66
77from trakt .core import Airs , Alias , Comment , Genre , delete , get
88from trakt .errors import NotFoundException
9+ from trakt .mixins import IdsMixin
910from trakt .sync import (Scrobbler , rate , comment , add_to_collection ,
1011 add_to_watchlist , add_to_history , remove_from_history ,
1112 remove_from_collection , remove_from_watchlist , search ,
1213 checkin_media , delete_checkin )
13- from trakt .utils import slugify , extract_ids , airs_date
14+ from trakt .utils import slugify , airs_date
1415from trakt .people import Person
1516
1617__author__ = 'Jon Nappi'
@@ -197,15 +198,15 @@ def anticipated_shows(page=1, limit=10, extended=None):
197198 yield [TVShow (** show ['show' ]) for show in data ]
198199
199200
200- class TVShow :
201+ class TVShow ( IdsMixin ) :
201202 """A Class representing a TV Show object."""
202203
203204 def __init__ (self , title = '' , slug = None , ** kwargs ):
204205 super ().__init__ ()
205206 self .media_type = 'shows'
206- self .top_watchers = self .top_episodes = self .year = self . tvdb = None
207- self .imdb = self . genres = self .certification = self .network = None
208- self .trakt = self . tmdb = self . _aliases = self ._comments = None
207+ self .top_watchers = self .top_episodes = self .year = None
208+ self .genres = self .certification = self .network = None
209+ self ._aliases = self ._comments = None
209210 self ._images = self ._people = self ._ratings = self ._translations = None
210211 self ._seasons = None
211212 self ._last_episode = self ._next_episode = None
@@ -219,6 +220,9 @@ def __init__(self, title='', slug=None, **kwargs):
219220
220221 @property
221222 def slug (self ):
223+ if self ._ids .get ('slug' , None ) is not None :
224+ return self ._ids ['slug' ]
225+
222226 if self ._slug is not None :
223227 return self ._slug
224228
@@ -244,7 +248,6 @@ def _get(self):
244248 self ._build (data )
245249
246250 def _build (self , data ):
247- extract_ids (data )
248251 for key , val in data .items ():
249252 if hasattr (self , '_' + key ):
250253 setattr (self , '_' + key , val )
@@ -363,16 +366,6 @@ def crew(self):
363366 """All of the crew members that worked on this :class:`TVShow`"""
364367 return [p for p in self .people if getattr (p , 'job' )]
365368
366- @property
367- def ids (self ):
368- """Accessor to the trakt, imdb, and tmdb ids, as well as the trakt.tv
369- slug
370- """
371- return {'ids' : {
372- 'trakt' : self .trakt , 'slug' : self .slug , 'imdb' : self .imdb ,
373- 'tmdb' : self .tmdb , 'tvdb' : self .tvdb
374- }}
375-
376369 @property
377370 @get
378371 def images (self ):
@@ -434,8 +427,6 @@ def seasons(self):
434427 data = yield self .ext + '/seasons?extended=episodes'
435428 self ._seasons = []
436429 for season in data :
437- extract_ids (season )
438-
439430 # Prepare episodes
440431 episodes = []
441432 for ep in season .pop ('episodes' , []):
@@ -447,6 +438,7 @@ def seasons(self):
447438 number = season .pop ('number' )
448439 season = TVSeason (self .title , number , self .slug , ** season )
449440 self ._seasons .append (season )
441+
450442 yield self ._seasons
451443
452444 @property
@@ -562,7 +554,7 @@ def __str__(self):
562554 __repr__ = __str__
563555
564556
565- class TVSeason :
557+ class TVSeason ( IdsMixin ) :
566558 """Container for TV Seasons"""
567559
568560 def __init__ (self , show , season = 1 , slug = None , ** kwargs ):
@@ -702,7 +694,7 @@ def __len__(self):
702694 __repr__ = __str__
703695
704696
705- class TVEpisode :
697+ class TVEpisode ( IdsMixin ) :
706698 """Container for TV Episodes"""
707699
708700 def __init__ (self , show , season , number = - 1 , ** kwargs ):
@@ -713,8 +705,8 @@ def __init__(self, show, season, number=-1, **kwargs):
713705 self .number = number
714706 self .overview = self .title = self .year = self .number_abs = None
715707 self .first_aired = self .last_updated = None
716- self .trakt = self . tmdb = self . tvdb = self . imdb = None
717- self .tvrage = self . _stats = self ._images = self ._comments = None
708+ self .runtime = None
709+ self ._stats = self ._images = self ._comments = None
718710 self ._translations = self ._ratings = None
719711 if len (kwargs ) > 0 :
720712 self ._build (kwargs )
@@ -732,7 +724,6 @@ def _get(self):
732724
733725 def _build (self , data ):
734726 """Build this :class:`TVEpisode` object with the data in *data*"""
735- extract_ids (data )
736727 for key , val in data .items ():
737728 if hasattr (self , '_' + key ):
738729 setattr (self , '_' + key , val )
@@ -782,15 +773,6 @@ def search(title, year=None):
782773 """
783774 return search (title , search_type = 'episode' , year = year )
784775
785- @property
786- def ids (self ):
787- """Accessor to the trakt, imdb, and tmdb ids, as well as the trakt.tv
788- slug
789- """
790- return {'ids' : {
791- 'trakt' : self .trakt , 'imdb' : self .imdb , 'tmdb' : self .tmdb
792- }}
793-
794776 @property
795777 @get
796778 def images (self ):
0 commit comments