mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-24 00:33:27 +00:00
Merge pull request #428 from sekkr1/development
added ignore pgs subs setting to embedded scan
This commit is contained in:
commit
a0e7e63286
4 changed files with 46 additions and 2 deletions
|
@ -31,6 +31,7 @@ defaults = {
|
|||
'page_size': '25',
|
||||
'minimum_score_movie': '70',
|
||||
'use_embedded_subs': 'True',
|
||||
'ignore_pgs_subs': 'False',
|
||||
'adaptive_searching': 'False',
|
||||
'enabled_providers': '',
|
||||
'throtteled_providers': '{}',
|
||||
|
|
|
@ -4,6 +4,7 @@ import os
|
|||
import subprocess
|
||||
import locale
|
||||
|
||||
from config import settings
|
||||
from utils import get_binary
|
||||
|
||||
class NotMKVAndNoFFprobe(Exception):
|
||||
|
@ -19,13 +20,24 @@ class EmbeddedSubsReader:
|
|||
def list_languages(self, file):
|
||||
if self.ffprobe:
|
||||
try:
|
||||
return subprocess.check_output([self.ffprobe, "-loglevel", "error", "-select_streams", "s", "-show_entries", "stream_tags=language", "-of", "csv=p=0", file.encode(locale.getpreferredencoding())], universal_newlines=True, stderr=subprocess.STDOUT).strip().split("\n")
|
||||
if not settings.general.getboolean('ignore_pgs_subs'):
|
||||
subtitle_languages = subprocess.check_output([self.ffprobe, "-loglevel", "error", "-select_streams", "s", "-show_entries", "stream_tags=language", "-of", "csv=p=0", file.encode(locale.getpreferredencoding())], universal_newlines=True, stderr=subprocess.STDOUT).strip()
|
||||
if not subtitle_languages:
|
||||
return []
|
||||
return subtitle_languages.split('\n')
|
||||
subtitle_tracks = subprocess.check_output([self.ffprobe, "-loglevel", "error", "-select_streams", "s", "-show_entries", "stream=codec_name:stream_tags=language", "-of", "csv=p=0", file.encode(locale.getpreferredencoding())], universal_newlines=True, stderr=subprocess.STDOUT).strip()
|
||||
if not subtitle_tracks:
|
||||
return []
|
||||
subtitle_tracks = subtitle_tracks.split('\n')
|
||||
return [lang for (sub_type, lang) in map(lambda subtitle_track: subtitle_track.split(','), subtitle_tracks) if sub_type != 'hdmv_pgs_subtitle']
|
||||
except subprocess.CalledProcessError as e:
|
||||
raise FFprobeError(e.output)
|
||||
if os.path.splitext(file)[1] != '.mkv':
|
||||
raise NotMKVAndNoFFprobe()
|
||||
with open(file, 'rb') as f:
|
||||
mkv = enzyme.MKV(f)
|
||||
return [subtitle_track.language for subtitle_track in mkv.subtitle_tracks]
|
||||
if not settings.general.getboolean('ignore_pgs_subs'):
|
||||
return [subtitle_track.language for subtitle_track in mkv.subtitle_tracks]
|
||||
return [subtitle_track.language for subtitle_track in mkv.subtitle_tracks if subtitle_track.codec_id != "S_HDMV/PGS"]
|
||||
|
||||
embedded_subs_reader = EmbeddedSubsReader()
|
|
@ -1234,6 +1234,11 @@ def save_settings():
|
|||
settings_general_embedded = 'False'
|
||||
else:
|
||||
settings_general_embedded = 'True'
|
||||
settings_general_ignore_pgs = request.forms.get('settings_general_ignore_pgs')
|
||||
if settings_general_ignore_pgs is None:
|
||||
settings_general_ignore_pgs = 'False'
|
||||
else:
|
||||
settings_general_ignore_pgs = 'True'
|
||||
settings_general_adaptive_searching = request.forms.get('settings_general_adaptive_searching')
|
||||
if settings_general_adaptive_searching is None:
|
||||
settings_general_adaptive_searching = 'False'
|
||||
|
@ -1332,6 +1337,7 @@ def save_settings():
|
|||
|
||||
settings.general.minimum_score_movie = text_type(settings_general_minimum_score_movies)
|
||||
settings.general.use_embedded_subs = text_type(settings_general_embedded)
|
||||
settings.general.ignore_pgs_subs = text_type(settings_general_ignore_pgs)
|
||||
settings.general.adaptive_searching = text_type(settings_general_adaptive_searching)
|
||||
settings.general.multithreading = text_type(settings_general_multithreading)
|
||||
|
||||
|
|
|
@ -1188,6 +1188,25 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="middle aligned row">
|
||||
<div class="right aligned four wide column">
|
||||
<label>Ignore embedded PGS subtitles</label>
|
||||
</div>
|
||||
<div class="one wide column">
|
||||
<div id="settings_ignore_pgs" class="ui toggle checkbox" data-ignorepgs={{settings.general.getboolean('ignore_pgs_subs')}}>
|
||||
<input name="settings_general_ignore_pgs" type="checkbox">
|
||||
<label></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapsed column">
|
||||
<div class="collapsed center aligned column">
|
||||
<div class="ui basic icon" data-tooltip="Ignores pgs subtitles in embedded subtitles detection. Only relevant if 'Use embedded subtitles' is enabled." data-inverted="">
|
||||
<i class="help circle large icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="middle aligned row">
|
||||
<div class="right aligned four wide column">
|
||||
<label>Adaptive searching</label>
|
||||
|
@ -2232,6 +2251,12 @@
|
|||
$("#settings_embedded").checkbox('uncheck');
|
||||
}
|
||||
|
||||
if ($('#settings_ignore_pgs').data("ignorepgs") === "True") {
|
||||
$("#settings_ignore_pgs").checkbox('check');
|
||||
} else {
|
||||
$("#settings_ignore_pgs").checkbox('uncheck');
|
||||
}
|
||||
|
||||
if ($('#settings_only_monitored_sonarr').data("monitored") === "True") {
|
||||
$("#settings_only_monitored_sonarr").checkbox('check');
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue