Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Return codes/ Exit statuses -- are they documented ? #882
Comments
|
Hey you can invoke youtube-dl in your python scripts easily by first importing youtube-dl and logging:
Then you have to make these classes:
and then to extract the information for a specific video you can just use:
I dont know why shk3/edx-downloader uses |
|
Keep this in mind that the code which i wrote above just gives you the information of a video like :
It wont download the video for you ! If you want it to download the video then you have to use:
If youtube-dl fails to extract the info then it will give you an error and you wont have any value in results variable. @esantoro Any further questions ? |
|
May I appropriate this issue to request that youtube-dl use exit codes to indicate success or failure? I am running youtube-dl from a script, and because youtube-dl doesn't return anything but 0, I have to do things like redirect its output to a log and grep it to see if it failed, instead of simply:
|
|
I'm also interested in this feature (exit codes). |
|
+1 (if not already implemented) |
|
No they are not. #852 |
|
It might be cool to have some particular return codes at least for some macro-category of errors. Assuming that It's been three years now, and random people still keep coming at this issue. I think it may be worth implementing this feature. |
|
On Linux exit codes can be 0~255. I guess there will eventually be more than 256 cases if we start to define exit codes. Another issue of exit codes is that those numbers are meaningless. I suggest using the Python API instead of relying on process exit codes for automatic jobs. Anyway there should be more exception classes than |
|
I said
@yan12125 said:
This is why we should have some error codes for macro-categories of errors (network errors, API errors, IO errors etc), and some error codes for very common failures (video id unavailable, requested format unavailable, etc). And a command line flag for detailed failure description. This way we can have macro- and micro- error reporting. |
|
Sorry, I didn't read the full thread. Defining macro categories is a good idea. How about HTTP-like status codes? For example 1 |
|
@yan12125 said:
API might be interpreted as:
or
The idea here is to let users know why youtube-dl failed, so that they can act consequently. |
|
I think the long term goal should be that the extractors simply return predefined error codes with optional error messages. These error codes can then be used as exit codes as well. 1-100 = Reserved for network errors, usage errors etc. (everything not extractor related) 101 = Video not found |
|
101 is already implemented for "--max-downloads exceeded". Sounds like it's some "API error" proposed by @esantoro. It shouldn't be changed, so 10x can be reserved for API errors. |
|
It's been six years now, and random people still keep coming at this issue. I think it may be worth implementing this feature. |
|
Yeah I'm honestly sorry I've been bothering the developers for the last six years with this, I really didn't mean to. |
|
+1 from me too. |
|
would like to add my vote as well. |
|
Lol almost seven years and and people are still asking for this. |
|
+1 That's useful for user. |
Hello there!
I use youtube-dl regularily on my laptop and i've seen it's also used in shk3/edx-downloader (a tool to download videso from edx online university), which I forked tonight and that i started hacking.
Now: one of the bugs i noticed is that it invokes youtube-dl via os.system, but if something bad happens it just lets the download fails and won't re-download the video.
I was then wondering if there are some particular exit codes to check for.
Or can i just assume that anything different from zero is a bad return value ?
Thanks in advance,
Emanuele Santoro