mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-01 12:32:25 +08:00
Revert "Fixed uppercase mod to be run after hearing impaired mod"
This reverts commit 52df29a1f5
.
This commit is contained in:
parent
189840bea7
commit
88c9d67cf1
2 changed files with 38 additions and 25 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue