diff --git a/lib/svtplay_dl/fetcher/dash.py b/lib/svtplay_dl/fetcher/dash.py index 5ec34c8..1d62816 100644 --- a/lib/svtplay_dl/fetcher/dash.py +++ b/lib/svtplay_dl/fetcher/dash.py @@ -299,7 +299,7 @@ def parse_duration(duration): def parse_dates(date_str): - match = re.search(r"(.*:.*)\.(\d{9})Z", date_str) + match = re.search(r"(.*:.*)\.(\d{5,9})Z", date_str) if match: date_str = f"{match.group(1)}.{int(int(match.group(2))/1000)}Z" # Need to translate nanoseconds to milliseconds date_patterns = ["%Y-%m-%dT%H:%M:%S.%fZ", "%Y-%m-%dT%H:%M:%S", "%Y-%m-%dT%H:%M:%SZ"] diff --git a/lib/svtplay_dl/tests/test_dash.py b/lib/svtplay_dl/tests/test_dash.py index 893f273..28040c6 100644 --- a/lib/svtplay_dl/tests/test_dash.py +++ b/lib/svtplay_dl/tests/test_dash.py @@ -69,6 +69,11 @@ def test_parse_duration(): def test_parse_date(): assert isinstance(parse_dates("2021-05-10T06:00:11.451554796Z"), datetime.datetime) + assert isinstance(parse_dates("2021-05-10T06:00:11.45155479Z"), datetime.datetime) + assert isinstance(parse_dates("2021-05-10T06:00:11.4515547Z"), datetime.datetime) + assert isinstance(parse_dates("2021-05-10T06:00:11.451554Z"), datetime.datetime) + assert isinstance(parse_dates("2021-05-10T06:00:11.45155Z"), datetime.datetime) + assert isinstance(parse_dates("2021-05-10T06:00:11.4515Z"), datetime.datetime) assert isinstance(parse_dates("2021-05-10T06:00:11.45Z"), datetime.datetime) assert isinstance(parse_dates("2021-05-10T06:00:11Z"), datetime.datetime) assert isinstance(parse_dates("2021-05-10T06:00:11"), datetime.datetime)