Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Youtube-dl video download script with single click from the browser
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Youtube-dl video download script with single click from the browser

inklightinklight Member
edited December 2018 in Tutorials

Few days ago I post request asking better way to download from youtube without using browser slow download manger with help from @uhu & @Mr_Tom and other ,
This is simple way to download video from youtube on Linux without using any extension or extra tools runs on background .
on this method we will use already running local server (I assume you already install/config it with php-fpm ) .
create new file yt.php on local host root folder
https://pastebin.com/raw/0PN1u1sM
^^I cant post the code here due to CF .

A bit explain about the code I'm using static build of ffmpeg so I add it full path to the command /usr/local/sbin/ffmpegchange that path if you using different location
let's go to quality selecting ,

 --audio-format opus --audio-quality 48k -f " bestvideo[ext=webm][height <=? 360 ]+worstaudio[ext=webm]/bestvideo[ext=mp4][height <=? 480 ]+worstaudio[ext=webm]" 

I have limited Internet connection that's way I select video codec to be VP9 and video dimension 360p , if not available it will select AV1(h264) mp4/480p , change it as you like
BTW youtube-dl now select best video best audio by default , so if you have better Internet connection you can remove this part .

  --external-downloader axel --external-downloader-args " -U \'Mozilla\' -n 7 " 

This import part for axel are more efficient using your Internet connection to download video much faster .
now for browser integration since I'm not expert developing browser extension , so I use simplest method by adding JS bookmark url . to send GET request to localhost php script
https://pastebin.com/raw/ksANMgdT
^^I cant post the code her due to CF (you got the idea ).

Thanked by 1that_guy

Comments

  • Don't use this PHP code ffs. He doesn't make use "escapeshellcmd".

    Anyone with minimal effort can get access to your system

  • inklightinklight Member
    edited December 2018

    vovler said: Don't use this PHP code ffs. He doesn't make use "escapeshellcmd".

    the script are open for any contributing I just made the simplest way to doing it ,
    anyway their is youtube-dl-server ready for use without needs for nginx or php-fpm , I guess it more secure the this one

  • deankdeank Member, Troll

    Our radiant Russian mob @Revovler has spoken.

    Case closed.

  • jackbjackb Member, Host Rep
    edited December 2018

    @inklight said:

    vovler said: Don't use this PHP code ffs. He doesn't make use "escapeshellcmd".

    the script are open for any contributing I just made the simplest way to doing it ,

    What you've published is downright dangerous. You need to properly sanitise anything you're pumping into the command line.

    If you want to take the simplest approach and get yourself rooted that's on you, but if you're providing anyone else it you should take basic precautions and sanitise your inputs... I'd suggest fixing it and updating your link in the OP before someone misses the comments below and gets themselves rooted.

    Thanked by 3eol nulldev vimalware
  • inklightinklight Member
    edited December 2018

    jackb said: I'd suggest fixing it and updating your link in the OP before someone misses the comments below and gets themselves rooted.

    Alright I'm already working on updating it give me few minutes .
    I update the script now it's only accept youtube video url

    $url  =  explode("?v=",$_REQUEST['v'])[1]   ;
    if ( !preg_match("/^[-_a-zA-Z0-9.]+$/", $url) )
    die() ;
    
    Thanked by 1jackb
  • I'd just like to make it clear that I deny helping generate this code.

    Thanked by 2eol netomx
  • uhu said: I'd just like to make it clear that I deny helping generate this code

    is it all that bad !

  • deankdeank Member, Troll

    @Revolver said no. And he isn't a guy who'd say so outright.

    Aye, it's that bad.

    Thanked by 1vovler
  • inklight said: is it all that bad !

    Yes. Thanks for your effort, though. Off to Alltube & it's plugin.

  • @inklight said:

    jackb said: I'd suggest fixing it and updating your link in the OP before someone misses the comments below and gets themselves rooted.

    Alright I'm already working on updating it give me few minutes .
    I update the script now it's only accept youtube video url

    $url = explode("?v=",$_REQUEST['v'])[1] ;
    if ( !preg_match("/^[-_a-zA-Z0-9.]+$/", $url) )
    die() ;

    Just use the escapeshellcmd() function, it's a 5 minute fix.

    Thanked by 2nulldev jackb
  • deankdeank Member, Troll

    Reinventing the wheel, LET style.

    Thanked by 2vovler netomx
  • Fixing PHP code is like pissing against the wind, except it stinks more.

    Thanked by 1eol
Sign In or Register to comment.