Aded option to ignore embedded subtitles #69

pull/119/merge
morpheus65535 6 years ago
parent 12d8e8b840
commit 3d98836f3b

@ -682,6 +682,11 @@ def save_settings():
settings_general_scenename = 'False'
else:
settings_general_scenename = 'True'
settings_general_embedded = request.forms.get('settings_general_embedded')
if settings_general_embedded is None:
settings_general_embedded = 'False'
else:
settings_general_embedded = 'True'
settings_general_minimum_score = request.forms.get('settings_general_minimum_score')
settings_general_use_postprocessing = request.forms.get('settings_general_use_postprocessing')
if settings_general_use_postprocessing is None:
@ -703,7 +708,7 @@ def save_settings():
before = c.execute("SELECT ip, port, base_url, log_level, path_mapping, use_sonarr, use_radarr, path_mapping_movie FROM table_settings_general").fetchone()
after = (unicode(settings_general_ip), int(settings_general_port), unicode(settings_general_baseurl), unicode(settings_general_loglevel), unicode(settings_general_pathmapping), unicode(settings_general_use_sonarr), unicode(settings_general_use_radarr), unicode(settings_general_pathmapping_movie))
c.execute("UPDATE table_settings_general SET ip = ?, port = ?, base_url = ?, path_mapping = ?, log_level = ?, branch=?, auto_update=?, single_language=?, minimum_score=?, use_scenename=?, use_postprocessing=?, postprocessing_cmd=?, use_sonarr=?, use_radarr=?, path_mapping_movie=?, page_size=?", (unicode(settings_general_ip), int(settings_general_port), unicode(settings_general_baseurl), unicode(settings_general_pathmapping), unicode(settings_general_loglevel), unicode(settings_general_branch), unicode(settings_general_automatic), unicode(settings_general_single_language), unicode(settings_general_minimum_score), unicode(settings_general_scenename), unicode(settings_general_use_postprocessing), unicode(settings_general_postprocessing_cmd), unicode(settings_general_use_sonarr), unicode(settings_general_use_radarr), unicode(settings_general_pathmapping_movie), unicode(settings_page_size)))
c.execute("UPDATE table_settings_general SET ip = ?, port = ?, base_url = ?, path_mapping = ?, log_level = ?, branch=?, auto_update=?, single_language=?, minimum_score=?, use_scenename=?, use_postprocessing=?, postprocessing_cmd=?, use_sonarr=?, use_radarr=?, path_mapping_movie=?, page_size=?, use_embedded_subs=?", (unicode(settings_general_ip), int(settings_general_port), unicode(settings_general_baseurl), unicode(settings_general_pathmapping), unicode(settings_general_loglevel), unicode(settings_general_branch), unicode(settings_general_automatic), unicode(settings_general_single_language), unicode(settings_general_minimum_score), unicode(settings_general_scenename), unicode(settings_general_use_postprocessing), unicode(settings_general_postprocessing_cmd), unicode(settings_general_use_sonarr), unicode(settings_general_use_radarr), unicode(settings_general_pathmapping_movie), unicode(settings_page_size), unicode(settings_general_embedded)))
conn.commit()
if after != before:
configured()

@ -50,8 +50,9 @@ def get_general_settings():
movie_default_language = general_settings[21]
movie_default_hi = general_settings[22]
page_size = general_settings[23]
use_embedded_subs = general_settings[24]
return [ip, port, base_url, path_mappings, log_level, branch, automatic, single_language, minimum_score, use_scenename, use_postprocessing, postprocessing_cmd, use_sonarr, use_radarr, path_mappings_movie, serie_default_enabled, serie_default_language, serie_default_hi, movie_default_enabled,movie_default_language, movie_default_hi, page_size]
return [ip, port, base_url, path_mappings, log_level, branch, automatic, single_language, minimum_score, use_scenename, use_postprocessing, postprocessing_cmd, use_sonarr, use_radarr, path_mappings_movie, serie_default_enabled, serie_default_language, serie_default_hi, movie_default_enabled,movie_default_language, movie_default_hi, page_size, use_embedded_subs]
def path_replace(path):
for path_mapping in path_mappings:
@ -130,3 +131,4 @@ movie_default_enabled = result[18]
movie_default_language = result[19]
movie_default_hi = result[20]
page_size = result[21]
use_embedded_subs = result[22]

@ -25,6 +25,7 @@ def store_subtitles(file):
for subtitle_track in mkv.subtitle_tracks:
try:
if alpha2_from_alpha3(subtitle_track.language) != None:
actual_subtitles.append([str(alpha2_from_alpha3(subtitle_track.language)),None])
except:
pass
@ -79,6 +80,7 @@ def store_subtitles_movie(file):
for subtitle_track in mkv.subtitle_tracks:
try:
if alpha2_from_alpha3(subtitle_track.language) != None:
actual_subtitles.append([str(alpha2_from_alpha3(subtitle_track.language)), None])
except:
pass
@ -131,13 +133,20 @@ def list_missing_subtitles(*no):
c_db.close()
missing_subtitles_global = []
use_embedded_subs = get_general_settings()[22]
for episode_subtitles in episodes_subtitles:
actual_subtitles_temp = []
actual_subtitles = []
desired_subtitles = []
missing_subtitles = []
if episode_subtitles[1] != None:
if use_embedded_subs == "True":
actual_subtitles = ast.literal_eval(episode_subtitles[1])
else:
actual_subtitles_temp = ast.literal_eval(episode_subtitles[1])
for subtitle in actual_subtitles_temp:
if subtitle[1] != None:
actual_subtitles.append(subtitle)
if episode_subtitles[2] != None:
desired_subtitles = ast.literal_eval(episode_subtitles[2])
actual_subtitles_list = []
@ -171,13 +180,20 @@ def list_missing_subtitles_movies(*no):
c_db.close()
missing_subtitles_global = []
use_embedded_subs = get_general_settings()[22]
for movie_subtitles in movies_subtitles:
actual_subtitles_temp = []
actual_subtitles = []
desired_subtitles = []
missing_subtitles = []
if movie_subtitles[1] != None:
if use_embedded_subs == "True":
actual_subtitles = ast.literal_eval(movie_subtitles[1])
else:
actual_subtitles_temp = ast.literal_eval(movie_subtitles[1])
for subtitle in actual_subtitles_temp:
if subtitle[1] != None:
actual_subtitles.append(subtitle)
if movie_subtitles[2] != None:
desired_subtitles = ast.literal_eval(movie_subtitles[2])
actual_subtitles_list = []

@ -171,6 +171,13 @@ if os.path.exists(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
except:
pass
try:
c.execute('alter table table_settings_general add column "use_embedded_subs" "text"')
except:
pass
else:
c.execute('UPDATE table_settings_general SET use_embedded_subs="True"')
# Commit change to db
db.commit()

@ -764,6 +764,25 @@
</div>
</div>
</div>
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Use embedded subtitles</label>
</div>
<div class="one wide column">
<div id="settings_embedded" class="ui toggle checkbox" data-embedded={{settings_general[24]}}>
<input name="settings_general_embedded" type="checkbox">
<label></label>
</div>
</div>
<div class="collapsed column">
<div class="collapsed center aligned column">
<div class="ui basic icon" data-tooltip="Use embedded subtitles in media files when determining missing ones." data-inverted="">
<i class="help circle large icon"></i>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="ui dividing header">Subtitles providers</div>
@ -1118,6 +1137,12 @@
$("#settings_scenename").checkbox('uncheck');
}
if ($('#settings_embedded').data("embedded") == "True") {
$("#settings_embedded").checkbox('check');
} else {
$("#settings_embedded").checkbox('uncheck');
}
if ($('#settings_use_postprocessing').data("postprocessing") == "True") {
$("#settings_use_postprocessing").checkbox('check');
$("#settings_general_postprocessing_cmd_div").removeClass('disabled');

Loading…
Cancel
Save