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

API returns unexpected None for actors #73

Closed
plotski opened this issue Feb 27, 2020 · 7 comments · May be fixed by #81
Closed

API returns unexpected None for actors #73

plotski opened this issue Feb 27, 2020 · 7 comments · May be fixed by #81
Labels

Comments

@plotski
Copy link

plotski commented Feb 27, 2020

>>> Tvdb(cache=False, actors=True)['Death Valley (2014)']
[...]
DEBUG:urllib3.connectionpool:https://api.thetvdb.com:443 "GET /series/286509/actors HTTP/1.1" 404 21
DEBUG:tvdb_api:loadurl: https://api.thetvdb.com/series/286509/actors lid=en
DEBUG:tvdb_api:response:
DEBUG:tvdb_api:{'Error': 'not found'}
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/foo/code/pythonBits/venv/lib/python3.7/site-packages/tvdb_api.py", line 1182, in __getitem__
    sid = self._nameToSid(key)
  File "/home/foo/code/pythonBits/venv/lib/python3.7/site-packages/tvdb_api.py", line 1168, in _nameToSid
    self._getShowData(selected_series['id'], self.config['language'])
  File "/home/foo/code/pythonBits/venv/lib/python3.7/site-packages/tvdb_api.py", line 1110, in _getShowData
    self._parseActors(sid)
  File "/home/foo/code/pythonBits/venv/lib/python3.7/site-packages/tvdb_api.py", line 1057, in _parseActors
    for curActorItem in actorsEt:
TypeError: 'NoneType' object is not iterable

This should be easy to fix by wrapping the for loop at line 1057 in a if isinstance(actorsEt, abc.Iterable).

@dbr dbr added the bug label May 11, 2020
@dbr
Copy link
Owner

dbr commented May 11, 2020

Strangely I just get a show-not-found error with actors=True:

>>> Tvdb()["Death Valley (2014)"]
<Show 'Death Valley (2014)' (containing 1 seasons)>
>>> Tvdb(actors=True)["Death Valley (2014)"]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/dbr/code/tvdb_api/tvdb_api.py", line 1163, in __getitem__
    sid = self._nameToSid(key)
  File "/Users/dbr/code/tvdb_api/tvdb_api.py", line 1152, in _nameToSid
    self._getShowData(selected_series['id'], self.config['language'])
  File "/Users/dbr/code/tvdb_api/tvdb_api.py", line 1094, in _getShowData
    self._parseActors(sid)
  File "/Users/dbr/code/tvdb_api/tvdb_api.py", line 1038, in _parseActors
    actorsEt = self._getetsrc(self.config['url_actorsInfo'] % (sid))
  File "/Users/dbr/code/tvdb_api/tvdb_api.py", line 888, in _getetsrc
    src = self._loadUrl(url, language=language)
  File "/Users/dbr/code/tvdb_api/tvdb_api.py", line 852, in _loadUrl
    raise tvdb_error("%s" % error)
tvdb_api.tvdb_error: not found

@dbr
Copy link
Owner

dbr commented May 11, 2020

Not too sure why your code didn't throw the tvdb_error exception and instead continues - this should be handled in the _loadUrl method

@dbr
Copy link
Owner

dbr commented May 11, 2020

Ahh, the NoneType error was fixed as part of the changes in tvdb_api 3.0

So the problem is just
https://api.thetvdb.com/series/286509/actors
is returning the "not found" error instead of an empty list

@plotski
Copy link
Author

plotski commented May 11, 2020 via email

@dbr
Copy link
Owner

dbr commented May 11, 2020

Yep - 2.0 vs 3.0 explains the slightly different error produced, but either way it's caused by a problem with the API response from TheTVDB

@mueslo
Copy link

mueslo commented Jun 6, 2020

It would still be prudent to work around this exception in tvdb_api. So when it throws an exception, please just return None or an empty list. The further down this has to be mitigated, the uglier it becomes.

Maybe something like this: fd61946

@dbr
Copy link
Owner

dbr commented Jun 15, 2020

Summarised this in #85 - shall close this as there's a few duplicates and it's a bit hard to keep track. Thanks all!

@dbr dbr closed this as completed Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants