mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-02-22 13:53:11 +08:00
subliminal_patch: update again; add is_valid shortcut
This commit is contained in:
parent
8879f5a82e
commit
10c7012c18
1 changed files with 7 additions and 0 deletions
|
@ -44,11 +44,13 @@ class Subtitle(Subtitle_):
|
||||||
|
|
||||||
pack_data = None
|
pack_data = None
|
||||||
_guessed_encoding = None
|
_guessed_encoding = None
|
||||||
|
_is_valid = False
|
||||||
|
|
||||||
def __init__(self, language, hearing_impaired=False, page_link=None, encoding=None, mods=None):
|
def __init__(self, language, hearing_impaired=False, page_link=None, encoding=None, mods=None):
|
||||||
super(Subtitle, self).__init__(language, hearing_impaired=hearing_impaired, page_link=page_link,
|
super(Subtitle, self).__init__(language, hearing_impaired=hearing_impaired, page_link=page_link,
|
||||||
encoding=encoding)
|
encoding=encoding)
|
||||||
self.mods = mods
|
self.mods = mods
|
||||||
|
self._is_valid = False
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<%s %r [%s:%s]>' % (
|
return '<%s %r [%s:%s]>' % (
|
||||||
|
@ -212,6 +214,9 @@ class Subtitle(Subtitle_):
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
if self._is_valid:
|
||||||
|
return True
|
||||||
|
|
||||||
text = self.text
|
text = self.text
|
||||||
if not text:
|
if not text:
|
||||||
return False
|
return False
|
||||||
|
@ -222,6 +227,7 @@ class Subtitle(Subtitle_):
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.error("PySRT-parsing failed, trying pysubs2")
|
logger.error("PySRT-parsing failed, trying pysubs2")
|
||||||
else:
|
else:
|
||||||
|
self._is_valid = True
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# something else, try to return srt
|
# something else, try to return srt
|
||||||
|
@ -247,6 +253,7 @@ class Subtitle(Subtitle_):
|
||||||
logger.exception("Couldn't convert subtitle %s to .srt format: %s", self, traceback.format_exc())
|
logger.exception("Couldn't convert subtitle %s to .srt format: %s", self, traceback.format_exc())
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
self._is_valid = True
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in a new issue