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

Invalid --dateafter crashes with no useful error #18170

Open
TorC8 opened this issue Nov 12, 2018 · 1 comment
Open

Invalid --dateafter crashes with no useful error #18170

TorC8 opened this issue Nov 12, 2018 · 1 comment

Comments

@TorC8
Copy link

@TorC8 TorC8 commented Nov 12, 2018

  • [x ] I've verified and I assure that I'm running youtube-dl 2018.11.07
  • [x ] At least skimmed through the README, most notably the FAQ and BUGS sections
  • [ x] Searched the bugtracker for similar issues including closed ones

What is the purpose of your issue?

  • [x ] Bug report (encountered problems with youtube-dl)

Description:

With a typo in the --dateafter making a nine digit number (in the below example, an extra 1 in the month), youtube-dl crashes without a useful error message for debugging the command. (Edited for clarity)


Minimal example command:

$ youtube-dl -v --dateafter 201811106
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'--dateafter', u'201811106']
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/bin/youtube-dl/__main__.py", line 19, in <module>
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 472, in main
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 220, in _real_main
  File "/usr/local/bin/youtube-dl/youtube_dl/utils.py", line 1330, in __init__
  File "/usr/local/bin/youtube-dl/youtube_dl/utils.py", line 1311, in date_from_str
  File "/usr/lib/python2.7/_strptime.py", line 335, in _strptime
    data_string[found.end():])
ValueError: unconverted data remains: 6

$ youtube-dl --version
2018.11.07

@TorC8
Copy link
Author

@TorC8 TorC8 commented Nov 18, 2018

Ran a couple extra tests. Looks like a short date either works, but may act on a wrong date, or throws a ValueError complaining about an invalid date format. Given what module throws the error, depending on how youtube-dl is allowed to handle errors, this may be an upstream bug.

Fix is probably to add a corrected version of the following to date_from_str in youtube-dl/utils at around line 1811:

if date_str in == re.match(r'^\d{7..}$', date_str)
    report_invalid_date_and_quit
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
1 participant
You can’t perform that action at this time.