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

How to know when all playlist videos as been downloaded? #7517

Closed
hedii opened this issue Nov 16, 2015 · 7 comments
Closed

How to know when all playlist videos as been downloaded? #7517

hedii opened this issue Nov 16, 2015 · 7 comments
Labels

Comments

@hedii
Copy link
Contributor

@hedii hedii commented Nov 16, 2015

When downloading playlist files, the line 'Downloading video x of x' is useful.
But it would be even more useful to have a line like that at the end of the output:
'All playlist videos downloaded'

I am using youtube-dl in a php app. I am parsing result lines to get progress, ETA, bandwidth, filename, etc..
But there is no information at all that i can use to know when the playlist download as ended.

Is there something to know when all playlist videos as been downloaded?

@jaimehrubiks
Copy link

@jaimehrubiks jaimehrubiks commented Nov 16, 2015

I don't see why you need that. You just check one by one and in the last one x/x you can see when it ends

@hedii
Copy link
Contributor Author

@hedii hedii commented Nov 16, 2015

no, because when the last x/x is displayed, the video has not yet been downloaded, or converted.

@jaimehrubiks
Copy link

@jaimehrubiks jaimehrubiks commented Nov 16, 2015

I see your point, and it is a good idea. Anyway I checked what I did and it is to wait for the process to end (it is in java anyway), you can also read the percentage after last x/x or even look for the word "error" for some cases.

@jaimeMF jaimeMF added the request label Nov 16, 2015
@hedii
Copy link
Contributor Author

@hedii hedii commented Nov 16, 2015

@jaimehrubiks thanks for your answer

  • waiting for the process to end is not relevant if youtube-dl is fired via an api: we just launch the download command and don't wait for a response. the response is the parsing of the command log (stored somewhere) each x sec. this is it that can indicate progress, download finish, conversion, etc...
  • read the percentage after last x/x is not relevant because there could be a converting process after the last download. if we want to do something on all the playlist files (in my case, zip the whole playlist), we have to wait for the end of the last converting process. To know the last download/convert as ended, we have to use very ugly, long, performance-killing regex that parse not the just the last line, but the whole file (last line and up to 'Downloading video x of x').
  • when youtube-dl is embeded in an external app (i've done it several times), it is better for performance to only parse the last line of the cmd output. We can use --exec echo 'blablabla' to output something that indicates the end of the download/conversion process when asking for a single video, but --exec is fired for each videos in a playlist, so this workaround is ineffective for playlists.

What about creating a new post processing option like that:

--exec-playlist CMD : Execute a command after all playlist's videos has been downloaded.

Or even easier, output a short message when the last video has been downloaded/converted: 'Process finished'.
It could be added to everything, not just playlists...

I don't know the python language, so i cannot propose a pull request :(

@jaimehrubiks
Copy link

@jaimehrubiks jaimehrubiks commented Nov 16, 2015

@hedii I see now. I wish someone adds this.

Anyway, again, I will try to help you :P
Just this:
youtube-dl https://www.youtube.com/playlist?list=PLAYLISTID end
and the last line is...
ERROR: u'end' is not a valid URL. Set --default-search "ytsearch" (or run youtube-dl "ytsearch:end" ) to search YouTube

So you check for: "ERROR: u'end'...." and you got it!

Edit:
You can achieve what you want this way (line 836):
http://i.imgur.com/uMAi5t8.png

But in case of other errors it might not be last line anyway. So another approach would be to add a text to the program itself when it ends.

I won't post any pull request because I don't know how the program is structured and this might not be the best way possible to achieve this.

@hedii
Copy link
Contributor Author

@hedii hedii commented Nov 16, 2015

@jaimehrubiks jajaja, dirty but it works. thanks

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Nov 17, 2015

You may need a more precise workaround for it:

if result_type == 'playlist':
    self.to_screen('[download] Process finished')

As these codes are also executed when a multi_video is finished.

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
4 participants
You can’t perform that action at this time.