summaryrefslogtreecommitdiffhomepage
path: root/libs/srt.py
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2022-01-23 23:07:52 -0500
committermorpheus65535 <[email protected]>2022-01-23 23:07:52 -0500
commit0c3c5a02a75bc61b6bf6e303de20e11741d2afac (patch)
tree30ae1d524ffe5d54172b7a4a8445d90c3461e659 /libs/srt.py
parent36bf0d219d0432c20e6314e0ce752b36f4d88e3c (diff)
downloadbazarr-0c3c5a02a75bc61b6bf6e303de20e11741d2afac.tar.gz
bazarr-0c3c5a02a75bc61b6bf6e303de20e11741d2afac.zip
Upgraded vendored Python dependencies to the latest versions and removed the unused dependencies.v1.0.3-beta.16
Diffstat (limited to 'libs/srt.py')
-rw-r--r--libs/srt.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/libs/srt.py b/libs/srt.py
index f781f7f9a..a4eb19dc6 100644
--- a/libs/srt.py
+++ b/libs/srt.py
@@ -18,9 +18,26 @@ LOG = logging.getLogger(__name__)
# accept it, so we do too.
RGX_TIMESTAMP_MAGNITUDE_DELIM = r"[,.:,.。:]"
RGX_TIMESTAMP_FIELD = r"[0-9]+"
-RGX_TIMESTAMP = RGX_TIMESTAMP_MAGNITUDE_DELIM.join([RGX_TIMESTAMP_FIELD] * 4)
+RGX_TIMESTAMP_FIELD_OPTIONAL = r"[0-9]*"
+RGX_TIMESTAMP = "".join(
+ [
+ RGX_TIMESTAMP_MAGNITUDE_DELIM.join([RGX_TIMESTAMP_FIELD] * 3),
+ RGX_TIMESTAMP_MAGNITUDE_DELIM,
+ "?",
+ RGX_TIMESTAMP_FIELD_OPTIONAL,
+ ]
+)
RGX_TIMESTAMP_PARSEABLE = r"^{}$".format(
- RGX_TIMESTAMP_MAGNITUDE_DELIM.join(["(" + RGX_TIMESTAMP_FIELD + ")"] * 4)
+ "".join(
+ [
+ RGX_TIMESTAMP_MAGNITUDE_DELIM.join(["(" + RGX_TIMESTAMP_FIELD + ")"] * 3),
+ RGX_TIMESTAMP_MAGNITUDE_DELIM,
+ "?",
+ "(",
+ RGX_TIMESTAMP_FIELD_OPTIONAL,
+ ")",
+ ]
+ )
)
RGX_INDEX = r"-?[0-9]+\.?[0-9]*"
RGX_PROPRIETARY = r"[^\r\n]*"
@@ -126,7 +143,7 @@ class Subtitle(object):
:param bool strict: If disabled, will allow blank lines in the content
of the SRT block, which is a violation of the SRT
- standard and may case your media player to explode
+ standard and may cause your media player to explode
:param str eol: The end of line string to use (default "\\n")
:returns: The metadata of the current :py:class:`Subtitle` object as an
SRT formatted subtitle block
@@ -228,7 +245,7 @@ def srt_timestamp_to_timedelta(timestamp):
match = TS_REGEX.match(timestamp)
if match is None:
raise TimestampParseError("Unparseable timestamp: {}".format(timestamp))
- hrs, mins, secs, msecs = map(int, match.groups())
+ hrs, mins, secs, msecs = [int(m) if m else 0 for m in match.groups()]
return timedelta(hours=hrs, minutes=mins, seconds=secs, milliseconds=msecs)