From 7c5839ab0dfdd49d76c59c10ae157ae162f13066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 6 Oct 2020 22:23:33 -0400 Subject: [PATCH] Added imdb_id for series --- bazarr/database.py | 1 + bazarr/get_series.py | 10 +++++++--- bazarr/get_subtitle.py | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bazarr/database.py b/bazarr/database.py index 005d96345..9f5b3a2ef 100644 --- a/bazarr/database.py +++ b/bazarr/database.py @@ -94,6 +94,7 @@ def db_upgrade(): ['table_shows', 'forced', 'text', 'False'], ['table_shows', 'tags', 'text', '[]'], ['table_shows', 'seriesType', 'text', ''], + ['table_shows', 'imdbId', 'text', ''], ['table_episodes', 'format', 'text'], ['table_episodes', 'resolution', 'text'], ['table_episodes', 'video_codec', 'text'], diff --git a/bazarr/get_series.py b/bazarr/get_series.py index fb263ff8f..64c7987e2 100644 --- a/bazarr/get_series.py +++ b/bazarr/get_series.py @@ -83,6 +83,8 @@ def update_series(): tags = [d['label'] for d in tagsDict if d['id'] in show['tags']] + imdbId = show['imdbId'] if 'imdbId' in show else None + # Add shows in Sonarr to current shows list current_shows_sonarr.append(show['id']) @@ -99,7 +101,8 @@ def update_series(): 'year': str(show['year']), 'alternateTitles': alternate_titles, 'tags': str(tags), - 'seriesType': show['seriesType']}) + 'seriesType': show['seriesType'], + 'imdbId': imdbId}) else: series_to_add.append({'title': show["title"], 'path': show["path"], @@ -116,7 +119,8 @@ def update_series(): 'alternateTitles': alternate_titles, 'forced': serie_default_forced, 'tags': str(tags), - 'seriesType': show['seriesType']}) + 'seriesType': show['seriesType'], + 'imdbId': imdbId}) # Remove old series from DB removed_series = list(set(current_shows_db_list) - set(current_shows_sonarr)) @@ -128,7 +132,7 @@ def update_series(): # Update existing series in DB series_in_db_list = [] series_in_db = database.execute("SELECT title, path, tvdbId, sonarrSeriesId, overview, poster, fanart, " - "audio_language, sortTitle, year, alternateTitles, tags, seriesType FROM table_shows") + "audio_language, sortTitle, year, alternateTitles, tags, seriesType, imdbId FROM table_shows") for item in series_in_db: series_in_db_list.append(item) diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py index 1b9ebe28e..cd9acd2e4 100644 --- a/bazarr/get_subtitle.py +++ b/bazarr/get_subtitle.py @@ -1027,7 +1027,7 @@ def refine_from_db(path, video): "SELECT table_shows.title as seriesTitle, table_episodes.season, table_episodes.episode, " "table_episodes.title as episodeTitle, table_shows.year, table_shows.tvdbId, " "table_shows.alternateTitles, table_episodes.format, table_episodes.resolution, " - "table_episodes.video_codec, table_episodes.audio_codec, table_episodes.path " + "table_episodes.video_codec, table_episodes.audio_codec, table_episodes.path, table_shows.imdbId " "FROM table_episodes INNER JOIN table_shows on " "table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId " "WHERE table_episodes.path = ?", (path_mappings.path_replace_reverse(path),), only_one=True) @@ -1042,6 +1042,8 @@ def refine_from_db(path, video): # if int(data['year']) > 0: video.year = int(data['year']) video.series_tvdb_id = int(data['tvdbId']) video.alternative_series = ast.literal_eval(data['alternateTitles']) + if data['imdbId'] and not video.series_imdb_id: + video.series_imdb_id = data['imdbId'] if not video.source: video.source = str(data['format']) if not video.resolution: