From dab1f8ba2038dfa3c6cb239786685469535316fa Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Sun, 11 Feb 2018 22:03:15 -0800 Subject: [PATCH] Save The Movie Database info after lookup --- plexpy/notification_handler.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 1315df96..6b1f47c9 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -531,7 +531,7 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m notify_params['trakt_url'] = 'https://trakt.tv/search/tvdb/' + notify_params['thetvdb_id'] + '?id_type=show' elif 'thetvdbdvdorder://' in notify_params['guid']: - notify_params['thetvdb_id'] = notify_params['guid'].split('thetvdbdvdorder://')[1].split('/')[0] + notify_params['thetvdb_id'] = notify_params['guid'].split('thetvdbdvdorder://')[1].split('/')[0].split('?')[0] notify_params['thetvdb_url'] = 'https://thetvdb.com/?tab=series&id=' + notify_params['thetvdb_id'] notify_params['trakt_url'] = 'https://trakt.tv/search/tvdb/' + notify_params['thetvdb_id'] + '?id_type=show' @@ -542,7 +542,7 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m notify_params['trakt_url'] = 'https://trakt.tv/search/tmdb/' + notify_params['themoviedb_id'] + '?id_type=movie' elif notify_params['media_type'] in ('show', 'season', 'episode'): - notify_params['themoviedb_id'] = notify_params['guid'].split('themoviedb://')[1].split('/')[0] + notify_params['themoviedb_id'] = notify_params['guid'].split('themoviedb://')[1].split('/')[0].split('?')[0] notify_params['themoviedb_url'] = 'https://www.themoviedb.org/tv/' + notify_params['themoviedb_id'] notify_params['trakt_url'] = 'https://trakt.tv/search/tmdb/' + notify_params['themoviedb_id'] + '?id_type=show' @@ -1199,6 +1199,17 @@ def get_themoviedb_info(rating_key=None, media_type=None, themoviedb_id=None): if response and not err_msg: themoviedb_json = response.json() + themoviedb_id = themoviedb_json['id'] + themoviedb_url = 'https://www.themoviedb.org/{}/{}'.format(media_type, themoviedb_id) + + keys = {'themoviedb_id': themoviedb_id} + themoviedb_info = {'rating_key': rating_key, + 'imdb_id': themoviedb_json.get('imdb_id'), + 'themoviedb_url': themoviedb_url, + 'themoviedb_json': json.dumps(themoviedb_json) + } + + db.upsert(table_name='themoviedb_lookup', key_dict=keys, value_dict=themoviedb_info) else: if err_msg: