From 3a7381c0d20f8fe3a4a174b1c58e61540cfdb071 Mon Sep 17 00:00:00 2001 From: Halali Date: Fri, 21 Sep 2018 14:48:12 +0200 Subject: [PATCH 01/26] fix for not able to login when changeing from basic to form login type --- views/settings.tpl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/views/settings.tpl b/views/settings.tpl index 392246f29..3ccedffa8 100644 --- a/views/settings.tpl +++ b/views/settings.tpl @@ -1507,6 +1507,12 @@ else { $('.auth_option').show(); }; + if ($('#settings_auth_type').val() == "form") { + $('#settings_auth_password').val(''); + } + else { + $('#settings_auth_password').val('{{settings_auth[2]}}'); + }; }); $('#settings_languages').dropdown('setting', 'onAdd', function(val, txt){ From 367f5c314d1b083984d99bd75ee983cdbaabf9ce Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Fri, 21 Sep 2018 09:28:35 -0400 Subject: [PATCH 02/26] Revert "fix for not able to login when changeing from basic to form login type" This reverts commit 3a7381c0d20f8fe3a4a174b1c58e61540cfdb071. --- views/settings.tpl | 6 ------ 1 file changed, 6 deletions(-) diff --git a/views/settings.tpl b/views/settings.tpl index 3ccedffa8..392246f29 100644 --- a/views/settings.tpl +++ b/views/settings.tpl @@ -1507,12 +1507,6 @@ else { $('.auth_option').show(); }; - if ($('#settings_auth_type').val() == "form") { - $('#settings_auth_password').val(''); - } - else { - $('#settings_auth_password').val('{{settings_auth[2]}}'); - }; }); $('#settings_languages').dropdown('setting', 'onAdd', function(val, txt){ From 1de528bcdb47126f3e685a6e90f523dfd19c5866 Mon Sep 17 00:00:00 2001 From: Halali Date: Fri, 21 Sep 2018 15:35:05 +0200 Subject: [PATCH 03/26] Revert "fix for not able to login when changeing from basic to form login type" This reverts commit 3a7381c0d20f8fe3a4a174b1c58e61540cfdb071. --- views/settings.tpl | 6 ------ 1 file changed, 6 deletions(-) diff --git a/views/settings.tpl b/views/settings.tpl index 3ccedffa8..392246f29 100644 --- a/views/settings.tpl +++ b/views/settings.tpl @@ -1507,12 +1507,6 @@ else { $('.auth_option').show(); }; - if ($('#settings_auth_type').val() == "form") { - $('#settings_auth_password').val(''); - } - else { - $('#settings_auth_password').val('{{settings_auth[2]}}'); - }; }); $('#settings_languages').dropdown('setting', 'onAdd', function(val, txt){ From d4cd75b0fb6f9bb653d66d60d869e1db55b74fcc Mon Sep 17 00:00:00 2001 From: Halali Date: Sat, 22 Sep 2018 12:15:52 +0200 Subject: [PATCH 04/26] fix for not able to login when changeing from basic to form login type --- views/settings.tpl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/views/settings.tpl b/views/settings.tpl index 392246f29..1648fc06e 100644 --- a/views/settings.tpl +++ b/views/settings.tpl @@ -1509,6 +1509,20 @@ }; }); + // Load default value for Settings_auth_type + $('#settings_auth_type').dropdown('clear'); + $('#settings_auth_type').dropdown('set selected','{{!settings_auth[0]}}'); + + // Remove value from Password input when changing to Form login to prevent bad password saving + $("#settings_auth_type").change(function() { + if ($(this).val() == 'form'){ + $('#settings_auth_password').val(''); + } + else { + $('#settings_auth_password').val('{{settings_auth[2]}}'); + } + }); + $('#settings_languages').dropdown('setting', 'onAdd', function(val, txt){ $("#settings_serie_default_languages").append( $("").attr("value", val).text(txt) @@ -1669,8 +1683,6 @@ %if settings_general[19] is not None: $('#settings_movie_default_languages').dropdown('set selected',{{!settings_general[19]}}); %end - $('#settings_auth_type').dropdown('clear'); - $('#settings_auth_type').dropdown('set selected','{{!settings_auth[0]}}'); $('#settings_branch').dropdown(); $('#settings_sonarr_sync').dropdown(); $('#settings_radarr_sync').dropdown(); From 54329b0d2bd6f1e2f909994be4382c9f2aed20ac Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Sat, 22 Sep 2018 18:07:46 -0400 Subject: [PATCH 05/26] Fix for providers auth not used --- bazarr.py | 129 +++++------------------------------------------ get_providers.py | 74 ++++++++++++++++++++------- get_subtitle.py | 79 ++++------------------------- 3 files changed, 79 insertions(+), 203 deletions(-) diff --git a/bazarr.py b/bazarr.py index e97beed01..aa5558104 100644 --- a/bazarr.py +++ b/bazarr.py @@ -85,7 +85,8 @@ import hashlib import time from get_languages import load_language_in_db, language_from_alpha3 -from get_providers import * +from get_providers import load_providers, get_providers, get_providers_auth +load_providers() from get_series import * from get_episodes import * @@ -1473,28 +1474,8 @@ def get_subtitle(): sonarrEpisodeId = request.forms.get('sonarrEpisodeId') # tvdbid = request.forms.get('tvdbid') - db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) - c = db.cursor() - c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1") - enabled_providers = c.fetchall() - c.close() - - providers_list = [] - providers_auth = {} - if len(enabled_providers) > 0: - for provider in enabled_providers: - providers_list.append(provider[0]) - try: - if provider[2] is not '' and provider[3] is not '': - provider_auth = providers_auth.append(provider[0]) - provider_auth.update({'username':providers[2], 'password':providers[3]}) - else: - providers_auth = None - except: - providers_auth = None - else: - providers_list = None - providers_auth = None + providers_list = get_providers() + providers_auth = get_providers_auth() try: result = download_subtitle(episodePath, language, hi, providers_list, providers_auth, sceneName, 'series') @@ -1518,28 +1499,8 @@ def manual_search_json(): language = request.forms.get('language') hi = request.forms.get('hi') - db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) - c = db.cursor() - c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1") - enabled_providers = c.fetchall() - c.close() - - providers_list = [] - providers_auth = {} - if len(enabled_providers) > 0: - for provider in enabled_providers: - providers_list.append(provider[0]) - try: - if provider[2] is not '' and provider[3] is not '': - provider_auth = providers_auth.append(provider[0]) - provider_auth.update({'username':providers[2], 'password':providers[3]}) - else: - providers_auth = None - except: - providers_auth = None - else: - providers_list = None - providers_auth = None + providers_list = get_providers() + providers_auth = get_providers_auth() data = manual_search(episodePath, language, hi, providers_list, providers_auth, sceneName, 'series') return dict(data=data) @@ -1559,19 +1520,8 @@ def manual_get_subtitle(): sonarrSeriesId = request.forms.get('sonarrSeriesId') sonarrEpisodeId = request.forms.get('sonarrEpisodeId') - db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) - c = db.cursor() - provider = c.execute("SELECT * FROM table_settings_providers WHERE name = ?",(selected_provider,)).fetchone() - c.close() - providers_auth = {} - try: - if provider[2] is not '' and provider[3] is not '': - provider_auth = providers_auth.append(provider[0]) - provider_auth.update({'username':providers[2], 'password':providers[3]}) - else: - providers_auth = None - except: - providers_auth = None + providers_list = get_providers() + providers_auth = get_providers_auth() try: result = manual_download_subtitle(episodePath, language, hi, subtitle, selected_provider, providers_auth, sceneName, 'series') @@ -1597,28 +1547,8 @@ def get_subtitle_movie(): radarrId = request.forms.get('radarrId') # tmdbid = request.forms.get('tmdbid') - db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) - c = db.cursor() - c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1") - enabled_providers = c.fetchall() - c.close() - - providers_list = [] - providers_auth = {} - if len(enabled_providers) > 0: - for provider in enabled_providers: - providers_list.append(provider[0]) - try: - if provider[2] is not '' and provider[3] is not '': - provider_auth = providers_auth.append(provider[0]) - provider_auth.update({'username':providers[2], 'password':providers[3]}) - else: - providers_auth = None - except: - providers_auth = None - else: - providers_list = None - providers_auth = None + providers_list = get_providers() + providers_auth = get_providers_auth() try: result = download_subtitle(moviePath, language, hi, providers_list, providers_auth, sceneName, 'movie') @@ -1642,28 +1572,8 @@ def manual_search_movie_json(): language = request.forms.get('language') hi = request.forms.get('hi') - db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) - c = db.cursor() - c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1") - enabled_providers = c.fetchall() - c.close() - - providers_list = [] - providers_auth = {} - if len(enabled_providers) > 0: - for provider in enabled_providers: - providers_list.append(provider[0]) - try: - if provider[2] is not '' and provider[3] is not '': - provider_auth = providers_auth.append(provider[0]) - provider_auth.update({'username':providers[2], 'password':providers[3]}) - else: - providers_auth = None - except: - providers_auth = None - else: - providers_list = None - providers_auth = None + providers_list = get_providers() + providers_auth = get_providers_auth() data = manual_search(moviePath, language, hi, providers_list, providers_auth, sceneName, 'movie') return dict(data=data) @@ -1682,19 +1592,8 @@ def manual_get_subtitle_movie(): subtitle = request.forms.get('subtitle') radarrId = request.forms.get('radarrId') - db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) - c = db.cursor() - provider = c.execute("SELECT * FROM table_settings_providers WHERE name = ?",(selected_provider,)).fetchone() - c.close() - providers_auth = {} - try: - if provider[2] is not '' and provider[3] is not '': - provider_auth = providers_auth.append(provider[0]) - provider_auth.update({'username':providers[2], 'password':providers[3]}) - else: - providers_auth = None - except: - providers_auth = None + providers_list = get_providers() + providers_auth = get_providers_auth() try: result = manual_download_subtitle(moviePath, language, hi, subtitle, selected_provider, providers_auth, sceneName, 'movie') diff --git a/get_providers.py b/get_providers.py index 70ca2fba0..006f129b4 100644 --- a/get_providers.py +++ b/get_providers.py @@ -3,29 +3,65 @@ from get_argv import config_dir import sqlite3 import os from subliminal import provider_manager +import collections -# Get providers list from subliminal -providers_list = sorted(provider_manager.names()) +def load_providers(): + # Get providers list from subliminal + providers_list = sorted(provider_manager.names()) -# Open database connection -db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) -c = db.cursor() + # Open database connection + db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) + c = db.cursor() -# Remove unsupported providers -providers_in_db = c.execute('SELECT name FROM table_settings_providers').fetchall() -for provider_in_db in providers_in_db: - if provider_in_db[0] not in providers_list: - c.execute('DELETE FROM table_settings_providers WHERE name = ?', (provider_in_db[0], )) + # Remove unsupported providers + providers_in_db = c.execute('SELECT name FROM table_settings_providers').fetchall() + for provider_in_db in providers_in_db: + if provider_in_db[0] not in providers_list: + c.execute('DELETE FROM table_settings_providers WHERE name = ?', (provider_in_db[0], )) -# Commit changes to database table -db.commit() + # Commit changes to database table + db.commit() -# Insert providers in database table -for provider_name in providers_list: - c.execute('''INSERT OR IGNORE INTO table_settings_providers(name) VALUES(?)''', (provider_name, )) + # Insert providers in database table + for provider_name in providers_list: + c.execute('''INSERT OR IGNORE INTO table_settings_providers(name) VALUES(?)''', (provider_name, )) -# Commit changes to database table -db.commit() + # Commit changes to database table + db.commit() -# Close database connection -db.close() + # Close database connection + db.close() + + +def get_providers(): + db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) + c = db.cursor() + enabled_providers = c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1").fetchall() + c.close() + + providers_list = [] + if len(enabled_providers) > 0: + for provider in enabled_providers: + providers_list.append(provider[0]) + else: + providers_list = None + + return providers_list + + +def get_providers_auth(): + db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) + c = db.cursor() + enabled_providers = c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1 AND username is not NULL AND password is not NULL").fetchall() + c.close() + + providers_auth = collections.defaultdict(dict) + if len(enabled_providers) > 0: + for provider in enabled_providers: + providers_auth[provider[0]] = {} + providers_auth[provider[0]]['username'] = provider[2] + providers_auth[provider[0]]['password'] = provider[3] + else: + providers_auth = None + + return providers_auth \ No newline at end of file diff --git a/get_subtitle.py b/get_subtitle.py index b63e73236..de7af773a 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -17,6 +17,7 @@ from utils import history_log, history_log_movie from notifier import send_notifications, send_notifications_movie import cPickle as pickle import codecs +from get_providers import get_providers, get_providers_auth # configure the cache region.configure('dogpile.cache.memory') @@ -201,7 +202,7 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a else: try: best_subtitle = subtitle - download_subtitles([best_subtitle]) + download_subtitles([best_subtitle], providers=provider, provider_configs=providers_auth) except Exception as e: logging.exception('Error downloading subtitles for ' + path) return None @@ -265,25 +266,10 @@ def series_download_subtitles(no): c_db = conn_db.cursor() episodes_details = c_db.execute('SELECT path, missing_subtitles, sonarrEpisodeId, scene_name FROM table_episodes WHERE sonarrSeriesId = ? AND missing_subtitles != "[]"' + monitored_only_query_string, (no,)).fetchall() series_details = c_db.execute("SELECT hearing_impaired FROM table_shows WHERE sonarrSeriesId = ?", (no,)).fetchone() - enabled_providers = c_db.execute("SELECT * FROM table_settings_providers WHERE enabled = 1").fetchall() c_db.close() - providers_list = [] - providers_auth = {} - if len(enabled_providers) > 0: - for provider in enabled_providers: - providers_list.append(provider[0]) - try: - if provider[2] is not '' and provider[3] is not '': - provider_auth = providers_auth.append(provider[0]) - provider_auth.update({'username':providers[2], 'password':providers[3]}) - else: - providers_auth = None - except: - providers_auth = None - else: - providers_list = None - providers_auth = None + providers_list = get_providers() + providers_auth = get_providers_auth() for episode in episodes_details: for language in ast.literal_eval(episode[1]): @@ -300,25 +286,10 @@ def movies_download_subtitles(no): conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) c_db = conn_db.cursor() movie = c_db.execute("SELECT path, missing_subtitles, radarrId, sceneName, hearing_impaired FROM table_movies WHERE radarrId = ?", (no,)).fetchone() - enabled_providers = c_db.execute("SELECT * FROM table_settings_providers WHERE enabled = 1").fetchall() c_db.close() - providers_list = [] - providers_auth = {} - if len(enabled_providers) > 0: - for provider in enabled_providers: - providers_list.append(provider[0]) - try: - if provider[2] is not '' and provider[3] is not '': - provider_auth = providers_auth.append(provider[0]) - provider_auth.update({'username': providers[2], 'password': providers[3]}) - else: - providers_auth = None - except: - providers_auth = None - else: - providers_list = None - providers_auth = None + providers_list = get_providers() + providers_auth = get_providers_auth() for language in ast.literal_eval(movie[1]): if language is not None: @@ -334,25 +305,10 @@ def wanted_download_subtitles(path): conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) c_db = conn_db.cursor() episodes_details = c_db.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, table_episodes.sonarrEpisodeId, table_episodes.sonarrSeriesId, table_shows.hearing_impaired, table_episodes.scene_name, table_episodes.failedAttempts FROM table_episodes INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE table_episodes.path = ? AND missing_subtitles != '[]'", (path_replace_reverse(path),)).fetchall() - enabled_providers = c_db.execute("SELECT * FROM table_settings_providers WHERE enabled = 1").fetchall() c_db.close() - providers_list = [] - providers_auth = {} - if len(enabled_providers) > 0: - for provider in enabled_providers: - providers_list.append(provider[0]) - try: - if provider[2] is not '' and provider[3] is not '': - provider_auth = providers_auth.append(provider[0]) - provider_auth.update({'username':providers[2], 'password':providers[3]}) - else: - providers_auth = None - except: - providers_auth = None - else: - providers_list = None - providers_auth = None + providers_list = get_providers() + providers_auth = get_providers_auth() for episode in episodes_details: attempt = episode[6] @@ -390,25 +346,10 @@ def wanted_download_subtitles_movie(path): conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) c_db = conn_db.cursor() movies_details = c_db.execute("SELECT path, missing_subtitles, radarrId, radarrId, hearing_impaired, sceneName, failedAttempts FROM table_movies WHERE path = ? AND missing_subtitles != '[]'", (path_replace_reverse_movie(path),)).fetchall() - enabled_providers = c_db.execute("SELECT * FROM table_settings_providers WHERE enabled = 1").fetchall() c_db.close() - providers_list = [] - providers_auth = {} - if len(enabled_providers) > 0: - for provider in enabled_providers: - providers_list.append(provider[0]) - try: - if provider[2] is not '' and provider[3] is not '': - provider_auth = providers_auth.append(provider[0]) - provider_auth.update({'username': providers[2], 'password': providers[3]}) - else: - providers_auth = None - except: - providers_auth = None - else: - providers_list = None - providers_auth = None + providers_list = get_providers() + providers_auth = get_providers_auth() for movie in movies_details: attempt = movie[6] From 8d13e5b5481dfd645aea7dab738ed6dd859bd4df Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Sat, 22 Sep 2018 18:10:35 -0400 Subject: [PATCH 06/26] Version bump --- bazarr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazarr.py b/bazarr.py index aa5558104..7131a976d 100644 --- a/bazarr.py +++ b/bazarr.py @@ -1,4 +1,4 @@ -bazarr_version = '0.6.4' +bazarr_version = '0.6.5' import gc gc.enable() From f405687d506f4e60bc9d859500801c88bc1dec03 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Sun, 23 Sep 2018 10:47:55 -0400 Subject: [PATCH 07/26] Fix for missing movieFile key returned by Radarr API --- get_movies.py | 77 ++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/get_movies.py b/get_movies.py index c9488f85c..4e546413e 100644 --- a/get_movies.py +++ b/get_movies.py @@ -48,48 +48,49 @@ def update_movies(): for movie in r.json(): if movie['hasFile'] is True: - try: - overview = unicode(movie['overview']) - except: - overview = "" - try: - poster_big = movie['images'][0]['url'] - poster = os.path.splitext(poster_big)[0] + '-500' + os.path.splitext(poster_big)[1] - except: - poster = "" - try: - fanart = movie['images'][1]['url'] - except: - fanart = "" - if 'movieFile' in movie: - if 'sceneName' in movie['movieFile']: - sceneName = movie['movieFile']['sceneName'] + try: + overview = unicode(movie['overview']) + except: + overview = "" + try: + poster_big = movie['images'][0]['url'] + poster = os.path.splitext(poster_big)[0] + '-500' + os.path.splitext(poster_big)[1] + except: + poster = "" + try: + fanart = movie['images'][1]['url'] + except: + fanart = "" + + if 'movieFile' in movie: + if 'sceneName' in movie['movieFile']: + sceneName = movie['movieFile']['sceneName'] + else: + sceneName = None else: sceneName = None - else: - sceneName = None - - # Add movies in radarr to current movies list - current_movies_radarr.append(unicode(movie['tmdbId'])) - - # Detect file separator - if movie['path'][0] == "/": - separator = "/" - else: - separator = "\\" - - # Update or insert movies list in database table - try: - if movie_default_enabled is True: - c.execute('''INSERT INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored) VALUES (?,?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?)''', (movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie_default_language, '[]', movie_default_hi, movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored'])))) - else: - c.execute('''INSERT INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored) VALUES (?,?,?,(SELECT languages FROM table_movies WHERE tmdbId = ?), '[]',(SELECT `hearing_impaired` FROM table_movies WHERE tmdbId = ?), ?, ?, ?, ?, ?, ?, ?)''', (movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie["tmdbId"], movie["tmdbId"], movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored'])))) - except: - c.execute('''UPDATE table_movies SET title = ?, path = ?, tmdbId = ?, radarrId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ?, sceneName = ?, monitored = ? WHERE tmdbid = ?''', (movie["title"],movie["path"] + separator + movie['movieFile']['relativePath'],movie["tmdbId"],movie["id"],overview,poster,fanart,profile_id_to_language(movie['qualityProfileId']),sceneName,unicode(bool(movie['monitored'])),movie["tmdbId"])) - # Commit changes to database table - db.commit() + # Add movies in radarr to current movies list + current_movies_radarr.append(unicode(movie['tmdbId'])) + + # Detect file separator + if movie['path'][0] == "/": + separator = "/" + else: + separator = "\\" + + # Update or insert movies list in database table + try: + if movie_default_enabled is True: + c.execute('''INSERT INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored) VALUES (?,?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?)''', (movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie_default_language, '[]', movie_default_hi, movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored'])))) + else: + c.execute('''INSERT INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored) VALUES (?,?,?,(SELECT languages FROM table_movies WHERE tmdbId = ?), '[]',(SELECT `hearing_impaired` FROM table_movies WHERE tmdbId = ?), ?, ?, ?, ?, ?, ?, ?)''', (movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie["tmdbId"], movie["tmdbId"], movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored'])))) + except: + c.execute('''UPDATE table_movies SET title = ?, path = ?, tmdbId = ?, radarrId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ?, sceneName = ?, monitored = ? WHERE tmdbid = ?''', (movie["title"],movie["path"] + separator + movie['movieFile']['relativePath'],movie["tmdbId"],movie["id"],overview,poster,fanart,profile_id_to_language(movie['qualityProfileId']),sceneName,unicode(bool(movie['monitored'])),movie["tmdbId"])) + + # Commit changes to database table + db.commit() # Delete movies not in radarr anymore added_movies = list(set(current_movies_radarr) - set(current_movies_db_list)) From 0f2371423d01502f164ad8769bb0643c3bb3130d Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 24 Sep 2018 18:04:33 -0400 Subject: [PATCH 08/26] Fix for search bar still mentionning series even if you're in movies --- views/menu.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/menu.tpl b/views/menu.tpl index c908cff36..210690ef3 100644 --- a/views/menu.tpl +++ b/views/menu.tpl @@ -101,7 +101,7 @@
From e6a44bcbd69657440509e6690be2666389c3ef9d Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 24 Sep 2018 22:22:27 -0400 Subject: [PATCH 09/26] Major improvement to episodes synchronization --- get_episodes.py | 52 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/get_episodes.py b/get_episodes.py index e1a458d5d..ac873db64 100644 --- a/get_episodes.py +++ b/get_episodes.py @@ -31,11 +31,19 @@ def sync_episodes(): c = db.cursor() # Get current episodes id in DB - current_episodes_db = c.execute('SELECT sonarrSeriesId, sonarrEpisodeId, title, path, season, episode, scene_name, monitored FROM table_episodes').fetchall() + current_episodes_db = c.execute('SELECT sonarrEpisodeId FROM table_episodes').fetchall() - # Get sonarrId for each series from database + current_episodes_db_list = [x[0] for x in current_episodes_db] current_episodes_sonarr = [] + episodes_to_update = [] + episodes_to_add = [] + + # Get sonarrId for each series from database seriesIdList = c.execute("SELECT sonarrSeriesId FROM table_shows").fetchall() + + # Close database connection + c.close() + for seriesId in seriesIdList: # Get episodes data for a series from Sonarr url_sonarr_api_episode = url_sonarr + "/api/episode?seriesId=" + str(seriesId[0]) + "&apikey=" + apikey_sonarr @@ -61,27 +69,41 @@ def sync_episodes(): sceneName = episode['episodeFile']['sceneName'] else: sceneName = None - current_episodes_sonarr.append((episode['seriesId'], episode['id'], episode['title'], episode['episodeFile']['path'], episode['seasonNumber'], episode['episodeNumber'], sceneName, str(bool(episode['monitored'])))) - added_episodes = list(set(current_episodes_sonarr) - set(current_episodes_db)) - removed_episodes = list(set(current_episodes_db) - set(current_episodes_sonarr)) + # Add episodes in sonarr to current episode list + current_episodes_sonarr.append(episode['id']) - for removed_episode in removed_episodes: - c.execute('DELETE FROM table_episodes WHERE sonarrEpisodeId = ?', (removed_episode[1],)) + if episode['id'] in current_episodes_db_list: + episodes_to_update.append((episode['title'], episode['episodeFile']['path'], episode['seasonNumber'], episode['episodeNumber'], sceneName, str(bool(episode['monitored'])), episode['id'])) + else: + episodes_to_add.append((episode['seriesId'], episode['id'], episode['title'], episode['episodeFile']['path'], episode['seasonNumber'], episode['episodeNumber'], sceneName, str(bool(episode['monitored'])))) + + removed_episodes = list(set(current_episodes_db_list) - set(current_episodes_sonarr)) + + # Update or insert movies in DB + db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) + c = db.cursor() + + updated_result = c.executemany('''UPDATE table_episodes SET title = ?, path = ?, season = ?, episode = ?, scene_name = ?, monitored = ? WHERE sonarrEpisodeId = ?''', episodes_to_update) + db.commit() + + try: + added_result = c.executemany('''INSERT INTO table_episodes(sonarrSeriesId, sonarrEpisodeId, title, path, season, episode, scene_name, monitored) VALUES (?, ?, ?, ?, ?, ?, ?, ?)''', episodes_to_add) + except sqlite3.IntegrityError as e: + logging.exception("You're probably an early adopter of Bazarr and this is a known issue. Please open an issue on Github and we'll fix this.") + else: db.commit() - for added_episode in added_episodes: - try: - c.execute('''INSERT INTO table_episodes(sonarrSeriesId, sonarrEpisodeId, title, path, season, episode, scene_name, monitored) VALUES (?, ?, ?, ?, ?, ?, ?, ?)''', added_episode) - except sqlite3.IntegrityError as e: - logging.exception("You're probably an early adopter of Bazarr and this is a known issue. Please open an issue on Github and we'll fix this.") - else: - db.commit() - store_subtitles(path_replace(added_episode[3])) + for removed_episode in removed_episodes: + c.execute('DELETE FROM table_episodes WHERE sonarrEpisodeId = ?', (removed_episode,)) + db.commit() # Close database connection c.close() + for added_episode in episodes_to_add: + store_subtitles(path_replace(added_episode[3])) + logging.debug('All episodes synced from Sonarr into database.') list_missing_subtitles() From 6156a99ef97452b5f43af2e5f2f42c041f8f2a71 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 24 Sep 2018 22:22:54 -0400 Subject: [PATCH 10/26] Major improvement to series synchronization --- get_series.py | 52 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/get_series.py b/get_series.py index a47bb42c9..a0bca2b4e 100644 --- a/get_series.py +++ b/get_series.py @@ -16,10 +16,6 @@ def update_series(): serie_default_language = get_general_settings()[16] serie_default_hi = get_general_settings()[17] - # Open database connection - db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) - c = db.cursor() - if apikey_sonarr == None: pass else: @@ -39,10 +35,20 @@ def update_series(): except requests.exceptions.RequestException as err: logging.exception("Error trying to get series from Sonarr.") else: + # Open database connection + db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) + c = db.cursor() + # Get current shows in DB current_shows_db = c.execute('SELECT tvdbId FROM table_shows').fetchall() + + # Close database connection + db.close() + current_shows_db_list = [x[0] for x in current_shows_db] current_shows_sonarr = [] + series_to_update = [] + series_to_add = [] for show in r.json(): try: @@ -62,28 +68,42 @@ def update_series(): # Add shows in Sonarr to current shows list current_shows_sonarr.append(show['tvdbId']) - # Update or insert shows list in database table - try: + if show['tvdbId'] in current_shows_db_list: + series_to_update.append((show["title"],show["path"],show["tvdbId"],show["id"],overview,poster,fanart,profile_id_to_language((show['qualityProfileId'] if sonarr_version == 2 else show['languageProfileId'])),show['sortTitle'],show["tvdbId"])) + else: if serie_default_enabled is True: - c.execute('''INSERT INTO table_shows(title, path, tvdbId, languages,`hearing_impaired`, sonarrSeriesId, overview, poster, fanart, `audio_language`, sortTitle) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''', (show["title"], show["path"], show["tvdbId"], serie_default_language, serie_default_hi, show["id"], overview, poster, fanart, profile_id_to_language(show['qualityProfileId']), show['sortTitle'])) - list_missing_subtitles(show["id"]) + series_to_add.append((show["title"], show["path"], show["tvdbId"], serie_default_language, serie_default_hi, show["id"], overview, poster, fanart, profile_id_to_language(show['qualityProfileId']), show['sortTitle'])) else: - c.execute('''INSERT INTO table_shows(title, path, tvdbId, languages,`hearing_impaired`, sonarrSeriesId, overview, poster, fanart, `audio_language`, sortTitle) VALUES (?,?,?,(SELECT languages FROM table_shows WHERE tvdbId = ?),(SELECT `hearing_impaired` FROM table_shows WHERE tvdbId = ?), ?, ?, ?, ?, ?, ?)''', (show["title"], show["path"], show["tvdbId"], show["tvdbId"], show["tvdbId"], show["id"], overview, poster, fanart, profile_id_to_language(show['qualityProfileId']), show['sortTitle'])) - except: - c.execute('''UPDATE table_shows SET title = ?, path = ?, tvdbId = ?, sonarrSeriesId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ? , sortTitle = ? WHERE tvdbid = ?''', (show["title"],show["path"],show["tvdbId"],show["id"],overview,poster,fanart,profile_id_to_language((show['qualityProfileId'] if sonarr_version == 2 else show['languageProfileId'])),show['sortTitle'],show["tvdbId"])) + series_to_add.append((show["title"], show["path"], show["tvdbId"], show["tvdbId"], show["tvdbId"], show["id"], overview, poster, fanart, profile_id_to_language(show['qualityProfileId']), show['sortTitle'])) + + # Update or insert series in DB + db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) + c = db.cursor() + + updated_result = c.executemany('''UPDATE table_shows SET title = ?, path = ?, tvdbId = ?, sonarrSeriesId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ? , sortTitle = ? WHERE tvdbid = ?''', series_to_update) + db.commit() + + if serie_default_enabled is True: + added_result = c.executemany('''INSERT INTO table_shows(title, path, tvdbId, languages,`hearing_impaired`, sonarrSeriesId, overview, poster, fanart, `audio_language`, sortTitle) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''', series_to_add) + db.commit() + else: + added_result = c.executemany('''INSERT INTO table_shows(title, path, tvdbId, languages,`hearing_impaired`, sonarrSeriesId, overview, poster, fanart, `audio_language`, sortTitle) VALUES (?,?,?,(SELECT languages FROM table_shows WHERE tvdbId = ?),(SELECT `hearing_impaired` FROM table_shows WHERE tvdbId = ?), ?, ?, ?, ?, ?, ?)''', series_to_add) + db.commit() + db.close() + + for show in series_to_add: + list_missing_subtitles(show[5]) # Delete shows not in Sonarr anymore deleted_items = [] for item in current_shows_db_list: if item not in current_shows_sonarr: deleted_items.append(tuple([item])) + db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) + c = db.cursor() c.executemany('DELETE FROM table_shows WHERE tvdbId = ?',deleted_items) - - # Commit changes to database table db.commit() - - # Close database connection - db.close() + db.close() def get_profile_list(): from get_settings import get_sonarr_settings From f1d12ff8edaa7e942340b9d24e41011689ecfa77 Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 24 Sep 2018 22:23:47 -0400 Subject: [PATCH 11/26] Major improvement to movies synchronization --- get_movies.py | 60 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/get_movies.py b/get_movies.py index 4e546413e..ef151dd50 100644 --- a/get_movies.py +++ b/get_movies.py @@ -12,16 +12,11 @@ def update_movies(): logging.debug('Starting movie sync from Radarr.') from get_settings import get_radarr_settings url_radarr = get_radarr_settings()[6] - # url_radarr_short = get_radarr_settings()[7] apikey_radarr = get_radarr_settings()[4] movie_default_enabled = get_general_settings()[18] movie_default_language = get_general_settings()[19] movie_default_hi = get_general_settings()[20] - # Open database connection - db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) - c = db.cursor() - if apikey_radarr == None: pass else: @@ -42,9 +37,15 @@ def update_movies(): logging.exception("Error trying to get movies from Radarr.") else: # Get current movies in DB + db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) + c = db.cursor() current_movies_db = c.execute('SELECT tmdbId FROM table_movies').fetchall() + db.close() + current_movies_db_list = [x[0] for x in current_movies_db] current_movies_radarr = [] + movies_to_update = [] + movies_to_add = [] for movie in r.json(): if movie['hasFile'] is True: @@ -63,11 +64,8 @@ def update_movies(): except: fanart = "" - if 'movieFile' in movie: - if 'sceneName' in movie['movieFile']: - sceneName = movie['movieFile']['sceneName'] - else: - sceneName = None + if 'sceneName' in movie['movieFile']: + sceneName = movie['movieFile']['sceneName'] else: sceneName = None @@ -80,32 +78,44 @@ def update_movies(): else: separator = "\\" - # Update or insert movies list in database table - try: + if unicode(movie['tmdbId']) in current_movies_db_list: + movies_to_update.append((movie["title"],movie["path"] + separator + movie['movieFile']['relativePath'],movie["tmdbId"],movie["id"],overview,poster,fanart,profile_id_to_language(movie['qualityProfileId']),sceneName,unicode(bool(movie['monitored'])),movie["tmdbId"])) + else: if movie_default_enabled is True: - c.execute('''INSERT INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored) VALUES (?,?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?)''', (movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie_default_language, '[]', movie_default_hi, movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored'])))) + movies_to_add.append((movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie_default_language, '[]', movie_default_hi, movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored'])))) else: - c.execute('''INSERT INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored) VALUES (?,?,?,(SELECT languages FROM table_movies WHERE tmdbId = ?), '[]',(SELECT `hearing_impaired` FROM table_movies WHERE tmdbId = ?), ?, ?, ?, ?, ?, ?, ?)''', (movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie["tmdbId"], movie["tmdbId"], movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored'])))) - except: - c.execute('''UPDATE table_movies SET title = ?, path = ?, tmdbId = ?, radarrId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ?, sceneName = ?, monitored = ? WHERE tmdbid = ?''', (movie["title"],movie["path"] + separator + movie['movieFile']['relativePath'],movie["tmdbId"],movie["id"],overview,poster,fanart,profile_id_to_language(movie['qualityProfileId']),sceneName,unicode(bool(movie['monitored'])),movie["tmdbId"])) + movies_to_add.append((movie["title"], movie["path"] + separator + movie['movieFile']['relativePath'], movie["tmdbId"], movie["tmdbId"], movie["tmdbId"], movie["id"], overview, poster, fanart, profile_id_to_language(movie['qualityProfileId']), sceneName, unicode(bool(movie['monitored'])))) - # Commit changes to database table - db.commit() + # Update or insert movies in DB + db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) + c = db.cursor() + + updated_result = c.executemany('''UPDATE table_movies SET title = ?, path = ?, tmdbId = ?, radarrId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ?, sceneName = ?, monitored = ? WHERE tmdbid = ?''', movies_to_update) + db.commit() + + if movie_default_enabled is True: + added_result = c.executemany('''INSERT INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored) VALUES (?,?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?)''', movies_to_add) + db.commit() + else: + added_result = c.executemany('''INSERT INTO table_movies(title, path, tmdbId, languages, subtitles,`hearing_impaired`, radarrId, overview, poster, fanart, `audio_language`, sceneName, monitored) VALUES (?,?,?,(SELECT languages FROM table_movies WHERE tmdbId = ?), '[]',(SELECT `hearing_impaired` FROM table_movies WHERE tmdbId = ?), ?, ?, ?, ?, ?, ?, ?)''', movies_to_add) + db.commit() + db.close() - # Delete movies not in radarr anymore added_movies = list(set(current_movies_radarr) - set(current_movies_db_list)) removed_movies = list(set(current_movies_db_list) - set(current_movies_radarr)) - for removed_movie in removed_movies: - c.execute('DELETE FROM table_movies WHERE tmdbId = ?', (removed_movie,)) - db.commit() + db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) + c = db.cursor() + c.executemany('DELETE FROM table_movies WHERE tmdbId = ?', removed_movies) + db.commit() + db.close() + db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) + c = db.cursor() for added_movie in added_movies: added_path = c.execute('SELECT path FROM table_movies WHERE tmdbId = ?', (added_movie,)).fetchone() store_subtitles_movie(path_replace_movie(added_path[0])) - - # Close database connection - db.close() + db.close() logging.debug('All movies synced from Radarr into database.') From e4d7b83f38f64eac739f0f0336592e59a6cd8162 Mon Sep 17 00:00:00 2001 From: Halali Date: Tue, 25 Sep 2018 13:58:23 +0200 Subject: [PATCH 12/26] fix for scheduler --- scheduler.py | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/scheduler.py b/scheduler.py index 333b3c268..8e894c194 100644 --- a/scheduler.py +++ b/scheduler.py @@ -20,22 +20,37 @@ integration = get_general_settings() def sonarr_full_update(): - full_update = get_sonarr_settings()[5] - if full_update == "Daily": - scheduler.add_job(update_all_episodes, CronTrigger(hour=4), max_instances=1, coalesce=True, misfire_grace_time=15, id='update_all_episodes', name='Update all episodes subtitles from disk', replace_existing=True) - elif full_update == "Weekly": - scheduler.add_job(update_all_episodes, CronTrigger(day_of_week='sun'), hour=4, max_instances=1, coalesce=True, misfire_grace_time=15, id='update_all_episodes', name='Update all episodes subtitles from disk', replace_existing=True) - elif full_update == "Manually": - scheduler.add_job(update_all_episodes, CronTrigger(year='2100'), hour=4, max_instances=1, coalesce=True, misfire_grace_time=15, id='update_all_episodes', name='Update all episodes subtitles from disk', replace_existing=True) + if integration[12] is True: + full_update = get_sonarr_settings()[5] + if full_update == "Daily": + scheduler.add_job(update_all_episodes, CronTrigger(hour=4), max_instances=1, coalesce=True, + misfire_grace_time=15, id='update_all_episodes', + name='Update all episodes subtitles from disk', replace_existing=True) + elif full_update == "Weekly": + scheduler.add_job(update_all_episodes, CronTrigger(day_of_week='sun'), hour=4, max_instances=1, coalesce=True, + misfire_grace_time=15, id='update_all_episodes', + name='Update all episodes subtitles from disk', replace_existing=True) + elif full_update == "Manually": + scheduler.add_job(update_all_episodes, CronTrigger(year='2100'), hour=4, max_instances=1, coalesce=True, + misfire_grace_time=15, id='update_all_episodes', + name='Update all episodes subtitles from disk', replace_existing=True) + def radarr_full_update(): - full_update = get_radarr_settings()[5] - if full_update == "Daily": - scheduler.add_job(update_all_movies, CronTrigger(hour=5), max_instances=1, coalesce=True, misfire_grace_time=15, id='update_all_movies', name='Update all movies subtitles from disk', replace_existing=True) - elif full_update == "Weekly": - scheduler.add_job(update_all_movies, CronTrigger(day_of_week='sun'), hour=5, max_instances=1, coalesce=True, misfire_grace_time=15, id='update_all_movies', name='Update all movies subtitles from disk', replace_existing=True) - elif full_update == "Manually": - scheduler.add_job(update_all_movies, CronTrigger(year='2100'), hour=5, max_instances=1, coalesce=True, misfire_grace_time=15, id='update_all_movies', name='Update all movies subtitles from disk', replace_existing=True) + if integration[13] is True: + full_update = get_radarr_settings()[5] + if full_update == "Daily": + scheduler.add_job(update_all_movies, CronTrigger(hour=5), max_instances=1, coalesce=True, misfire_grace_time=15, + id='update_all_movies', name='Update all movies subtitles from disk', replace_existing=True) + elif full_update == "Weekly": + scheduler.add_job(update_all_movies, CronTrigger(day_of_week='sun'), hour=5, max_instances=1, coalesce=True, + misfire_grace_time=15, id='update_all_movies', name='Update all movies subtitles from disk', + replace_existing=True) + elif full_update == "Manually": + scheduler.add_job(update_all_movies, CronTrigger(year='2100'), hour=5, max_instances=1, coalesce=True, + misfire_grace_time=15, id='update_all_movies', name='Update all movies subtitles from disk', + replace_existing=True) + def execute_now(taskid): scheduler.modify_job(taskid, next_run_time=datetime.now()) From c774ef8a16f093fa896abeafbfbf3bb7c2a3ca8a Mon Sep 17 00:00:00 2001 From: Halali Date: Wed, 26 Sep 2018 11:06:17 +0200 Subject: [PATCH 13/26] fix for bad showing monitored status --- views/episodes.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/episodes.tpl b/views/episodes.tpl index 5586c31cc..f3ec5d422 100644 --- a/views/episodes.tpl +++ b/views/episodes.tpl @@ -175,7 +175,7 @@ %for episode in season: - %if episode[9] is True: + %if episode[9] == 'True': %else: From fd7cd0a92caf1e77c0d5e73038ac40c919fb25b1 Mon Sep 17 00:00:00 2001 From: Halali Date: Wed, 26 Sep 2018 12:35:46 +0200 Subject: [PATCH 14/26] Fix for #84 --- views/episodes.tpl | 3 +-- views/movie.tpl | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/views/episodes.tpl b/views/episodes.tpl index f3ec5d422..155d6f632 100644 --- a/views/episodes.tpl +++ b/views/episodes.tpl @@ -31,8 +31,7 @@ background-position:center center; } #divdetails { - background-color: #000000; - opacity: 0.9; + background-color: rgba(0, 0, 0, 0.9); color: #ffffff; margin-top: 6em; margin-bottom: 3em; diff --git a/views/movie.tpl b/views/movie.tpl index 984558fb0..861ca3565 100644 --- a/views/movie.tpl +++ b/views/movie.tpl @@ -30,8 +30,7 @@ background-position:center center; } #divdetails { - background-color: #000000; - opacity: 0.9; + background-color: rgba(0, 0, 0, 0.9); color: #ffffff; margin-top: 6em; margin-bottom: 3em; @@ -109,7 +108,7 @@

- %if details[13] is True: + %if details[13] == 'True': %else: From bfdc6200b7794d225ff6610ef6a262e5966ba012 Mon Sep 17 00:00:00 2001 From: Halali Date: Wed, 26 Sep 2018 14:31:47 +0200 Subject: [PATCH 15/26] minor search engine changes --- bazarr.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/bazarr.py b/bazarr.py index 7131a976d..b6b7b4996 100644 --- a/bazarr.py +++ b/bazarr.py @@ -313,26 +313,29 @@ def serieseditor(): output = template('serieseditor', __file__=__file__, bazarr_version=bazarr_version, rows=data, languages=languages, missing_count=missing_count, base_url=base_url, single_language=single_language) return output + @route(base_url + 'search_json/', method='GET') @custom_auth_basic(check_credentials) def search_json(query): authorize() db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30) c = db.cursor() - - c.execute("SELECT title, sonarrSeriesId FROM table_shows WHERE title LIKE ? ORDER BY title", ('%'+query+'%',)) - series = c.fetchall() - - c.execute("SELECT title, radarrId FROM table_movies WHERE title LIKE ? ORDER BY title", ('%' + query + '%',)) - movies = c.fetchall() - + search_list = [] - for serie in series: - search_list.append(dict([('name', serie[0]), ('url', base_url + 'episodes/' + str(serie[1]))])) - - for movie in movies: - search_list.append(dict([('name', movie[0]), ('url', base_url + 'movie/' + str(movie[1]))])) - + if get_general_settings()[12] is True: + c.execute("SELECT title, sonarrSeriesId FROM table_shows WHERE title LIKE ? ORDER BY title", + ('%' + query + '%',)) + series = c.fetchall() + for serie in series: + search_list.append(dict([('name', serie[0]), ('url', base_url + 'episodes/' + str(serie[1]))])) + + if get_general_settings()[13] is True: + c.execute("SELECT title, radarrId FROM table_movies WHERE title LIKE ? ORDER BY title", ('%' + query + '%',)) + movies = c.fetchall() + for movie in movies: + search_list.append(dict([('name', movie[0]), ('url', base_url + 'movie/' + str(movie[1]))])) + c.close() + response.content_type = 'application/json' return dict(items=search_list) From 6be749d0180f484199a66e2602b290014b954da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 26 Sep 2018 15:13:02 -0400 Subject: [PATCH 16/26] Fix for UI bug in histories statistic --- views/historymovies.tpl | 1 - views/historyseries.tpl | 1 - 2 files changed, 2 deletions(-) diff --git a/views/historymovies.tpl b/views/historymovies.tpl index 86b9fb161..c6ec0fa1a 100644 --- a/views/historymovies.tpl +++ b/views/historymovies.tpl @@ -38,7 +38,6 @@ background-color: #333333; box-shadow: 0 0 10px 1px #333; padding: 10px; - margin-bottom: -2em !important; } .label, .value { color: white !important; diff --git a/views/historyseries.tpl b/views/historyseries.tpl index e14a3c415..85bdd5f6a 100644 --- a/views/historyseries.tpl +++ b/views/historyseries.tpl @@ -38,7 +38,6 @@ background-color: #333333; box-shadow: 0 0 10px 1px #333; padding: 10px; - margin-bottom: -2em !important; } .label, .value { color: white !important; From f7ef9495c8fe585cea19ab0dd6b362268701d7b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 27 Sep 2018 11:50:48 -0400 Subject: [PATCH 17/26] Partial fix for #84 --- views/menu.tpl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/views/menu.tpl b/views/menu.tpl index 210690ef3..c55dd1f6a 100644 --- a/views/menu.tpl +++ b/views/menu.tpl @@ -113,18 +113,18 @@ - - % restart_required = c.execute("SELECT configured, updated FROM system").fetchone() - % c.close() + % restart_required = c.execute("SELECT configured, updated FROM system").fetchone() + % c.close() - % if restart_required[1] == '1' and restart_required[0] == '1': -
Bazarr need to be restarted to apply last update and changes to general settings.
- % elif restart_required[1] == '1': -
Bazarr need to be restarted to apply last update.
- % elif restart_required[0] == '1': -
Bazarr need to be restarted to apply changes to general settings.
- % end + % if restart_required[1] == '1' and restart_required[0] == '1': +
Bazarr need to be restarted to apply last update and changes to general settings.
+ % elif restart_required[1] == '1': +
Bazarr need to be restarted to apply last update.
+ % elif restart_required[0] == '1': +
Bazarr need to be restarted to apply changes to general settings.
+ % end + From 1092733b5e8e59cba0b60bdb21344445fa4976f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Thu, 27 Sep 2018 15:06:34 -0400 Subject: [PATCH 18/26] Fix for POB in manual search --- get_subtitle.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/get_subtitle.py b/get_subtitle.py index de7af773a..d7bcd6d55 100644 --- a/get_subtitle.py +++ b/get_subtitle.py @@ -124,7 +124,7 @@ def manual_search(path, language, hi, providers, providers_auth, sceneName, medi hi = False language_set = set() for lang in ast.literal_eval(language): - if lang == 'pob': + if lang == 'pb': language_set.add(Language('por', 'BR')) else: language_set.add(Language(alpha3_from_alpha2(lang))) @@ -183,7 +183,8 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a use_postprocessing = get_general_settings()[10] postprocessing_cmd = get_general_settings()[11] - if language == 'pob': + if language == 'pb': + language = alpha3_from_alpha2(language) lang_obj = Language('por', 'BR') else: language = alpha3_from_alpha2(language) From 34451891157c2f3384f5bc86e646b304b82b63c1 Mon Sep 17 00:00:00 2001 From: Halali Date: Fri, 28 Sep 2018 16:40:36 +0200 Subject: [PATCH 19/26] Final fix for #84 --- views/menu.tpl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/views/menu.tpl b/views/menu.tpl index c55dd1f6a..cac881bb7 100644 --- a/views/menu.tpl +++ b/views/menu.tpl @@ -152,7 +152,17 @@ if (window.location.href.indexOf("episodes") > -1) { $('.menu').css('background', '#000000'); + $('.menu').css('opacity', '0.8'); $('#divmenu').css('background', '#000000'); + $('#divmenu').css('opacity', '0.8'); + $('#divmenu').css('box-shadow', '0px 0px 5px 5px #000000'); + } + else if (window.location.href.indexOf("movie/") > -1) { + $('.menu').css('background', '#000000'); + $('.menu').css('opacity', '0.8'); + $('#divmenu').css('background', '#000000'); + $('#divmenu').css('opacity', '0.8'); + $('#divmenu').css('box-shadow', '0px 0px 5px 5px #000000'); } else { $('.menu').css('background', '#272727'); From 3e15b55e16a3af5bc296207261f51370dca09bf9 Mon Sep 17 00:00:00 2001 From: Halali Date: Fri, 28 Sep 2018 17:46:34 +0200 Subject: [PATCH 20/26] Final fix for #84 --- views/menu.tpl | 1 - 1 file changed, 1 deletion(-) diff --git a/views/menu.tpl b/views/menu.tpl index cac881bb7..9c98a29e8 100644 --- a/views/menu.tpl +++ b/views/menu.tpl @@ -4,7 +4,6 @@