Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/test_shows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 4 additions & 3 deletions trakt/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
}
Expand Down