Open phihag opened 13 years ago
Showing status (and probably aborting, too) seems surprisingly difficult. I think we can trick around by the following:
{"status":"downloading"}
{"status": "downloading"}
within 10 secondsAbort now works like this:
Showing progress works like this:
All in all, rather complicated, but achievable.
Since the php code may be nontrivial, it should be developed outside of the main repository.
Did this ever get moved out to some other repo/forked? Is there work going on? A smooth browser interface would be extremely convenient.
I too am curious what is the status of this issue.
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?
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".
@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.
@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?
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
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}
@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.
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
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.
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
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.