dbr / tvnamer

Automatic TV episode file renamer, uses data from thetvdb.com via tvdb_api
https://pypi.python.org/pypi/tvnamer/
The Unlicense
912 stars 115 forks source link

TypeError: '<' not supported between instances of 'int' and 'str' #150

Closed lozbrown closed 4 years ago

lozbrown commented 5 years ago

I constantly get the following error in 2.5 and not sure how to resolve

Loading config: /home/loz/.tvnamer.json
####################
# Starting tvnamer
# Found 4 episodes
Traceback (most recent call last):
  File "/usr/local/bin/tvnamer", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/tvnamer/main.py", line 436, in main
    tvnamer(paths = sorted(args))
  File "/usr/local/lib/python3.6/dist-packages/tvnamer/main.py", line 317, in tvnamer
    episodes_found.sort(key = lambda x: x.sortable_info())
TypeError: '<' not supported between instances of 'int' and 'str'
kam1kaze commented 5 years ago

@lozbrown I've switched it to python 2 version and it works fine now.

alebianco commented 4 years ago

Still hitting this problem with python 2

$ python --version
Python 2.7.17
Loading config: ~/.tvnamer.json
####################
# Starting tvnamer
# Found 3 episodes
Traceback (most recent call last):
  File "/usr/local/Cellar/tvnamer/2.5/libexec/bin/tvnamer", line 11, in <module>
    load_entry_point('tvnamer==2.5', 'console_scripts', 'tvnamer')()
  File "/usr/local/Cellar/tvnamer/2.5/libexec/lib/python3.7/site-packages/tvnamer/main.py", line 449, in main
    tvnamer(paths = sorted(args))
  File "/usr/local/Cellar/tvnamer/2.5/libexec/lib/python3.7/site-packages/tvnamer/main.py", line 330, in tvnamer
    episodes_found.sort(key = lambda x: x.sortable_info())
TypeError: '<' not supported between instances of 'int' and 'str'

I think the error comes from the fact that i have some replacements in the config file that match to series ids:

"input_series_replacements": {
        "Marvel*s Agents of S*": 263365,
        "See": 361565,
        "Star Trek - Picard\\s*\\(\\d+\\)?": 364093,
        "Will & Grace": 71814,
        "The Walking Dead": 153021,
        "Devs\\s*\\(\\d+\\)?": 364149
    },

and in some occasions it tries to compare one of those ids (numeric) with a series name extracted from the filename (string).

lozbrown commented 4 years ago

Seeing this again after upgrading to Latest Ubuntu which of course pushes me to python 3

Loading config: /home/loz/.config/tvnamer/tvnamer.json
####################
# Starting tvnamer
Invalid filename: Cannot parse '/media/Virtual/Unsorted-Downloads/Paw Patrol Ready, Race, Rescue! (2019).mkv' with replacements: 'Paw Patrol Ready, Race, Rescue! (2019).mkv'
# Found 30 episodes
Traceback (most recent call last):
  File "/usr/local/bin/tvnamer", line 11, in <module>
    sys.exit(main())
  File "/home/loz/.local/lib/python3.8/site-packages/tvnamer/main.py", line 474, in main
    tvnamer(paths = sorted(args))
  File "/home/loz/.local/lib/python3.8/site-packages/tvnamer/main.py", line 337, in tvnamer
    episodes_found.sort(key = lambda x: x.sortable_info())
TypeError: '<' not supported between instances of 'int' and 'str'
dbr commented 4 years ago

Interesting, not sure why it's getting into that state instead of skipping over files it can't fully parse, shall try and look into this soon

alebianco commented 4 years ago

I think it happens when one of the file matched is of a series present in the input_series_replacements configuration, and another file is simply matched by name on tvdb

dbr commented 4 years ago

Yep that's exactly it - seriesname is usually a str, but the replacements can make it an series-ID integer.. and, importantly, sorted([1, "two", 3]) works in Python 2 but is now an error in 3

alebianco commented 4 years ago

glad it was confirmed 👍 also surprised it was closed 👎 since the project in the readme states

It supports Python 2.7 and 3.5 onwards

it would be nice to address the problem 🙏

alebianco commented 4 years ago

nevermind, I can't read obviously :D

thanks for fixing it 🔝

dbr commented 4 years ago

Ah yeh that wasn't clear - it's fixed in the latest development code, which will become tvnamer 4.0 (which will support Python 3.x only) which I hope to release sometime in the next couple of weeks

I might do a release of the current tvnamer 3.x release branch with this change backported sometime this week

lozbrown commented 3 years ago

Any chance of backporting this to 3.x, I'm hitting this frequently.

alebianco commented 3 years ago

@lozbrown while waiting for a backport, I just patched the files locally following the changes in the commit. When (and if) I get an update and my local changes are overwritten, I hope this fix will be included already ...

dbr commented 3 years ago

Released tvnamer 3.0.2 with this fix backported!