diff --git a/bazarr/config.py b/bazarr/config.py index 07a8d6965..0c231f593 100644 --- a/bazarr/config.py +++ b/bazarr/config.py @@ -31,6 +31,7 @@ defaults = { 'page_size': '25', 'minimum_score_movie': '70', 'use_embedded_subs': 'True', + 'ignore_pgs_subs': 'True', 'adaptive_searching': 'False', 'enabled_providers': '', 'throtteled_providers': '{}', diff --git a/bazarr/embedded_subs_reader.py b/bazarr/embedded_subs_reader.py index 0c4a3a100..7cd9bbfff 100644 --- a/bazarr/embedded_subs_reader.py +++ b/bazarr/embedded_subs_reader.py @@ -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,18 @@ 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'): + 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") + 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().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() \ No newline at end of file diff --git a/bazarr/main.py b/bazarr/main.py index 3e794de6c..86f7073ae 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -277,6 +277,11 @@ def save_wizard(): 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_subfolder = request.forms.get('settings_subfolder') settings_subfolder_custom = request.forms.get('settings_subfolder_custom') settings_upgrade_subs = request.forms.get('settings_upgrade_subs') @@ -302,6 +307,7 @@ def save_wizard(): settings.general.subfolder = text_type(settings_subfolder) settings.general.subfolder_custom = text_type(settings_subfolder_custom) settings.general.use_embedded_subs = text_type(settings_general_embedded) + settings.general.ignore_pgs_subs = text_type(settings_general_ignore_pgs) settings.general.upgrade_subs = text_type(settings_upgrade_subs) settings.general.days_to_upgrade_subs = text_type(settings_days_to_upgrade_subs) settings.general.upgrade_manual = text_type(settings_upgrade_manual) @@ -1234,6 +1240,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 +1343,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) diff --git a/views/settings.tpl b/views/settings.tpl index 3111f8d4d..6059709ab 100644 --- a/views/settings.tpl +++ b/views/settings.tpl @@ -1188,6 +1188,25 @@ +
+
+ +
+
+
+ + +
+
+ +
+
@@ -2232,6 +2251,12 @@ $("#settings_embedded").checkbox('uncheck'); } + if ($('#settings_ignore_pgs').data("ignore") === "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 {