diff --git a/bazarr/get_languages.py b/bazarr/get_languages.py
index c76ddefc7..6d8b96182 100644
--- a/bazarr/get_languages.py
+++ b/bazarr/get_languages.py
@@ -5,6 +5,7 @@ import sqlite3
import pycountry
from get_args import args
+from subzero.language import Language
def load_language_in_db():
@@ -108,5 +109,21 @@ def alpha3_from_language(lang):
return result
+def get_language_set():
+ db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30)
+ c = db.cursor()
+ languages = c.execute('''SELECT code3 FROM table_settings_languages WHERE enabled = 1''').fetchall()
+ db.close()
+ language_set = set()
+
+ for lang in languages:
+ if lang[0] == 'pob':
+ language_set.add(Language('por', 'BR'))
+ else:
+ language_set.add(Language(lang[0]))
+
+ return language_set
+
+
if __name__ == '__main__':
load_language_in_db()
diff --git a/bazarr/list_subtitles.py b/bazarr/list_subtitles.py
index f4bcdc23e..6a803e0df 100644
--- a/bazarr/list_subtitles.py
+++ b/bazarr/list_subtitles.py
@@ -16,7 +16,7 @@ from bs4 import UnicodeDammit
from itertools import islice
from get_args import args
-from get_languages import alpha2_from_alpha3
+from get_languages import alpha2_from_alpha3, get_language_set
from config import settings
from helper import path_replace, path_replace_movie, path_replace_reverse, \
path_replace_reverse_movie
@@ -56,7 +56,8 @@ def store_subtitles(file):
try:
# fixme: set subliminal_patch.core.CUSTOM_PATHS to a list of absolute folders or subfolders to support
# subtitles outside the media file folder
- subtitles = search_external_subtitles(file)
+ subtitles = search_external_subtitles(file, languages=get_language_set(),
+ only_one=settings.general.getboolean('single_language'))
except Exception as e:
logging.exception("BAZARR unable to index external subtitles.")
pass
@@ -137,10 +138,10 @@ def store_subtitles_movie(file):
# fixme: set subliminal_patch.core.CUSTOM_PATHS to a list of absolute folders or subfolders to support
# subtitles outside the media file folder
- subtitles = search_external_subtitles(file)
brazilian_portuguese = [".pt-br", ".pob", "pb"]
try:
- subtitles = core.search_external_subtitles(file)
+ subtitles = search_external_subtitles(file, languages=get_language_set(),
+ only_one=settings.general.getboolean('single_language'))
except Exception as e:
logging.exception("BAZARR unable to index external subtitles.")
pass
diff --git a/libs/subliminal_patch/core.py b/libs/subliminal_patch/core.py
index e46ff617d..d4c159a1c 100644
--- a/libs/subliminal_patch/core.py
+++ b/libs/subliminal_patch/core.py
@@ -600,7 +600,7 @@ def _search_external_subtitles(path, languages=None, only_one=False, scandir_gen
logger.error('Cannot parse language code %r', language_code)
language = None
- if not language and only_one:
+ elif not language_code and only_one:
language = Language.rebuild(list(languages)[0], forced=forced)
subtitles[p] = language
diff --git a/views/episodes.tpl b/views/episodes.tpl
index d129b5edd..586e36dec 100644
--- a/views/episodes.tpl
+++ b/views/episodes.tpl
@@ -361,8 +361,11 @@
});
$('#search_missing_subtitles').on('click', function(){
- $('#loader_text').text("Searching for missing subtitles...");
- window.location = '{{base_url}}search_missing_subtitles/{{no}}';
+ $(this).addClass('disabled');
+ $(this).find('i:first').addClass('loading');
+ $.ajax({
+ url: '{{base_url}}search_missing_subtitles/{{no}}'
+ })
});
$('.remove_subtitles').on('click', function(){
@@ -418,7 +421,7 @@
});
});
- $('a:not(.manual_search), .menu .item, button:not(#config, .cancel)').on('click', function(){
+ $('a:not(.manual_search), .menu .item, button:not(#config, .cancel, #search_missing_subtitles)').on('click', function(){
$('#loader').addClass('active');
});
diff --git a/views/menu.tpl b/views/menu.tpl
index 10b6bec2b..9bea9b648 100644
--- a/views/menu.tpl
+++ b/views/menu.tpl
@@ -19,6 +19,8 @@
.searchicon {
color: white !important;
}
+ div.disabled { pointer-events: none; }
+ button.disabled { pointer-events: none; }
@@ -222,13 +224,13 @@
+
+
+
\ No newline at end of file
diff --git a/views/movie.tpl b/views/movie.tpl
index f43ef0a0b..8f6b96664 100644
--- a/views/movie.tpl
+++ b/views/movie.tpl
@@ -94,7 +94,7 @@
-
+
<%
subs_languages = ast.literal_eval(str(details[7]))
subs_languages_list = []
@@ -314,9 +314,12 @@
window.location = '{{base_url}}scan_disk_movie/{{no}}';
});
- $('#search_missing_subtitles').on('click', function(){
- $('#loader_text').text("Searching for missing subtitles...");
- window.location = '{{base_url}}search_missing_subtitles_movie/{{no}}';
+ $('#search_missing_subtitles_movie').on('click', function(){
+ $(this).addClass('disabled');
+ $(this).find('i:first').addClass('loading');
+ $.ajax({
+ url: '{{base_url}}search_missing_subtitles_movie/{{no}}'
+ })
});
$('.remove_subtitles').on('click', function(){
@@ -371,7 +374,7 @@
});
});
- $('a, .menu .item, button:not(#config, .cancel, .manual_search)').on('click', function(){
+ $('a, .menu .item, button:not(#config, .cancel, .manual_search, #search_missing_subtitles_movie)').on('click', function(){
$('#loader').addClass('active');
});
diff --git a/views/system.tpl b/views/system.tpl
index 40c9482d2..c53716bb5 100644
--- a/views/system.tpl
+++ b/views/system.tpl
@@ -62,7 +62,7 @@
-
+
Name |
@@ -73,7 +73,7 @@
%for task in task_list:
-
+
{{task[0]}} |
{{task[1]}} |
{{task[2]}} |
@@ -346,7 +346,11 @@
});
$('.execute').on('click', function(){
- window.location = '{{base_url}}execute/' + $(this).data("taskid");
+ $(this).addClass('disabled');
+ $(this).find('i:first').addClass('loading');
+ $.ajax({
+ url: '{{base_url}}execute/' + $(this).data("taskid")
+ })
});
$('a:not(.tabs), button:not(.cancel, #download_log), #restart').on('click', function(){
diff --git a/views/wantedmovies.tpl b/views/wantedmovies.tpl
index df87d8edd..1b2140068 100644
--- a/views/wantedmovies.tpl
+++ b/views/wantedmovies.tpl
@@ -139,7 +139,7 @@