aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/postprocessor/modify_chapters.py
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2021-10-20 11:45:20 -0500
committerJesús <heckyel@hyperbola.info>2021-10-20 11:45:20 -0500
commitc7afb25e19a91493db6069d1db9f7d1bc8491dc1 (patch)
treed4f4d0a125e191585af49dcfb189d2f1ba9acf17 /yt_dlp/postprocessor/modify_chapters.py
parent000d2844fd93d8c35fc74d22588291e7c7d742fa (diff)
parentd3c93ec2b7f5bcb872b0afb169efaa2f1abdf6e2 (diff)
downloadhypervideo-pre-c7afb25e19a91493db6069d1db9f7d1bc8491dc1.tar.lz
hypervideo-pre-c7afb25e19a91493db6069d1db9f7d1bc8491dc1.tar.xz
hypervideo-pre-c7afb25e19a91493db6069d1db9f7d1bc8491dc1.zip
updated from upstream | 20/10/2021 at 11:45
Diffstat (limited to 'yt_dlp/postprocessor/modify_chapters.py')
-rw-r--r--yt_dlp/postprocessor/modify_chapters.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/yt_dlp/postprocessor/modify_chapters.py b/yt_dlp/postprocessor/modify_chapters.py
index a0818c41b..dca876200 100644
--- a/yt_dlp/postprocessor/modify_chapters.py
+++ b/yt_dlp/postprocessor/modify_chapters.py
@@ -31,8 +31,10 @@ class ModifyChaptersPP(FFmpegPostProcessor):
@PostProcessor._restrict_to(images=False)
def run(self, info):
+ # Chapters must be preserved intact when downloading multiple formats of the same video.
chapters, sponsor_chapters = self._mark_chapters_to_remove(
- info.get('chapters') or [], info.get('sponsorblock_chapters') or [])
+ copy.deepcopy(info.get('chapters')) or [],
+ copy.deepcopy(info.get('sponsorblock_chapters')) or [])
if not chapters and not sponsor_chapters:
return [], info
@@ -126,7 +128,7 @@ class ModifyChaptersPP(FFmpegPostProcessor):
cuts = []
def append_cut(c):
- assert 'remove' in c
+ assert 'remove' in c, 'Not a cut is appended to cuts'
last_to_cut = cuts[-1] if cuts else None
if last_to_cut and last_to_cut['end_time'] >= c['start_time']:
last_to_cut['end_time'] = max(last_to_cut['end_time'], c['end_time'])
@@ -154,7 +156,7 @@ class ModifyChaptersPP(FFmpegPostProcessor):
new_chapters = []
def append_chapter(c):
- assert 'remove' not in c
+ assert 'remove' not in c, 'Cut is appended to chapters'
length = c['end_time'] - c['start_time'] - excess_duration(c)
# Chapter is completely covered by cuts or sponsors.
if length <= 0:
@@ -237,7 +239,7 @@ class ModifyChaptersPP(FFmpegPostProcessor):
heapq.heappush(chapters, (c['start_time'], i, c))
# (normal, sponsor) and (sponsor, sponsor)
else:
- assert '_categories' in c
+ assert '_categories' in c, 'Normal chapters overlap'
cur_chapter['_was_cut'] = True
c['_was_cut'] = True
# Push the part after the sponsor to PQ.