summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2023-02-21 06:33:44 -0500
committermorpheus65535 <[email protected]>2023-02-21 06:33:44 -0500
commit88c9d67cf174a08dae9ea3e96cd1c3e070fb318a (patch)
treec01729e08c197db83c33e4644524956fd50b52a1 /libs
parent189840bea78e20c4379a777222dad79def3f3385 (diff)
downloadbazarr-88c9d67cf174a08dae9ea3e96cd1c3e070fb318a.tar.gz
bazarr-88c9d67cf174a08dae9ea3e96cd1c3e070fb318a.zip
Revert "Fixed uppercase mod to be run after hearing impaired mod"v1.1.5-beta.21
This reverts commit 52df29a1f51d3975a2580cfd97bff31164d32a14.
Diffstat (limited to 'libs')
-rw-r--r--libs/subzero/modification/main.py38
-rw-r--r--libs/subzero/modification/mods/common.py25
2 files changed, 38 insertions, 25 deletions
diff --git a/libs/subzero/modification/main.py b/libs/subzero/modification/main.py
index 68ba77838..13bf22483 100644
--- a/libs/subzero/modification/main.py
+++ b/libs/subzero/modification/main.py
@@ -111,6 +111,11 @@ class SubtitleModifications(object):
identifier, self.language)
continue
+ if mod_cls.only_uppercase and not self.only_uppercase:
+ if self.debug:
+ logger.debug("Skipping %s, because the subtitle isn't all uppercase", identifier)
+ continue
+
# merge args of duplicate mods if possible
elif mod_cls.args_mergeable and identifier in mods_merged:
mods_merged[identifier] = mod_cls.merge_args(mods_merged[identifier], args)
@@ -175,9 +180,42 @@ class SubtitleModifications(object):
return line_mods, non_line_mods, used_mods
+ def detect_uppercase(self):
+ entries_used = 0
+ for entry in self.f:
+ entry_used = False
+ for sub in entry.text.strip().split(r"\N"):
+ # skip HI bracket entries, those might actually be lowercase
+ sub = sub.strip()
+ for processor in registry.mods["remove_HI"].processors[:4]:
+ sub = processor.process(sub)
+
+ if sub.strip():
+ # only consider alphabetic characters to determine if uppercase
+ alpha_sub = ''.join([i for i in sub if i.isalpha()])
+ if alpha_sub and not alpha_sub.isupper():
+ return False
+
+ entry_used = True
+ else:
+ # skip full entry
+ break
+
+ if entry_used:
+ entries_used += 1
+
+ if entries_used == 40:
+ break
+
+ return True
+
def modify(self, *mods):
new_entries = []
start = time.time()
+ self.only_uppercase = self.detect_uppercase()
+
+ if self.only_uppercase and self.debug:
+ logger.debug("Full-uppercase subtitle found")
line_mods, non_line_mods, mods_used = self.prepare_mods(*mods)
self.mods_used = mods_used
diff --git a/libs/subzero/modification/mods/common.py b/libs/subzero/modification/mods/common.py
index 9a715f0c7..3d16541bc 100644
--- a/libs/subzero/modification/mods/common.py
+++ b/libs/subzero/modification/mods/common.py
@@ -175,35 +175,10 @@ class FixUppercase(SubtitleModification):
long_description = "Some subtitles are in all-uppercase letters. This at least makes them readable."
- def detect_uppercase(self, parent):
- entries_used = 0
- for entry in parent.f:
- entry_used = False
- for sub in entry.text.strip().split(r"\N"):
- if sub.strip():
- alpha_sub = ''.join([i for i in sub if i.isalpha()])
- if alpha_sub and not alpha_sub.isupper():
- return False
-
- entry_used = True
- else:
- # skip full entry
- break
-
- if entry_used:
- entries_used += 1
-
- if entries_used == 40:
- break
-
- return True
-
def capitalize(self, c):
return u"".join([s.capitalize() for s in split_upper_re.split(c)])
def modify(self, content, debug=False, parent=None, **kwargs):
- if not self.detect_uppercase(parent):
- return
for entry in parent.f:
entry.plaintext = self.capitalize(entry.plaintext)