Merge remote-tracking branch 'origin/development' into development

pull/489/head
Halali 6 years ago
commit ada9ffb045

@ -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()

@ -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

@ -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

@ -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');
});

@ -19,6 +19,8 @@
.searchicon {
color: white !important;
}
div.disabled { pointer-events: none; }
button.disabled { pointer-events: none; }
</style>
</head>
<body>
@ -222,13 +224,13 @@
</script>
<script type="text/javascript">
var url = location.protocol +"//" + window.location.host + "{{base_url}}notifications";
var notification;
var url_notifications = location.protocol +"//" + window.location.host + "{{base_url}}notifications";
var notificationTimeout;
var timeout;
var killer;
function doAjax() {
function doNotificationsAjax() {
$.ajax({
url: url,
url: url_notifications,
success: function (data) {
if (data !== "") {
data = JSON.parse(data);
@ -275,17 +277,79 @@
},
complete: function (data) {
// Schedule the next
if (data != "") {
notification = setTimeout(doAjax, 100);
if (data !== "") {
notificationTimeout = setTimeout(doNotificationsAjax, 100);
} else {
notification = setTimeout(doAjax, 1000);
notificationTimeout = setTimeout(doNotificationsAjax, 1000);
}
}
});
}
notification = setTimeout(doAjax, 1000);
notificationTimeout = setTimeout(doNotificationsAjax, 1000);
$(window).bind('beforeunload', function(){
clearTimeout(notification);
clearTimeout(notificationTimeout);
});
</script>
<script type="text/javascript">
var url_tasks = location.protocol +"//" + window.location.host + "{{base_url}}running_tasks";
var tasksTimeout;
function doTasksAjax() {
$.ajax({
url: url_tasks,
dataType: 'json',
success: function (data) {
$('#tasks > tbody > tr').each(function() {
if ($.inArray($(this).attr('id'), data['tasks']) > -1) {
$(this).find('td:last').find('div:first').addClass('disabled');
$(this).find('td:last').find('div:first').find('i:first').addClass('loading');
} else {
$(this).find('td:last').find('div:first').removeClass('disabled');
$(this).find('td:last').find('div:first').find('i:first').removeClass('loading');
}
});
if ($.inArray('wanted_search_missing_subtitles', data['tasks']) > -1) {
$('#wanted_search_missing_subtitles').addClass('disabled');
$('#wanted_search_missing_subtitles_movies').addClass('disabled');
$('#wanted_search_missing_subtitles').find('i:first').addClass('loading');
$('#wanted_search_missing_subtitles_movies').find('i:first').addClass('loading');
} else {
$('#wanted_search_missing_subtitles').removeClass('disabled');
$('#wanted_search_missing_subtitles_movies').removeClass('disabled');
$('#wanted_search_missing_subtitles').find('i:first').removeClass('loading');
$('#wanted_search_missing_subtitles_movies').find('i:first').removeClass('loading');
}
%if 'no' in locals():
if ($.inArray('search_missing_subtitles_{{no}}', data['tasks']) > -1) {
$('#search_missing_subtitles').addClass('disabled');
$('#search_missing_subtitles').find('i:first').addClass('loading');
} else {
$('#search_missing_subtitles').removeClass('disabled');
$('#search_missing_subtitles').find('i:first').removeClass('loading');
}
if ($.inArray('search_missing_subtitles_movie_{{no}}', data['tasks']) > -1) {
$('#search_missing_subtitles_movie').addClass('disabled');
$('#search_missing_subtitles_movie').find('i:first').addClass('loading');
} else {
$('#search_missing_subtitles_movie').removeClass('disabled');
$('#search_missing_subtitles_movie').find('i:first').removeClass('loading');
}
%end
},
complete: function (data) {
// Schedule the next
tasksTimeout = setTimeout(doTasksAjax, 5000);
}
});
}
tasksTimeout = setTimeout(doTasksAjax, 500);
$(window).bind('beforeunload', function(){
clearTimeout(tasksTimeout);
});
</script>

@ -94,7 +94,7 @@
<img class="left floated ui image" style="max-height:250px;" src="{{base_url}}image_proxy_movies{{details[2]}}">
<div class="ui right floated basic icon buttons">
<button id="scan_disk" class="ui button" data-tooltip="Scan disk for subtitles" data-inverted=""><i class="ui inverted large compact refresh icon"></i></button>
<button id="search_missing_subtitles" class="ui button" data-tooltip="Download missing subtitles" data-inverted=""><i class="ui inverted huge compact search icon"></i></button>
<button id="search_missing_subtitles_movie" class="ui button" data-tooltip="Download missing subtitles" data-inverted=""><i class="ui inverted huge compact search icon"></i></button>
<%
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');
});

@ -62,7 +62,7 @@
</div>
<div class="ui bottom attached tab segment active" data-tab="tasks">
<div class="content">
<table class="ui very basic selectable table">
<table class="ui very basic selectable table" id="tasks">
<thead>
<tr>
<th>Name</th>
@ -73,7 +73,7 @@
</thead>
<tbody>
%for task in task_list:
<tr>
<tr id="{{task[3]}}">
<td>{{task[0]}}</td>
<td>{{task[1]}}</td>
<td>{{task[2]}}</td>
@ -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(){

@ -139,7 +139,7 @@
<script>
$('a, button').on('click', function(){
$('a, button:not(#wanted_search_missing_subtitles_movies)').on('click', function(){
$('#loader').addClass('active');
});
@ -157,8 +157,11 @@
});
$('#wanted_search_missing_subtitles_movies').on('click', function(){
$('#loader_text').text("Searching for missing subtitles...");
window.location = '{{base_url}}wanted_search_missing_subtitles';
$(this).addClass('disabled');
$(this).find('i:first').addClass('loading');
$.ajax({
url: '{{base_url}}wanted_search_missing_subtitles'
})
});
$('.get_subtitle').on('click', function(){

@ -146,7 +146,7 @@
<script>
$('a, button').on('click', function(){
$('a, button:not(#wanted_search_missing_subtitles)').on('click', function(){
$('#loader').addClass('active');
});
@ -164,8 +164,11 @@
});
$('#wanted_search_missing_subtitles').on('click', function(){
$('#loader_text').text("Searching for missing subtitles...");
window.location = '{{base_url}}wanted_search_missing_subtitles';
$(this).addClass('disabled');
$(this).find('i:first').addClass('loading');
$.ajax({
url: '{{base_url}}wanted_search_missing_subtitles'
})
});
$('.get_subtitle').on('click', function(){

Loading…
Cancel
Save