aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2019-05-07 06:43:21 -0400
committerGitHub <[email protected]>2019-05-07 06:43:21 -0400
commita0e7e63286f2a9af929bfcc21280f1193588c952 (patch)
treef6502f2cf73852ea17308bd0b249c170206e2fc8
parent85be773190c40c5af412e73cf0c5058d3fa9cec6 (diff)
parentbe7ea23239b80a3c20df3a566cf262de04c67b8d (diff)
downloadbazarr-a0e7e63286f2a9af929bfcc21280f1193588c952.tar.gz
bazarr-a0e7e63286f2a9af929bfcc21280f1193588c952.zip
Merge pull request #428 from sekkr1/developmentv0.7.4
added ignore pgs subs setting to embedded scan
-rw-r--r--bazarr/config.py1
-rw-r--r--bazarr/embedded_subs_reader.py16
-rw-r--r--bazarr/main.py6
-rw-r--r--views/settings.tpl25
4 files changed, 46 insertions, 2 deletions
diff --git a/bazarr/config.py b/bazarr/config.py
index 07a8d6965..2bfdcf2bf 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': 'False',
'adaptive_searching': 'False',
'enabled_providers': '',
'throtteled_providers': '{}',
diff --git a/bazarr/embedded_subs_reader.py b/bazarr/embedded_subs_reader.py
index 0c4a3a100..a4a659c63 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,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() \ No newline at end of file
diff --git a/bazarr/main.py b/bazarr/main.py
index 3e794de6c..f57fc2e8e 100644
--- a/bazarr/main.py
+++ b/bazarr/main.py
@@ -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)
diff --git a/views/settings.tpl b/views/settings.tpl
index 3111f8d4d..ae3c73f9e 100644
--- a/views/settings.tpl
+++ b/views/settings.tpl
@@ -1190,6 +1190,25 @@
<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>
</div>
<div class="one wide column">
@@ -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 {