dbr / tvnamer

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

TVNamer 2.4 stopped working #160

Closed cdf1982 closed 4 years ago

cdf1982 commented 4 years ago

Hi, I don't feel great asking this as a issue, since it's more of a support request, but maybe this happened for others too... In the last few days TVNamer stopped working for me, always with the same traceback errors:

####################

Starting tvnamer

Found 1 episode

####################

Processing file: the.blacklist.S07E07.HDTV.x264-SVA.mkv

Detected series: the blacklist (season: 7, episode: 7)

Traceback (most recent call last): File "/usr/local/bin/tvnamer", line 9, in load_entry_point('tvnamer==2.4', 'console_scripts', 'tvnamer')() File "/Library/Python/2.7/site-packages/tvnamer/main.py", line 436, in main tvnamer(paths = sorted(args)) File "/Library/Python/2.7/site-packages/tvnamer/main.py", line 342, in tvnamer processFile(tvdb_instance, episode) File "/Library/Python/2.7/site-packages/tvnamer/main.py", line 170, in processFile episode.populateFromTvdb(tvdb_instance, force_name=Config['force_name'], series_id=Config['series_id']) File "/Library/Python/2.7/site-packages/tvnamer/utils.py", line 640, in populateFromTvdb show = tvdb_instance[force_name or self.seriesname] File "/Library/Python/2.7/site-packages/tvdb_api.py", line 1182, in getitem sid = self._nameToSid(key) File "/Library/Python/2.7/site-packages/tvdb_api.py", line 1168, in _nameToSid self._getShowData(selected_series['id'], self.config['language']) File "/Library/Python/2.7/site-packages/tvdb_api.py", line 1092, in _getShowData for curInfo in seriesInfoEt.keys(): AttributeError: 'NoneType' object has no attribute 'keys'

Nothing in my config file or system configuration has changed except for updating macOS to 10.14.6 a few days ago; I usually still have the system's python 2.7 configured as default, and it has worked fine for two years now, but today I also tried setting 3.7 as default; same error.

This is happening on 2 different computers, which makes me think that something might have changed in the tvdb response, but I'm out of my depth here.

I've come to rely on this amazing project (thank you for your work!) daily, so all help will be very much appreciated!

Cesare

mcagl commented 4 years ago

I just did some investigation...

Going in tvdb_api.py line 1092 it turns out that seriesInfoEt is None.

Just some lines above there is

seriesInfoEt = self._getetsrc(
            self.config['url_seriesInfo'] % sid
        )

And going to the implementation of _getetsrc() at line 900:

def _getetsrc(self, url, language=None):
        """Loads a URL using caching, returns an ElementTree of the source
        """
        src = self._loadUrl(url, language=language)

        return src

I added a simple print of the url, and found that it is something like https://api.thetvdb.com/series/##### that when visited it gives an auth error like this: {"Error":"Not authorized","authorizer":"cloudfront"}.

I don't know what the problem is, but it seems that TVNamer is not allowed to use the TVDB API anymore.

PS: Edited many times to do some better formatting, sorry...

emeidi commented 4 years ago

+1, same problem here.

emeidi commented 4 years ago

After reading

https://thetvdb.com/api-information

and looking at tvdb_api.py, my fear is the hardcoded API Key "borrowed" from thetvdb got either revoked or is still active, but can't be used by other projects anymore (wild guessing):

"apikey": "0629B785CE550C8D",

I will try to get my own API key, configure it for use with tvnamer and will share the outcome here:

apikey (str/unicode): Override the default thetvdb.com API key. By default it will use tvdb_api's own key (fine for small scripts), but you can use your own key if desired - this is recommended if you are embedding tvdb_api in a larger application) See http://thetvdb.com/?tab=apiregister to get your own key

emeidi commented 4 years ago

OK, I created an account on the site, got my personal API key and changed lines 699–704 in tvdb_api.py to the following:

else:
    self.config['auth_payload'] = {
        "apikey": "00000000-0000-0000-0000-000000000000",
        "userkey": "",
        "username": ""
    }

Unfortunately, retrieving show information still does not work.

I also tried to edit lines 346–353 in main.py of tvrenamer and pass the apikey when instantiating Tvdb:

tvdb_instance = Tvdb(
        interactive = not Config['select_first'],
        search_all_languages = Config['search_all_languages'],
        language = Config['language'],
        dvdorder = dvdorder,
        cache=cache,
        apikey='00000000-0000-0000-0000-000000000000',
    )

Didn't help either.

NB: Regarding userkey/username:

Note that the username and key are ONLY required for the /user routes. The user's key is labled Account Identifier in the account section of the main site. The TVDB API

dbr commented 4 years ago

I believe this is an ongoing server side issue with TheTVDB - there’s a forum thread linked in #157 with people having various similar issues

jim1138 commented 4 years ago

If I try a simple tvnamer . -v, I get something along the lines of:-

'# Detected series: The Big Bang Theory (season: 3, episode: 1)
2019-11-26 08:53:06,539 - tvdb_api - DEBUG - Getting show the big bang theory
2019-11-26 08:53:06,540 - tvdb_api - DEBUG - Searching for show the%20big%20bang%20theory
2019-11-26 08:53:06,540 - tvdb_api - DEBUG - Retrieving URL http://thetvdb.com/api/GetSeries.php?seriesname=the%20big%20bang%20theory&language=all
Traceback (most recent call last):
  File "/home/jim/.local/bin/tvnamer", line 11, in <module>
    sys.exit(main())
  File "build/bdist.linux-x86_64/egg/tvnamer/main.py", line 418, in main
  File "build/bdist.linux-x86_64/egg/tvnamer/main.py", line 325, in tvnamer
  File "build/bdist.linux-x86_64/egg/tvnamer/main.py", line 170, in processFile
  File "build/bdist.linux-x86_64/egg/tvnamer/utils.py", line 639, in populateFromTvdb
  File "build/bdist.linux-x86_64/egg/tvdb_api.py", line 870, in __getitem__
    if u'invalidLanguage' in errors:
  File "build/bdist.linux-x86_64/egg/tvdb_api.py", line 850, in _nameToSid
    self.authorize()
  File "build/bdist.linux-x86_64/egg/tvdb_api.py", line 647, in _getSeries
    ['da', 'fi', 'nl', ...]
  File "build/bdist.linux-x86_64/egg/tvdb_api.py", line 633, in search
    via the _actors key of a Show(), for example:
KeyError: 'all'

However, if I explicitly state the series id, then the the api appears to work, eg:-

tvnamer . --series-id=80379

# Detected series: The Big Bang Theory (season: 3, episode: 1)
2019-11-26 08:57:35,190 - tvdb_api - DEBUG - Configured language en override show language of en
2019-11-26 08:57:35,190 - tvdb_api - DEBUG - Getting all series data for 80379
2019-11-26 08:57:35,190 - tvdb_api - DEBUG - Retrieving URL http://thetvdb.com/api/0629B785CE550C8D/series/80379/en.xml
2019-11-26 08:57:35,299 - tvdb_api - DEBUG - Getting all episodes of 80379
2019-11-26 08:57:35,299 - tvdb_api - DEBUG - Retrieving URL http://thetvdb.com/api/0629B785CE550C8D/series/80379/all/en.xml
####################

Possibly issues with the api changes and dealing with the language=all ?

jim1138 commented 4 years ago

Problem solved. Having dug around I realised I was running old versions of tvnamer (2.2.1-1) & tvdb_api (1.9-1)

Removed them both and then used pip install tvnamer to install tvnamer version 2.5