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

Get exit status of youtube-dl.exe in batch script #13855

Closed
EWouters opened this issue Aug 8, 2017 · 2 comments
Closed

Get exit status of youtube-dl.exe in batch script #13855

EWouters opened this issue Aug 8, 2017 · 2 comments
Labels

Comments

@EWouters
Copy link

@EWouters EWouters commented Aug 8, 2017

Hi, I am trying to write a simple batch script because my downloads keep returning this error: ERROR: content too short (expected 3432356 bytes and served 2830796) and I want them to auto retry until successful.

I wrote the following:

@ECHO OFF
SET /P url="Paste URL to download: "
ECHO Download %url%
:while1
for /f "delims=" %%a in ('youtube-dl.exe %url%') do @set result=%%a
if %ERRORLEVEL% NEQ 0 (
    ECHO %result%
    ECHO Failed, retrying...
    GOTO while1
)
ECHO Success!
pause

But even when there is an error it will go to Success. How can I get the exit status of youtube-dl.exe in my if statement?

Thanks!

BTW: it would be awesome if there would be an option to retry until successful in youtube-dl itself. Then it could also be robust against wrong urls.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Aug 8, 2017

for executes command in a separate cmd.exe process thus you're getting errorlevel this process not youtube-dl.

@dstftw dstftw closed this Aug 8, 2017
@dstftw dstftw added the duplicate label Aug 8, 2017
@EWouters
Copy link
Author

@EWouters EWouters commented Aug 8, 2017

How ignorant of me, thank you. This now solves my problem:

@ECHO OFF
SET /P url="Paste URL to download: "
:while
youtube-dl.exe %url%
if %ERRORLEVEL% NEQ 0 (
    ECHO Failed, retrying...
    GOTO while
)
ECHO Success!
PAUSE

I would still love it if this feature would be added.

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