From 681af943330172e9d6b5b132f542cca6a25cbdba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 13 Mar 2019 13:28:59 -0400 Subject: [PATCH] Fix for #346. --- bazarr/get_subtitle.py | 10 ++++++---- bazarr/main.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py index eeea3242c..7531d565e 100644 --- a/bazarr/get_subtitle.py +++ b/bazarr/get_subtitle.py @@ -660,14 +660,15 @@ def refine_from_db(path, video): if isinstance(video, Episode): db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30) c = db.cursor() - data = c.execute("SELECT table_shows.title, table_episodes.season, table_episodes.episode, table_episodes.title, table_shows.year, table_shows.tvdbId, table_shows.alternateTitles, table_episodes.format, table_episodes.resolution, table_episodes.video_codec, table_episodes.audio_codec FROM table_episodes INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE table_episodes.path = ?", (path_replace_reverse(path),)).fetchone() + data = c.execute("SELECT table_shows.title, table_episodes.season, table_episodes.episode, table_episodes.title, table_shows.year, table_shows.tvdbId, table_shows.alternateTitles, table_episodes.format, table_episodes.resolution, table_episodes.video_codec, table_episodes.audio_codec FROM table_episodes INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE table_episodes.path = ?", (unicode(path_replace_reverse(path)),)).fetchone() db.close() if data: video.series = re.sub(r'(\(\d\d\d\d\))' , '', data[0]) video.season = int(data[1]) video.episode = int(data[2]) video.title = data[3] - if int(data[4]) > 0: video.year = int(data[4]) + if data[4]: + if int(data[4]) > 0: video.year = int(data[4]) video.series_tvdb_id = int(data[5]) video.alternative_series = ast.literal_eval(data[6]) if not video.format: @@ -681,11 +682,12 @@ def refine_from_db(path, video): elif isinstance(video, Movie): db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30) c = db.cursor() - data = c.execute("SELECT title, year, alternativeTitles, format, resolution, video_codec, audio_codec, imdbId FROM table_movies WHERE path = ?", (path_replace_reverse_movie(path),)).fetchone() + data = c.execute("SELECT title, year, alternativeTitles, format, resolution, video_codec, audio_codec, imdbId FROM table_movies WHERE path = ?", (unicode(path_replace_reverse_movie(path)),)).fetchone() db.close() if data: video.title = re.sub(r'(\(\d\d\d\d\))' , '', data[0]) - if int(data[1]) > 0: video.year = int(data[1]) + if data[1]: + if int(data[1]) > 0: video.year = int(data[1]) if data[7]: video.imdb_id = data[7] video.alternative_titles = ast.literal_eval(data[2]) if not video.format: diff --git a/bazarr/main.py b/bazarr/main.py index 37b1446f9..bfb98fe42 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -1,6 +1,6 @@ # coding=utf-8 -bazarr_version = '0.7.3' +bazarr_version = '0.7.2.1' import gc import sys