Added imdb_id for series

This commit is contained in:
Louis Vézina 2020-10-06 22:23:33 -04:00
parent 49e7dfa0f5
commit 7c5839ab0d
3 changed files with 11 additions and 4 deletions

View File

@ -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'],

View File

@ -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)

View File

@ -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: