From 277198685eee89500c0478d2a3d21b10b20ccb5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Sat, 26 Oct 2019 23:17:14 -0400 Subject: [PATCH] WIP --- bazarr/database.py | 7 ++++- bazarr/get_subtitle.py | 4 +-- bazarr/list_subtitles.py | 4 +-- bazarr/main.py | 16 ++++------ bazarr/notifier.py | 2 +- views/movie.tpl | 64 ++++++++++++++++++++-------------------- views/movies.tpl | 26 ++++++++-------- views/wanted.tpl | 28 +++++++----------- 8 files changed, 73 insertions(+), 78 deletions(-) diff --git a/bazarr/database.py b/bazarr/database.py index ef7e71309..6c15dc658 100644 --- a/bazarr/database.py +++ b/bazarr/database.py @@ -1,5 +1,6 @@ import os from sqlite3worker import Sqlite3Worker +from six import string_types from get_args import args from helper import path_replace, path_replace_movie, path_replace_reverse, path_replace_reverse_movie @@ -19,7 +20,7 @@ class SqliteDictConverter: if type(values_dict) is dict: for key, value in values_dict.items(): self.keys += key + ", " - if type(value) not in [str, unicode]: + if type(value) is not string_types: value = str(value) else: value = "\"" + value + "\"" @@ -46,6 +47,8 @@ class SqliteDictPathMapper: item['path'] = path_replace(item['path']) elif type(values_dict) is dict: values_dict['path'] = path_replace(values_dict['path']) + else: + return path_replace(values_dict) def path_replace_movie(self, values_dict): if type(values_dict) is list: @@ -53,6 +56,8 @@ class SqliteDictPathMapper: item['path'] = path_replace_movie(item['path']) elif type(values_dict) is dict: values_dict['path'] = path_replace_movie(values_dict['path']) + else: + return path_replace(values_dict) dict_mapper = SqliteDictPathMapper() \ No newline at end of file diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py index 1f9b64fd1..97788c04d 100644 --- a/bazarr/get_subtitle.py +++ b/bazarr/get_subtitle.py @@ -913,8 +913,8 @@ def refine_from_db(path, video): video.title = re.sub(r'(\(\d\d\d\d\))', '', data['title']) if data['year']: if int(data['year']) > 0: video.year = int(data['year']) - if data['imdb_id']: video.imdb_id = data['imdb_id'] - video.alternative_titles = ast.literal_eval(data['alternative_titles']) + if data['imdbId']: video.imdb_id = data['imdbId'] + video.alternative_titles = ast.literal_eval(data['alternativeTitles']) if not video.format: if data['format']: video.format = data['format'] if not video.resolution: diff --git a/bazarr/list_subtitles.py b/bazarr/list_subtitles.py index 19c2e12d6..23fff3384 100644 --- a/bazarr/list_subtitles.py +++ b/bazarr/list_subtitles.py @@ -277,7 +277,7 @@ def list_missing_subtitles(no=None, epno=None): def list_missing_subtitles_movies(no=None): if no is not None: - movies_subtitles_clause = " WHERE radarrId=no" + movies_subtitles_clause = " WHERE radarrId=" + str(no) else: movies_subtitles_clause = "" @@ -325,7 +325,7 @@ def list_missing_subtitles_movies(no=None): missing_subtitles_global.append(tuple([str(missing_subtitles), movie_subtitles['radarrId']])) for missing_subtitles_item in missing_subtitles_global: - database.execute("UPDATE table_movies SET missing_subtitles=? WHERE radarrIr=?", + database.execute("UPDATE table_movies SET missing_subtitles=? WHERE radarrId=?", (missing_subtitles_item[0], missing_subtitles_item[1])) diff --git a/bazarr/main.py b/bazarr/main.py index 0bb429e90..be4ee07fd 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -609,7 +609,7 @@ def search_json(query): if settings.general.getboolean('use_radarr'): # Get matching movies - movies = database.execute("SELECT title, radarrId, year FROM table_movies WEHRE title LIKE ? ORDER BY " + movies = database.execute("SELECT title, radarrId, year FROM table_movies WHERE title LIKE ? ORDER BY " "title ASC", (query,)) for movie in movies: search_list.append(dict([('name', re.sub(r'\ \(\d{4}\)', '', movie['title']) + ' (' + movie['year'] + ')'), @@ -741,9 +741,9 @@ def movies(): languages = database.execute("SELECT code2, name FROM table_settings_languages WHERE enabled=1") return template('movies', bazarr_version=bazarr_version, rows=data, languages=languages, - missing_count=missing_count, page=page, max_page=max_page, base_url=base_url, - single_language=settings.general.getboolean('single_language'), page_size=page_size, - current_port=settings.general.port) + missing_count=missing_count, page=page, max_page=max_page, base_url=base_url, + single_language=settings.general.getboolean('single_language'), page_size=page_size, + current_port=settings.general.port) @route(base_url + 'movieseditor') @@ -843,13 +843,9 @@ def movie(no): "scenename, monitored, failedAttempts, forced FROM table_movies " "WHERE radarrId=?", (no,), only_one=True) # path_replace - dict_mapper.path_replace(movies_details) - - for movie_details in movies_details: - movies_details = movie_details - break + dict_mapper.path_replace_movie(movies_details) - tmdbid = movies_details['tmdb_id'] + tmdbid = movies_details['tmdbId'] languages = database.execute("SELECT code2, name FROM table_settings_languages WHERE enabled=1") diff --git a/bazarr/notifier.py b/bazarr/notifier.py index 1280ef54b..9bb226c4c 100644 --- a/bazarr/notifier.py +++ b/bazarr/notifier.py @@ -49,7 +49,7 @@ def get_notifier_providers(): def get_series_name(sonarrSeriesId): data = database.execute("SELECT title FROM table_shows WHERE sonarrSeriesId=?", (sonarrSeriesId,), only_one=True) - return data[0]['title'] or None + return data['title'] or None def get_episode_name(sonarrEpisodeId): diff --git a/views/movie.tpl b/views/movie.tpl index 803a78706..e5c552564 100644 --- a/views/movie.tpl +++ b/views/movie.tpl @@ -19,11 +19,11 @@ -