diff --git a/tests/test_shows.py b/tests/test_shows.py index 58da4fb..b4ba3a6 100644 --- a/tests/test_shows.py +++ b/tests/test_shows.py @@ -159,3 +159,12 @@ def test_next_episode(): def test_last_episode(): got = TVShow('Game of Thrones') assert isinstance(got.last_episode, TVEpisode) + + +def test_show_ids_include_tvdb(): + # tvdb is a primary Trakt id with an existing accessor; it must be present + # in .ids so downstream tvdb-guid matching (e.g. PlexTraktSync) resolves. + # Regression for tvdb being omitted from the ids accessor list. + got = TVShow('Game of Thrones') + assert got.tvdb == 121361 + assert got.ids['ids']['tvdb'] == 121361 diff --git a/trakt/mixins.py b/trakt/mixins.py index 3859dee..8c30241 100644 --- a/trakt/mixins.py +++ b/trakt/mixins.py @@ -35,7 +35,7 @@ class IdsMixin: This is replacement for extract_ids() utility method. """ - __ids = ['imdb', 'slug', 'tmdb', 'trakt'] + __ids = ['imdb', 'slug', 'tmdb', 'trakt', 'tvdb'] def __init__(self, ids=None): if ids is None: @@ -45,10 +45,11 @@ def __init__(self, ids=None): @property def ids(self): """ - Accessor to the trakt, imdb, and tmdb ids, - as well as the trakt.tv slug + Accessor to the trakt, imdb, tmdb and tvdb ids, as well as the + trakt.tv slug. Only ids present on the object are included. """ ids = {k: getattr(self, k, None) for k in self.__ids} + ids = {k: v for k, v in ids.items() if v is not None} return { 'ids': ids }