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

Exception for specific tv show #95

Closed balrok closed 10 years ago

balrok commented 10 years ago

Hello, I always get an exception when tvnamer tries to download the episode information. To reproduce this:

mkdir test
cd test
touch "Katekyo Hitman Reborn - [01x01] - What I m the 10th Generation Mafia Boss .flv"
tvnamer .

The exception looks like this:

# Processing file: Katekyo Hitman Reborn - [01x01] - What I m the 10th Generation Mafia Boss .flv
# Detected series: Katekyo Hitman Reborn (season: 1, episode: 1)
TVDB Search Results:
1 -> Katekyo Hitman Reborn! [en] # http://thetvdb.com/?tab=series&id=80975&lid=7 (default)
2 -> Katekyo Hitman Reborn [de] # http://thetvdb.com/?tab=series&id=80975&lid=14
3 -> Katekyō Hitman Reborn! [es] # http://thetvdb.com/?tab=series&id=80975&lid=16
Enter choice (first number, return for default, 'all', ? for help):

Traceback (most recent call last):
  File "/usr/local/bin/tvnamer", line 9, in <module>
    load_entry_point('tvnamer==2.3', 'console_scripts', 'tvnamer')()
  File "/usr/local/lib/python2.7/dist-packages/tvnamer-2.3-py2.7.egg/tvnamer/main.py", line 418, in main
    tvnamer(paths = sorted(args))
  File "/usr/local/lib/python2.7/dist-packages/tvnamer-2.3-py2.7.egg/tvnamer/main.py", line 325, in tvnamer
    processFile(tvdb_instance, episode)
  File "/usr/local/lib/python2.7/dist-packages/tvnamer-2.3-py2.7.egg/tvnamer/main.py", line 170, in processFile
    episode.populateFromTvdb(tvdb_instance, force_name=Config['force_name'], series_id=Config['series_id'])
  File "/usr/local/lib/python2.7/dist-packages/tvnamer-2.3-py2.7.egg/tvnamer/utils.py", line 639, in populateFromTvdb
    show = tvdb_instance[force_name or self.seriesname]
  File "/usr/local/lib/python2.7/dist-packages/tvdb_api-1.9-py2.7.egg/tvdb_api.py", line 871, in __getitem__
    sid = self._nameToSid(key)
  File "/usr/local/lib/python2.7/dist-packages/tvdb_api-1.9-py2.7.egg/tvdb_api.py", line 856, in _nameToSid
    self._getShowData(selected_series['id'], selected_series['language'])
  File "/usr/local/lib/python2.7/dist-packages/tvdb_api-1.9-py2.7.egg/tvdb_api.py", line 829, in _getShowData
    ep_no = int(cur_ep.find('EpisodeNumber').text)
AttributeError: 'NoneType' object has no attribute 'text'

I tried to debug a bit - that is why the linenumbers might be off a bit.

Also thank you for your nice tool - I already renamed over 20 tv shows without a problem and very easy :)

dbr commented 10 years ago

Ah, interesting - I think it's breaking because one of the episodes is missing an EpisodeNumber.. Not quite sure which one, one of the ones in here:

http://thetvdb.com/api/0629B785CE550C8D/series/80975/all/en.xml

..producing:

<Element 'Combined_episodenumber' at 0x10cf0b450> None
<Element 'Combined_season' at 0x10cf0b480> 9
<Element 'EpisodeName' at 0x10cf0b4b0> None
<Element 'Language' at 0x10cf0b4e0> en
<Element 'Overview' at 0x10cf0b510> None
<Element 'SeasonNumber' at 0x10cf0b540> 9

I shall fix tvdb_api so it skips that for now

dbr commented 10 years ago

That show also contains weird data, like

<Combined_episodenumber>12.0</Combined_episodenumber>

..which causes a different error.

balrok commented 10 years ago

Thank you for the fast response and fixes :)

thezoggy commented 10 years ago

http://forums.thetvdb.com/viewtopic.php?f=7&t=17412&p=64409#p64409