From eeba43e4928d2621b8d81df5da2ac3b12b314151 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Mon, 1 Apr 2019 22:34:03 -0400
Subject: [PATCH] Continuing development.
---
bazarr/get_subtitle.py | 25 ++++++++++++++++++++++++-
bazarr/list_subtitles.py | 10 ++++++++--
views/episodes.tpl | 10 +++++-----
views/movie.tpl | 18 ++++++++++++------
4 files changed, 49 insertions(+), 14 deletions(-)
diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py
index 39565e9d9..39af5ca66 100644
--- a/bazarr/get_subtitle.py
+++ b/bazarr/get_subtitle.py
@@ -119,14 +119,26 @@ def download_subtitle(path, language, hi, forced, providers, providers_auth, sce
lang_obj = Language('por', 'BR')
if forced == "True":
lang_obj.forced = True
+ providers_auth['podnapisi']['only_foreign'] = True
+ providers_auth['subscene']['only_foreign'] = True
+ providers_auth['opensubtitles']['only_foreign'] = True
else:
lang_obj.forced = False
+ providers_auth['podnapisi']['only_foreign'] = False
+ providers_auth['subscene']['only_foreign'] = False
+ providers_auth['opensubtitles']['only_foreign'] = False
else:
lang_obj = Language(l)
if forced == "True":
lang_obj.forced = True
+ providers_auth['podnapisi']['only_foreign'] = True
+ providers_auth['subscene']['only_foreign'] = True
+ providers_auth['opensubtitles']['only_foreign'] = True
else:
lang_obj.forced = False
+ providers_auth['podnapisi']['only_foreign'] = False
+ providers_auth['subscene']['only_foreign'] = False
+ providers_auth['opensubtitles']['only_foreign'] = False
language_set.add(lang_obj)
use_scenename = settings.general.getboolean('use_scenename')
@@ -273,14 +285,26 @@ def manual_search(path, language, hi, forced, providers, providers_auth, sceneNa
lang_obj = Language('por', 'BR')
if forced == "True":
lang_obj.forced = True
+ providers_auth['podnapisi']['only_foreign'] = True
+ providers_auth['subscene']['only_foreign'] = True
+ providers_auth['opensubtitles']['only_foreign'] = True
else:
lang_obj.forced = False
+ providers_auth['podnapisi']['only_foreign'] = False
+ providers_auth['subscene']['only_foreign'] = False
+ providers_auth['opensubtitles']['only_foreign'] = False
else:
lang_obj = Language(lang)
if forced == "True":
lang_obj.forced = True
+ providers_auth['podnapisi']['only_foreign'] = True
+ providers_auth['subscene']['only_foreign'] = True
+ providers_auth['opensubtitles']['only_foreign'] = True
else:
lang_obj.forced = False
+ providers_auth['podnapisi']['only_foreign'] = False
+ providers_auth['subscene']['only_foreign'] = False
+ providers_auth['opensubtitles']['only_foreign'] = False
language_set.add(lang_obj)
use_scenename = settings.general.getboolean('use_scenename')
@@ -301,7 +325,6 @@ def manual_search(path, language, hi, forced, providers, providers_auth, sceneNa
provider_configs=providers_auth,
throttle_callback=provider_throttle,
language_hook=None) # fixme
- print subtitles
else:
subtitles = []
logging.info("BAZARR All providers are throttled")
diff --git a/bazarr/list_subtitles.py b/bazarr/list_subtitles.py
index 01cd5f3b5..3589dfb4a 100644
--- a/bazarr/list_subtitles.py
+++ b/bazarr/list_subtitles.py
@@ -215,7 +215,7 @@ def list_missing_subtitles(*no):
conn_db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30)
c_db = conn_db.cursor()
episodes_subtitles = c_db.execute(
- "SELECT table_episodes.sonarrEpisodeId, table_episodes.subtitles, table_shows.languages FROM table_episodes INNER JOIN table_shows on table_episodes.sonarrSeriesId = table_shows.sonarrSeriesId" + query_string).fetchall()
+ "SELECT table_episodes.sonarrEpisodeId, table_episodes.subtitles, table_shows.languages, table_shows.forced FROM table_episodes INNER JOIN table_shows on table_episodes.sonarrSeriesId = table_shows.sonarrSeriesId" + query_string).fetchall()
c_db.close()
missing_subtitles_global = []
@@ -235,6 +235,9 @@ def list_missing_subtitles(*no):
actual_subtitles.append(subtitle)
if episode_subtitles[2] is not None:
desired_subtitles = ast.literal_eval(episode_subtitles[2])
+ if episode_subtitles[3] == "True" and desired_subtitles is not None:
+ for i, desired_subtitle in enumerate(desired_subtitles):
+ desired_subtitles[i] = desired_subtitle + ":forced"
actual_subtitles_list = []
if desired_subtitles is None:
missing_subtitles_global.append(tuple(['[]', episode_subtitles[0]]))
@@ -263,7 +266,7 @@ def list_missing_subtitles_movies(*no):
pass
conn_db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30)
c_db = conn_db.cursor()
- movies_subtitles = c_db.execute("SELECT radarrId, subtitles, languages FROM table_movies" + query_string).fetchall()
+ movies_subtitles = c_db.execute("SELECT radarrId, subtitles, languages, forced FROM table_movies" + query_string).fetchall()
c_db.close()
missing_subtitles_global = []
@@ -283,6 +286,9 @@ def list_missing_subtitles_movies(*no):
actual_subtitles.append(subtitle)
if movie_subtitles[2] is not None:
desired_subtitles = ast.literal_eval(movie_subtitles[2])
+ if movie_subtitles[3] == "True" and desired_subtitles is not None:
+ for i, desired_subtitle in enumerate(desired_subtitles):
+ desired_subtitles[i] = desired_subtitle + ":forced"
actual_subtitles_list = []
if desired_subtitles is None:
missing_subtitles_global.append(tuple(['[]', movie_subtitles[0]]))
diff --git a/views/episodes.tpl b/views/episodes.tpl
index 1dfec49a9..08348e59e 100644
--- a/views/episodes.tpl
+++ b/views/episodes.tpl
@@ -227,17 +227,17 @@
if missing_languages is not None:
from get_subtitle import search_active
for language in missing_languages:
- if episode[10] is not None and settings.general.getboolean('adaptive_searching') and language in episode[10]:
+ if episode[10] is not None and settings.general.getboolean('adaptive_searching') and language in episode[10]:
for lang in ast.literal_eval(episode[10]):
if language in lang:
- if search_active(lang[1]):
+ if search_active(lang[1]):
%>
-
+ 1 else "False"}}" data-sonarrSeriesId="{{episode[5]}}" data-sonarrEpisodeId="{{episode[7]}}" class="get_subtitle ui tiny label">
{{language}}
%else:
-
+ 1 else "False"}}" data-sonarrSeriesId="{{episode[5]}}" data-sonarrEpisodeId="{{episode[7]}}" class="get_subtitle ui tiny label">
{{language}}
@@ -245,7 +245,7 @@
%end
%end
%else:
-
+ 1 else "False"}}" data-sonarrSeriesId="{{episode[5]}}" data-sonarrEpisodeId="{{episode[7]}}" class="get_subtitle ui tiny label">
{{language}}
diff --git a/views/movie.tpl b/views/movie.tpl
index aeb879239..409e70f5f 100644
--- a/views/movie.tpl
+++ b/views/movie.tpl
@@ -193,18 +193,24 @@
<%
for missing_subs_language in missing_subs_languages:
+ if len(missing_subs_language) > 2:
+ forced = missing_subs_language[2]
+ else:
+ forced = False
+ end
+
if details[14] is not None and settings.general.getboolean('adaptive_searching') and missing_subs_language in details[14]:
for lang in ast.literal_eval(details[14]):
if missing_subs_language in lang:
if search_active(lang[1]):
%>
-
- {{language_from_alpha2(str(missing_subs_language))}}
+
+ {{!'' if forced else ''}}{{language_from_alpha2(str(missing_subs_language.split(':')[0]))}}
%else:
-
- {{language_from_alpha2(str(missing_subs_language))}}
+
+ {{!'' if forced else ''}}{{language_from_alpha2(str(missing_subs_language.split(':')[0]))}}
<%
@@ -213,8 +219,8 @@
end
else:
%>
-
- {{language_from_alpha2(str(missing_subs_language))}}
+
+ {{!'' if forced else ''}}{{language_from_alpha2(str(missing_subs_language.split(':')[0]))}}
<%