forked from moogar0880/PyTrakt
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Add IdsMixin to replace extract_ids() utility method (#14)
- Loading branch information
Showing
7 changed files
with
93 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Contains various MixIns""" | ||
|
||
__author__ = 'Jon Nappi, Elan Ruusamäe' | ||
|
||
|
||
class IdsMixin: | ||
""" | ||
Provides Mixin to translate "ids" array | ||
to appropriate provider ids in base class. | ||
This is replacement for extract_ids() utility method. | ||
""" | ||
|
||
__ids = ['imdb', 'slug', 'tmdb', 'trakt'] | ||
|
||
def __init__(self): | ||
self._ids = {} | ||
|
||
@property | ||
def ids(self): | ||
""" | ||
Accessor to the trakt, imdb, and tmdb ids, | ||
as well as the trakt.tv slug | ||
""" | ||
ids = {k: getattr(self, k, None) for k in self.__ids} | ||
return { | ||
'ids': ids | ||
} | ||
|
||
@property | ||
def imdb(self): | ||
return self._ids.get('imdb', None) | ||
|
||
@property | ||
def tmdb(self): | ||
return self._ids.get('tmdb', None) | ||
|
||
@property | ||
def trakt(self): | ||
return self._ids.get('trakt', None) | ||
|
||
@property | ||
def tvdb(self): | ||
return self._ids.get('tvdb', None) | ||
|
||
@property | ||
def tvrage(self): | ||
return self._ids.get('tvrage', None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.