pythonBits icon indicating copy to clipboard operation
pythonBits copied to clipboard

Try to guess season from episode names if directory does not contain it

Open plotski opened this issue 4 years ago • 4 comments

$ pythonbits 'any/existing/path/without/season/info' -c tv -f description
[...]
Traceback (most recent call last):
  File "/path/to/pythonBits/pythonbits/__main__.py", line 137, in main
    _main(Category, set_fields, get_fields)
  File "/path/to/pythonBits/pythonbits/__main__.py", line 113, in _main
    sub.show_fields(get_fields)
  File "/path/to/pythonBits/pythonbits/bb.py", line 51, in show_fields
    return super(BbSubmission, self).show_fields(
  File "/path/to/pythonBits/pythonbits/submission.py", line 236, in show_fields
    val = self[field]
  File "/path/to/pythonBits/pythonbits/submission.py", line 115, in __getitem__
    rv = field_renderer()
  File "/path/to/pythonBits/pythonbits/bb.py", line 633, in _render_description
    sections = [("Description", self['section_description']),
  File "/path/to/pythonBits/pythonbits/submission.py", line 115, in __getitem__
    rv = field_renderer()
  File "/path/to/pythonBits/pythonbits/bb.py", line 561, in _render_section_description
    summary = self['summary']
  File "/path/to/pythonBits/pythonbits/submission.py", line 115, in __getitem__
    rv = field_renderer()
  File "/path/to/pythonBits/pythonbits/bb.py", line 557, in _render_summary
    result = t.search(self['tv_specifier'])
  File "/path/to/pythonBits/pythonbits/submission.py", line 115, in __getitem__
    rv = field_renderer()
  File "/path/to/pythonBits/pythonbits/bb.py", line 249, in _render_tv_specifier
    return TvSpecifier(title, guess['season'],
KeyError: 'season'

This was fixed by my ugly confirmed_guess hack but is now an issue again after you reverted it.

As you said in the PR comment, this can be fixed by explicitly mentioning the season in the TITLE argument, but the exception above leaves the user hanging with no information what went wrong and what to do.

plotski avatar Jun 01 '20 10:06 plotski

Sorry about that! Can you give example filenames for which this happens?

mueslo avatar Jun 01 '20 10:06 mueslo

Use any path of an existing file or directory, it just can't contain any season information. This should reproduce the issue:

$ touch foo
$ pythonbits foo -c tv -f description

plotski avatar Jun 01 '20 11:06 plotski

Is this for miniseries? Why does your directory not contain the season? (kb.php?id=30)

From README.md:

In case the media title and type cannot be guessed from the path alone, you can explicitly specify them, e.g. pythonbits <path> "Doctor Who (2005) S06" or pythonbits <path> -c movie.

mueslo avatar Jun 01 '20 11:06 mueslo

I pm'd you an example.

Generally speaking, relying on user input is just asking for disaster. If the expected input is not there, software shouldn't just shrug and explode into the user's face. The least it should do is tell the user what's wrong and how to recover.

I think "This doesn't make any sense, please confirm this input: ..." is the most user-friendly way, but throwing an error like Missing season (try providing the TITLE argument, e.g. "<auto-fill in source name here> S01") would also be acceptable.

plotski avatar Jun 01 '20 12:06 plotski