Download Instagram Vids Via Linux Bash Script Example

Go down

Download Instagram Vids Via Linux Bash Script Example Empty Download Instagram Vids Via Linux Bash Script Example

Post by jamied_uk on 12th November 2018, 14:08




Script



Code:
#!/bin/bash
# (c) J~Net 2018
# jnet.forumotion.com/t1655-download-instagram-vids-via-linux-bash-script-example#2553
#
# Example:
#
# ./run.sh "https://www.instagram.com/p/BqFMLEig93K/?utm_source=ig_share_sheet&igshid=1bxa7vyyr78c9"
#
#
cd /home/jay/Documents/Scripts/Instagram_Download
#
wget $1 -O out.html
#
cat out.html | grep "<meta property=\"og:video\" content=\"" > out.txt
#
clear
cat out.txt | grep "content=\"https://" > new.txt
grep -o ' <meta property.*/>' new.txt | sed 's/\(<meta property\|<\/>\)//g' > final.txt
str=`cat final.txt`
echo "$str" | cut -c 23- > final.txt
str=`cat final.txt`
# Remove last 4 chars
echo ${str::-4} > final.txt
#
str=`cat final.txt`
#readarray a < out.txt
#
wget $str
#
rm *.html
rm out.txt
rm out2.txt
rm new.txt
rm final.txt

Make executable and run




Soon I will put a php script for this so you can use it via a web page.

Vid Coming Soon!


Script
jamied_uk
jamied_uk
Admin

Posts : 2471
Join date : 2010-05-09
Age : 36
Location : UK

http://address-shortner.co.uk

Back to top Go down

Download Instagram Vids Via Linux Bash Script Example Empty PHP Front End

Post by jamied_uk on 12th November 2018, 21:42

For a PHP based front end to do the same thing using above bash script you can do this too Very Happy




Before you start make sure any folders you want files to download to via a php script, you will need to allow www-data access to execute bash scripts and have correct folder permissions!

Run.sh script

Code:
#!/bin/bash
#
#export TERM=xterm
export TERM=linux
# ./run.sh https://www.instagram.com/p/BqA5E3QhRTB/?utm_source=ig_share_sheet&igshid=w4vbfaltu7c4
#
url="$1"
if [ -z "$url" ]
then
    echo "\url is empty"
else
    cd "/var/www/html/apps/Downloader/ig/"
    wget $url -O out.html
#
    cat out.html | grep "<meta property=\"og:video\" content=\"" > out.txt
#
    cat out.txt | grep "content=\"https://" > new.txt
    grep -o ' <meta property.*/>' new.txt | sed 's/\(<meta property\|<\/>\)//g' > final.txt
    str=`cat final.txt`
    echo "$str" | cut -c 23- > final.txt
    str=`cat final.txt`
# Remove last 4 chars
    echo ${str::-4} > final.txt
#
    str=`cat final.txt`
#readarray a < out.txt
#
    wget "$str"
#
    rm *.html
    rm out.txt
    #rm out2.txt
    rm new.txt
    rm final.txt   
    #echo "\url is set to $url"
    mv *.mp4 output.mp4
fi
#cd $url
#


Index.php


Code:
<!DOCTYPE HTML>
<meta http-equiv="Pragma" content="no-cache">
<title>J~Net Instagram Video Downloader</title>
<html> 
<body>
<?php
session_start();
if(!$_SESSION['userid']){
header("Location: /index.php");
exit;
}  ?>
<?php
include_once("../../../php_includes/check_login_status.php");
include("../../../headerd.php");
$id=$_SESSION['userid'];
$username=$_SESSION['username'];

?>
<center>
<link rel="stylesheet" href="css/style.css">

<link rel="stylesheet" type="text/css" href="css/button3.css">
<style>
.button {
    background-color: #4CAF50; /* Green */
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    cursor: pointer;
}
</style>

<header id="header"><h1 class="logo"><a href="/">J~Net Instagram Video Downloader</a></h1><p class="subtitle">Instagram Photo, Video, and IGTV Downloader</p><form id="main_form" action="process.php" method="post" onsubmit="return false;>
<div class="main_input_wrapper"><input autofocus="" placeholder="https://instagram.com/p/41SW_pmmq4/" name="url" value="" style="color:#000;"></div><div class="actions"><input value="Download" class="button" type="submit"></div>

</form><div id="results" style="opacity: 1;"><div class="success"></div>

</div><div id="waiting" style="transform-origin: 0px 0px 0px; opacity: 1; transform: scale(1, 1); display: none;"><div class="loading"><span></span> <span></span> <span></span></div></div><div id="waitingdls">Your download will start in a few seconds.</div><section class="zen"><div id="zen">  </div></section></header>


</body>
</html>


Process.php


Code:
<!DOCTYPE HTML>
<meta http-equiv="Pragma" content="no-cache">
<title>J~Net Instagram Video Downloader</title>
<html> 
<body>
<?php
session_start();
if(!$_SESSION['userid']){
header("Location: /index.php");
exit;
}  ?>
<?php
include_once("../../../php_includes/check_login_status.php");
include("../../../headerd.php");
$id=$_SESSION['userid'];
$username=$_SESSION['username'];
//
//$url=$_POST['url'];
$url=filter_var($_POST['url'], FILTER_SANITIZE_STRING);

?>
<center>
<link rel="stylesheet" href="css/style.css">

<style>
.button {
    background-color: #4CAF50; /* Green */
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    cursor: pointer;
}
</style>


<h2>J~Net Instagram Video Downloader</h2>
<p><br>


<?php
echo "<center>Downloading Video From Link $url<p><br>";


function Build(){
sleep(1);
//$name="output.mp4";
$message=shell_exec("/var/www/html/apps/Downloader/ig/run.sh \"$url\" 2>&1");
//print_r($message);
echo '<p><br>';
echo "<img src=\"$url\">";
}

if (isset($_POST['url']))
//$name="output.mp4";
//echo "$name";
$message=shell_exec("/var/www/html/apps/Downloader/ig/run.sh \"$url\" 2>&1");
//print_r($message);
echo '<p><br>';
$link='<div id="results" style="opacity: 1;"><div class="success"><a href="output.mp4?dl=1" class="button button_green" target="_blank">Download video</a></div>';


//Build($name);
?>
<p><br>


<?php echo $link;?>

<p><br>

<link rel="stylesheet" type="text/css" href="css/button3.css">

<div id="breadcrumbsc" onclick="location.href='index.php';" style="cursor: pointer;">
<center>
<h2>Back</h2>
</center>
</div>



<script>
function Build(){
 alert("<?php Build(); ?>");
 }
</script>

</body>
</html>
jamied_uk
jamied_uk
Admin

Posts : 2471
Join date : 2010-05-09
Age : 36
Location : UK

http://address-shortner.co.uk

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum