diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-06-26 04:49:26 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-06-26 04:49:33 +0530 |
commit | 9eef7c4e558f86fb248554868931936097d46592 (patch) | |
tree | 7ff9d24bb64a7b9fe8b980a443c05641029d5c8f /yt_dlp/YoutubeDL.py | |
parent | bbae4377237f7535a738ae94b40dc6f76872f47b (diff) | |
download | hypervideo-pre-9eef7c4e558f86fb248554868931936097d46592.tar.lz hypervideo-pre-9eef7c4e558f86fb248554868931936097d46592.tar.xz hypervideo-pre-9eef7c4e558f86fb248554868931936097d46592.zip |
Sanitize `chapters`
Closes #4182
Diffstat (limited to 'yt_dlp/YoutubeDL.py')
-rw-r--r-- | yt_dlp/YoutubeDL.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 6ffc5f71c..c6882d0d7 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -2375,6 +2375,15 @@ class YoutubeDL: if (info_dict.get('duration') or 0) <= 0 and info_dict.pop('duration', None): self.report_warning('"duration" field is negative, there is an error in extractor') + chapters = info_dict.get('chapters') or [] + dummy_chapter = {'end_time': 0, 'start_time': info_dict.get('duration')} + for prev, current, next_ in zip( + (dummy_chapter, *chapters), chapters, (*chapters[1:], dummy_chapter)): + if current.get('start_time') is None: + current['start_time'] = prev.get('end_time') + if not current.get('end_time'): + current['end_time'] = next_.get('start_time') + if 'playlist' not in info_dict: # It isn't part of a playlist info_dict['playlist'] = None |