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

Different return codes for different situations, please. #852

Closed
RonJohn2 opened this issue May 23, 2013 · 7 comments
Closed

Different return codes for different situations, please. #852

RonJohn2 opened this issue May 23, 2013 · 7 comments

Comments

@RonJohn2
Copy link

@RonJohn2 RonJohn2 commented May 23, 2013

Hi,

(Great job fixing the "slow flv" issue!)

ERROR: Unable to download video webpage: HTTP Error 404: Not Found
Also, when it fails to d/l the complete video.

Please exit with different "greater than 1" codes when such errors occur. That way, scripts can handle them in the appropriate manner.

Thanks.

@phihag
Copy link
Contributor

@phihag phihag commented May 23, 2013

Sorry, I don't understand your overall problem, and I strongly suspect there is a better solution. Why does your script want to know the reason why youtube-dl exited?

Why we could document exit codes and use multiple ones, that would become very complicating when multiple videos are involved.

@RonJohn2
Copy link
Author

@RonJohn2 RonJohn2 commented May 23, 2013

Different errors require different actions.
If yt-dl quit because:
a) of a network issue, then I want the script to loop, retrying the download until it completes.
b) the video doesn't exist anymore, then I want to skip that video.

"when multiple videos are involved."

Huh, I never noticed that you can d/l multiple videos. I put video URLs in a text file and the script reads the "head -n1" url, and once it's succeeded in downloading it, deletes it (with "sed '1d'" and again reads the "head -n1" url.

This way, I can keep appending URLs to the back of the file as I see fit.

@phihag
Copy link
Contributor

@phihag phihag commented May 23, 2013

a) is #506, #809 . Instead of just working with your script, it would be beneficial have this feature for all users of youtube-dl.

A 404 doesn't necessarily mean that the video doesn't exist - it could just be a temporary error. Basically, you want youtube-dl to download the video (and retry if a network issue occurs), and fail (with exit code 1) otherwise.

Checking of videos from the input batch file has been suggested as well, but that is indeed something that doesn't fit into youtube-dl's core competencies, although I wouldn't reject any code change to that effect.

I'm closing this issue now, as a duplicate of #505 and #809. However, feel free to comment if you think there are other reasons for multiple exit codes, and we'll promptly reopen it. Thanks!

@phihag phihag closed this May 23, 2013
@RonJohn2
Copy link
Author

@RonJohn2 RonJohn2 commented May 23, 2013

"--retries" seems a partial solution. Errors happen so infrequently, though, that I won't know for a while.

@weedy
Copy link

@weedy weedy commented Mar 16, 2016

I would like to have a different exit code for network based problems vs. out of space or other things.

@sergei-sh
Copy link

@sergei-sh sergei-sh commented May 11, 2016

I have a big script which downloads hundreds of videos and also tracks which video is already downloaded, which not needs being downloaded and log errors. Logging errors means automatically assigning error status after a try, not just human reading console. So I need to distinguish between a) success b) no video on page c) video is present but page is not supported (error happened). Now I have to analyze each log contents.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Aug 20, 2016

@sergei-sh Please go to #882 for future discussions. Exit codes sounds a possible feature for me, while this issue is already superseded by #882.

By the way, it's almost impossible to check whether there are videos or not. A common approach is introducing some heuristics, for example finding error strings in the web page. It should work in most cases but nobody can guarantee.

Anyway, #10308 should be resolved first - adding more exception classes to the code base.

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