diff options
author | Jesús <heckyel@hyperbola.info> | 2022-02-18 16:58:38 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2022-02-18 16:58:38 -0500 |
commit | c7a54bcfbd27dde89c6267b42da7de8ea5625be1 (patch) | |
tree | 671b2b7ffe3f976952836dbfe6ee53bf33971e3a /yt_dlp/extractor/common.py | |
parent | b6d1ccad21d790c38605be2966ad17e92f1186d7 (diff) | |
parent | ed66a17ef0b18159dda901f0122520c25ea95d6b (diff) | |
download | hypervideo-pre-c7a54bcfbd27dde89c6267b42da7de8ea5625be1.tar.lz hypervideo-pre-c7a54bcfbd27dde89c6267b42da7de8ea5625be1.tar.xz hypervideo-pre-c7a54bcfbd27dde89c6267b42da7de8ea5625be1.zip |
updated from upstream | 18/02/2022 at 16:58
Diffstat (limited to 'yt_dlp/extractor/common.py')
-rw-r--r-- | yt_dlp/extractor/common.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index 37c8be5f6..04d4c0733 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -75,6 +75,7 @@ from ..utils import ( str_to_int, strip_or_none, traverse_obj, + try_get, unescapeHTML, UnsupportedError, unified_strdate, @@ -2878,7 +2879,8 @@ class InfoExtractor(object): segment_duration = None if 'total_number' not in representation_ms_info and 'segment_duration' in representation_ms_info: segment_duration = float_or_none(representation_ms_info['segment_duration'], representation_ms_info['timescale']) - representation_ms_info['total_number'] = int(math.ceil(float(period_duration) / segment_duration)) + representation_ms_info['total_number'] = int(math.ceil( + float_or_none(period_duration, segment_duration, default=0))) representation_ms_info['fragments'] = [{ media_location_key: media_template % { 'Number': segment_number, @@ -2969,6 +2971,10 @@ class InfoExtractor(object): f['url'] = initialization_url f['fragments'].append({location_key(initialization_url): initialization_url}) f['fragments'].extend(representation_ms_info['fragments']) + if not period_duration: + period_duration = try_get( + representation_ms_info, + lambda r: sum(frag['duration'] for frag in r['fragments']), float) else: # Assuming direct URL to unfragmented media. f['url'] = base_url |