youtube-dl: Errors written to screen instead of stderr
Errors are printed to screen directly instead of error stream (stderr)
stderr is used for errors and/or warnings, but in youtube-dl, errors are written specifically to the output screen through a “to_screen” function. It would be preferrable to direct errors to stderr to allow for error redirection for logs/etc.
For instance, in the following, I cannot store a copy of the error message in the standard way for redirection.
~$ sudo python3 /usr/local/bin/youtube-dl --version 2020.03.24 ~$ sudo python3 /usr/local/bin/youtube-dl -U ERROR: can't find the current version. Please try again later. ~$ sudo python3 /usr/local/bin/youtube-dl -U 2>./youtube_errors ERROR: can't find the current version. Please try again later. ~$ du -hsx youtube_errors 0 youtube_errors
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 15
~/youtube-dl$ grep “to_screen('ERROR” ./youtube_dl/update.py -n 50: to_screen(‘ERROR: can't find the current version. Please try again later.’) 63: to_screen(‘ERROR: can't obtain versions info. Please try again later.’) 66: to_screen(‘ERROR: the versions file is not signed or corrupted. Aborting.’) 71: to_screen(‘ERROR: the versions file signature is invalid. Aborting.’) 93: to_screen(‘ERROR: no write permissions on %s’ % filename) 101: to_screen(‘ERROR: no write permissions on %s’ % directory) 111: to_screen(‘ERROR: unable to download latest version’) 116: to_screen(‘ERROR: the downloaded file hash does not match. Aborting.’) 125: to_screen(‘ERROR: unable to write the new version’) 145: to_screen(‘ERROR: unable to overwrite current version’) 157: to_screen(‘ERROR: unable to download latest version’) 162: to_screen(‘ERROR: the downloaded file hash does not match. Aborting.’) 171: to_screen(‘ERROR: unable to overwrite current version’)
When I redirect stderr, everything goes to the screen regardless. As you can see in the following, the redirrecting to NULL results in output to the screen, same with redirecting to errors.txt, and the errors.txt file gets created but is empty (0 bytes in size). I’m using version 2020.03.24 in alpine linux, if that makes any difference.
$ python3 ./youtube-dl -U ERROR: can’t find the current version. Please try again later. $ python3 ./youtube-dl -U 2>/dev/null ERROR: can’t find the current version. Please try again later. $ python3 ./youtube-dl -U 2>errors.txt ERROR: can’t find the current version. Please try again later. $ stat errors.txt File: errors.txt Size: 0 Blocks: 0 IO Block: 512 regular empty file Device: 2h/2d Inode: 3940649674048836 Links: 1 Access: (0644/-rw-r–r–) Uid: ( 1000/ user) Gid: ( 1001/ user) Access: 2020-03-31 01:38:42.000000000 Modify: 2020-03-31 01:38:42.000000000 Change: 2020-03-31 01:38:42.000000000
$ cat errors.txt $
On Tue, Mar 31, 2020 at 10:26 AM Joshua Walden notifications@github.com wrote: