Note that there are some explanatory texts on larger screens.

plurals
  1. POyoutube-dl and php exec
    primarykey
    data
    text
    <p>I have installed youtube-dl on my CentOS 6 / Plesk 10 Dedicated server, and via SSH, everything works like a charm !</p> <p>The thing is I'm trying to write a php script which takes a POST parameter in containing the URL of the video I want to copy to the server, copy it and then process it with ffmpeg.</p> <p>I thought I would use the exec() function. </p> <p>I can get an output if I echo the results of <code>youtube-dl --help</code>, but everytime I ask php to execute a command which actually does something with the video, it returns a status of '1', and outputs nothing.</p> <p>Any ideas on what I'm doing wrong ?</p> <p>Here is my php code: </p> <pre><code>&lt;?php $result = array(); $status; $url = $_POST['src']; $string = 'youtube-dl "'.$url.'" -f 18 -o "/var/www/vhosts/my.virtual.host.net/httpdocs/downloader/downloads/%(id)s.%(ext)s"'; $string2 = 'youtube-dl --help'; exec($string, $result, $status); echo json_encode(array('status' =&gt; $status, 'url_orginal'=&gt;$url, 'url' =&gt; $result)); ?&gt; </code></pre> <p>When I execute $string2, I get status: "0" and "url": [youtube-dl help text lines]</p> <p>But when I execute $string, nothing happens, I get "status": "1" and nothing else, no video is downloaded. I've tried also a simulation with the "-g" parameter, and variants but as soon as youtube-dl has to fetch the video, it breaks.</p> <p>Thank you in advance !</p> <p>EDIT</p> <p>I edited my code so it looks like this :</p> <pre><code>&lt;?php $result = array(); $status; $url = $_POST['src']; $string = 'youtube-dl "'.$url.'" -f 18 -o "/var/www/vhosts/my.virtual.host.net/httpdocs/downloader/downloads/%(id)s.%(ext)s"'; $string2 = 'youtube-dl --help'; exec($string, $result, $status); echo json_encode(array('status' =&gt; $status, 'url_orginal'=&gt;$url, 'url' =&gt; $result, 'command' =&gt; $string)); ?&gt; </code></pre> <p>and the result, which I didn't get yesterday now is :</p> <pre><code>command: "youtube-dl "http://www.youtube.com/watch?v=coq9klG41R8" -f 18 -o "/var/www/vhosts/my.virtual.host.net/httpdocs/downloader/downloads/%(id)s.%(ext)s"" status: 1 url: 0: "[youtube] Setting language" 1: "[youtube] coq9klG41R8: Downloading video info webpage" 2: "[youtube] coq9klG41R8: Extracting video information" url_orginal: "http://www.youtube.com/watch?v=coq9klG41R8" </code></pre> <p>Which is weird, considering a) that yesterday I got an empty url[], and that b) even if now I get what apparently looks like a normal youtube-dl return, it only contains the 3 first lines, and I cannot see any video file in the specified path... Any ideas ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload