Youtube-dl video download script with single click from the browser
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
^^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
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
^^I cant post the code her due to CF (you got the idea ).
Don't use this PHP code ffs. He doesn't make use "escapeshellcmd".
Anyone with minimal effort can get access to your system
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
Our radiant Russian mob @Revovler has spoken.
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.
Alright I'm already working on updating it give me few minutes .
I update the script now it's only accept youtube video url
I'd just like to make it clear that I deny helping generate this code.
is it all that bad !
@Revolver said no. And he isn't a guy who'd say so outright.
Aye, it's that bad.
Yes. Thanks for your effort, though. Off to Alltube & it's plugin.
Just use the escapeshellcmd() function, it's a 5 minute fix.
Reinventing the wheel, LET style.
Fixing PHP code is like pissing against the wind, except it stinks more.