Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

youtube-dl use with php #8679

Closed
mrfade opened this issue Feb 27, 2016 · 5 comments
Closed

youtube-dl use with php #8679

mrfade opened this issue Feb 27, 2016 · 5 comments

Comments

@mrfade
Copy link
Contributor

@mrfade mrfade commented Feb 27, 2016

hello
i want use youtube-dl with php but i cant do
im use this codes

     $url = 'https://www.youtube.com/watch?v=UyI4v5sxT54';
    $template = '/var/www/html/ytdl/' .
                'videos/%(id)s.%(ext)s';
    $string = ('youtube-dl --output=' . escapeshellarg($template) . ' ' . escapeshellarg($url));

    $descriptorspec = array(
       0 => array("pipe", "r"),  // stdin
       1 => array("pipe", "w"),  // stdout
       2 => array("pipe", "w"),  // stderr
    );
    $process = proc_open($string, $descriptorspec, $pipes);
    $stdout = stream_get_contents($pipes[1]);
    fclose($pipes[1]);
    $stderr = stream_get_contents($pipes[2]);
    fclose($pipes[2]);
    $ret = proc_close($process);
    echo json_encode(array('status' => $ret, 'errors' => $stderr,
                           'url_orginal'=>$url, 'output' => $stdout,
                           'command' => $string));

but this codes returns http://prntscr.com/a8l77k
please help me, sorry for my bad english

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Feb 27, 2016

Have you installed youtube-dl at all? What's the output of which youtube-dl?

@mrfade
Copy link
Contributor Author

@mrfade mrfade commented Feb 27, 2016

i installed youtube-dl, already i can download videos with youtube-dl on shell but i want to use this with php
Output: http://prntscr.com/a8la5v

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Feb 27, 2016

Specify full path to youtube-dl in script.

@mrfade
Copy link
Contributor Author

@mrfade mrfade commented Feb 27, 2016

like this?
/usr/local/bin/youtube-dl --output='/var/www/html/ytdl/videos/%(id)s.%(ext)s' 'https://www.youtube.com/watch?v=UyI4v5sxT54'

@mrfade
Copy link
Contributor Author

@mrfade mrfade commented Feb 27, 2016

dstftw thank you very much!, you are hero 👍

@mrfade mrfade closed this Feb 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.