ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
132.7k stars 10.07k forks source link

Create a php API and demo page #152

Open phihag opened 13 years ago

phihag commented 13 years ago

youtube-dl is often embedded by php applications. There should be an example php page included, with the following features:

This may require an additional output option in youtube-dl, for example the ability to output JSON sentences.

phihag commented 13 years ago

Showing status (and probably aborting, too) seems surprisingly difficult. I think we can trick around by the following:

Abort now works like this:

Showing progress works like this:

All in all, rather complicated, but achievable.

phihag commented 13 years ago

Since the php code may be nontrivial, it should be developed outside of the main repository.

viddypiddy commented 12 years ago

Did this ever get moved out to some other repo/forked? Is there work going on? A smooth browser interface would be extremely convenient.

bassrock commented 12 years ago

I too am curious what is the status of this issue.

bencrundwell commented 12 years ago

I'm really keen to get the downloading progress in my PHP application. I patched a previous version to output a .progress file every second and then used PHP to poll it. But with the latest required update I have lost my patch. Would it be possible to add an output of current progress?

glisignoli commented 11 years ago

My thoughts on this was to just implement a sqlite database that multiple youtube-dl instances could access and update. This would allow multiple instances of youtube-dl to run, while allowing a single (or multiple) frontend(s) to read the sqlite database for updates on the running processes. This would be an easier update to youtube-dl than writing an API layer(or at least in my mind it is). What this doesn't allow is control over running processes, although at the moment only use this would be would to stop the download/convert, which is just a kill of the PID.

I'm interested myself in adding this functionality, unfortunately python isn't a language I am familiar with, but I have enough free time that I am willing to "give it a go".

bassrock commented 11 years ago

@glisignoli That sounds like a really good idea for processing a bunch of youtube videos!! Maybe even using a worker service like resque or sidekiq! We could have a really decent server solution that we can just pass videos to using an api.

pricejn2 commented 11 years ago

@phihag - I found one of you examples at http://www.verious.com/qa/youtube-dl-and-php-exec/ Don't suppose you have any others out there to share?

yasoob commented 11 years ago

Check this for help on some issues.

SpEcHiDe commented 9 years ago

PHP file <?php if(isset($_POST['submit'])){ $c=$_POST['cmqwe']; // save to directory $b=$_POST['link']; // video link $a="yt-dl.sh"; // youtube dl script name

            $com="sh ".$a." ".$b." ".$c;
            $com=shell_exec("sh ".$a." ".$b." ".$c);
            $com=nl2br($com);
            echo $com . "<br /><hr />" ;
        }

?>

SH file

!/bin/sh

ping -c1 "www.google.com" 2>&1 > /dev/null

if [ $? -ne 0 ]; then echo "connect to internet and try again" else if [ $# -ne 2 ]; then echo "usage instructions : sh ${0} " else cd ${2} ./youtube-dl ${1} fi fi

yan12125 commented 9 years ago

@SpEcHiDe Your script is quite dangerous. Imagine the POST data:

submit=Submit&cmqwe=foobar&link=foobar;rm+-rf+/home

Anyway, pass $_POST or $_GET data to shell_exec() without proper escaping is VERY VERY dangerous.

siddht4 commented 7 years ago

This can be done by mere sanitize the data.I have tried where the index page takes user input url.A session cookie is auto injected.When the user clicks on submit button the ajax requests post the data which is sanitized along with user ip,cookie and store it in mariadb(I have tried in mariadb,so this will also work for mysql or percona db).

ydl_opts and my_hook can be customized to form a json which can be shown to the user as actual download status.

The only issue left here is how to send back user to download the complete file.It was internal so not a big deal. if d['status'] == 'finished': to send a callback to download page is what i m thinking now

siddht4 commented 7 years ago

I have tried the json part https://github.com/siddht1/youtube_dl_embed/blob/master/1.py ,this will create a file a.json which can be used as an api feature.Merge this with https://github.com/siddht3/table_json_creator to create a api type.

Things still missing are url provided and extractor details.Which I suppose my_hook has.

bato3 commented 6 years ago

It isn't example, but full site: https://github.com/Rudloff/alltube

If you want create simple youtube-dl server it's better use NODE: https://www.npmjs.com/package/youtube-dl