Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Use youtube-dl in a PhP script. #711
Comments
|
This isn't an issue with youtube-dl. Also, why do you have an "echo" in the front of that line. |
|
shell_exec('cd /home/ftp8/public_html/temp && /usr/local/bin/youtube-dl --max-quality FLV "https://www.youtube.com/watch?v=GMuZdN84PJg'); in php doesnt work any solution for this ? |
|
how you run youtube-dl from php ? you use it in scripts if yes give me the command |
|
Thank your for reporting this issue, @doctorbinsibar . In your second example, you're missing a double quote at the end. Most likelky, that's the cause of the problem. Can you copy and paste the actual code (or even better, upload it) you're using? And it would help immensely if you'd describe doesn't work in detail - what does the program output, what do you see in php's error_log, and what on your filesystem? For reference, this program: <?php
$url = 'https://www.youtube.com/watch?v=GMuZdN84PJg';
$cmd = 'youtube-dl -o "/home/phihag/div/tmp/%(id)s.%(ext)s" ' . escapeshellarg($url);
exec($cmd, $output, $ret);
echo 'output: ';
var_export($output);
echo "\nret: ";
var_export($ret);works fine on my system (with php 5.4.4), and outputs:
|
|
its a simple script that i have build for experiments. must youtube-dl be the same folder as the script ? |
|
now look at this : http://ftp8.org/tes.php This php file has only this inside: $cmd = 'youtube-dl -o "/home/ftp8/public_html/temp/%(id)s.%(ext)s" --max-quality flv" "https://www.youtube.com/watch?v=GMuZdN84PJg"'; the video must downloaded to http://ftp8.org/temp/ no luck ! |
|
$cmd = 'youtube-dl -o "/home/ftp8/public_html/temp/%(id)s.%(ext)s" --max-quality flv https://www.youtube.com/watch?v=GMuZdN84PJg'; Working with Shell absolutly fine but in php no chance when i use it in puddy working nice !!! |
$cmd = 'youtube-dl -o "/home/ftp8/public_html/temp/%(id)s.%(ext)s" --max-quality flv" "https://www.youtube.com/watch?v=GMuZdN84PJg"';
shell_exec($cmd);will just output that. php files with php code in them must start with In your first code example, you've got one quote too much, right after flv. |
Run this File: http://ftp8.org/tes.php (its the above code) Temp Folder chmod 777 |
|
@doctorbinsibar It looks like youtube-dl is not in your PATH. What output do you get if you replace |
|
output: array ( ) ret: 1 Error Log:
added PHP Info on the Page anything missing for this command ? |
|
That looks a lot better; youtube-dl is being executed now. Without the full output one would get with <?php
$cmd = `/usr/bin/env python --version`
passthru($cmd); |
|
Python 2.6.6 just installed it because of youtube-dl i have added your last code about python version in the php file, looks like the same problem. |
|
@doctorbinsibar What exact output do you get when you run <?php
$cmd = `/usr/bin/env python --version`
passthru($cmd);on your server? |
|
hope you can help me out the third part is now to reach under
|
|
Quite obviously, that's not the output of the script you posted - it ends with But let's stop guessing and modify the example script to include stderr output:
Modify the path in |
|
if i change the $cmd to
|
|
updated python to 3.3 here is the output: stdout: '' stderr: 'sys:1: DeprecationWarning: Non-ASCII character '\xcc' in file /usr/local/bin/youtube-dl on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details File "/usr/local/bin/youtube-dl", line 2 PK���Ì·ÙTe“Ï mµÐÍ�ÊØ†à¤ó¶K�v“g¼b��š–�»ó�[å0åŠeysÍ |
|
Ah, thanks, that's precisely what I guessed: You have an old version of Python. If you add
you'll see that your webserver's Python is not your user's. But fret not, you can simply call
that should work, as long as your Python is installed in |
|
hey @phihag i also have an issue related to youtube-dl My issue is that youtube-dl is perfectly download video from all the mentioned websites except YOUTUBE. Some days ago youtube-dl works flawless but from past 4 days it doesn't download videos from youtube. i used your code, written @ #711 (comment) and i got output is given below:- stdout: '[youtube] Setting language [youtube] mnUvNeUqh_E: Downloading video webpage ' stderr: 'WARNING: unable to set language: HTTP Error 402: Payment Required ERROR: unable to download video webpage: HTTP Error 402: Payment Required ' ret: 1 can you please explain... why i got this message and what it means...?? Thanks in advance |
|
@ankita1990 As mentioned in the FAQ, that message means that youtube blocked your IP address for excessive connections. Are you, by any chance, using a downloader such as axel, or downloading thousands of videos? In any case, as documented in the FAQ feel free to propose code to solve the CAPTCHA (i.e. show it to the user in some way / give it to a program that does that). You may also want to use multiple IP addresses. |
|
@doctorbinsibar Has updating to a newer Python/calling youtube-dl with that Python version solved your problem? |
|
thank you phihag, the problem was solved after using the path of the python file |
For a Script that i want to develop i want to download youtube videos from a PHP script.
If i call it with shell_exec(); it doesnt work.
youtube-dl --max-quality=FLV "https://www.youtube.com/watch?v=hGgr8ZbeNgQ"
i call this in shell browser works fine.
I make this in php script doesnt work:
echo exec('youtube-dl --max-quality=FLV "https://www.youtube.com/watch?v=hGgr8ZbeNgQ" ');
Please help