diff --git a/resources/lib/itemtypes/movies.py b/resources/lib/itemtypes/movies.py index 26b5a100..f9193c88 100644 --- a/resources/lib/itemtypes/movies.py +++ b/resources/lib/itemtypes/movies.py @@ -91,6 +91,14 @@ class Movie(ItemBase): api.provider('imdb'), "imdb", uniqueid) + elif api.provider('tmdb') is not None: + uniqueid = self.kodidb.get_uniqueid(kodi_id, + v.KODI_TYPE_MOVIE) + self.kodidb.update_uniqueid(kodi_id, + v.KODI_TYPE_MOVIE, + api.provider('tmdb'), + "tmdb", + uniqueid) else: self.kodidb.remove_uniqueid(kodi_id, v.KODI_TYPE_MOVIE) uniqueid = -1 @@ -120,6 +128,13 @@ class Movie(ItemBase): v.KODI_TYPE_MOVIE, api.provider('imdb'), "imdb") + elif api.provider('tmdb') is not None: + uniqueid = self.kodidb.add_uniqueid_id() + self.kodidb.add_uniqueid(uniqueid, + kodi_id, + v.KODI_TYPE_MOVIE, + api.provider('tmdb'), + "tmdb") else: uniqueid = -1 self.kodidb.add_people(kodi_id, diff --git a/resources/lib/itemtypes/tvshows.py b/resources/lib/itemtypes/tvshows.py index bb09ab20..61d8d050 100644 --- a/resources/lib/itemtypes/tvshows.py +++ b/resources/lib/itemtypes/tvshows.py @@ -204,6 +204,14 @@ class Show(TvShowMixin, ItemBase): api.provider('tvdb'), 'tvdb', uniqueid) + elif api.provider('tmdb') is not None: + uniqueid = self.kodidb.get_uniqueid(kodi_id, + v.KODI_TYPE_SHOW) + self.kodidb.update_uniqueid(kodi_id, + v.KODI_TYPE_SHOW, + api.provider('tmdb'), + 'tmdb', + uniqueid) else: self.kodidb.remove_uniqueid(kodi_id, v.KODI_TYPE_SHOW) uniqueid = -1 @@ -245,6 +253,13 @@ class Show(TvShowMixin, ItemBase): v.KODI_TYPE_SHOW, api.provider('tvdb'), 'tvdb') + if api.provider('tmdb'): + uniqueid = self.kodidb.add_uniqueid_id() + self.kodidb.add_uniqueid(uniqueid, + kodi_id, + v.KODI_TYPE_SHOW, + api.provider('tmdb'), + 'tmdb') else: uniqueid = -1 self.kodidb.add_people(kodi_id, @@ -490,6 +505,14 @@ class Episode(TvShowMixin, ItemBase): api.provider('tvdb'), "tvdb", uniqueid) + elif api.provider('tmdb'): + uniqueid = self.kodidb.get_uniqueid(kodi_id, + v.KODI_TYPE_EPISODE) + self.kodidb.update_uniqueid(kodi_id, + v.KODI_TYPE_EPISODE, + api.provider('tmdb'), + "tmdb", + uniqueid) else: self.kodidb.remove_uniqueid(kodi_id, v.KODI_TYPE_EPISODE) uniqueid = -1 @@ -568,6 +591,15 @@ class Episode(TvShowMixin, ItemBase): v.KODI_TYPE_EPISODE, api.provider('tvdb'), "tvdb") + elif api.provider('tmdb'): + uniqueid = self.kodidb.add_uniqueid_id() + self.kodidb.add_uniqueid(uniqueid, + kodi_id, + v.KODI_TYPE_EPISODE, + api.provider('tmdb'), + "tmdb") + else: + uniqueid = -1 self.kodidb.add_people(kodi_id, v.KODI_TYPE_EPISODE, api.people()) diff --git a/resources/lib/plex_api/base.py b/resources/lib/plex_api/base.py index 096cd47e..e14bcf21 100644 --- a/resources/lib/plex_api/base.py +++ b/resources/lib/plex_api/base.py @@ -552,6 +552,9 @@ class Base(object): elif providername == 'tvdb': # originally e.g. com.plexapp.agents.thetvdb://276564?lang=en regex = utils.REGEX_TVDB + elif providername == 'tmdb': + # originally e.g. com.plexapp.agents.themoviedb://603?lang=en + regex = utils.REGEX_TMDB else: raise NotImplementedError('Not implemented: %s' % providername) diff --git a/resources/lib/utils.py b/resources/lib/utils.py index e9496463..391fe481 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -49,6 +49,7 @@ REGEX_PLEX_DIRECT = re.compile(r'''\.plex\.direct:\d+$''') # Plex API REGEX_IMDB = re.compile(r'''/(tt\d+)''') REGEX_TVDB = re.compile(r'''thetvdb:\/\/(.+?)\?''') +REGEX_TMDB = re.compile(r'''themoviedb:\/\/(.+?)\?''') # Plex music REGEX_MUSICPATH = re.compile(r'''^\^(.+)\$$''') # Grab Plex id from an URL-encoded string