]> jfr.im git - yt-dlp.git/commitdiff
[extractor] Do not warn for invalid chapter data in description
authorpukkandan <redacted>
Sat, 15 Apr 2023 21:46:23 +0000 (03:16 +0530)
committerpukkandan <redacted>
Sun, 16 Apr 2023 03:25:43 +0000 (08:55 +0530)
Fixes https://github.com/yt-dlp/yt-dlp/issues/6811#issuecomment-1509876209

yt_dlp/extractor/common.py

index 838899052c762b29702a398e64cb61862b23349c..78288f8091c95458479d8241d2b35a4afea6a657 100644 (file)
@@ -3658,18 +3658,22 @@ def _extract_chapters_helper(self, chapter_list, start_function, title_function,
             'start_time': start_function(chapter),
             'title': title_function(chapter),
         } for chapter in chapter_list or []]
-        if not strict:
+        if strict:
+            warn = self.report_warning
+        else:
+            warn = self.write_debug
             chapter_list.sort(key=lambda c: c['start_time'] or 0)
 
         chapters = [{'start_time': 0}]
         for idx, chapter in enumerate(chapter_list):
             if chapter['start_time'] is None:
-                self.report_warning(f'Incomplete chapter {idx}')
+                warn(f'Incomplete chapter {idx}')
             elif chapters[-1]['start_time'] <= chapter['start_time'] <= duration:
                 chapters.append(chapter)
             elif chapter not in chapters:
-                self.report_warning(
-                    f'Invalid start time ({chapter["start_time"]} < {chapters[-1]["start_time"]}) for chapter "{chapter["title"]}"')
+                issue = (f'{chapter["start_time"]} > {duration}' if chapter['start_time'] > duration
+                         else f'{chapter["start_time"]} < {chapters[-1]["start_time"]}')
+                warn(f'Invalid start time ({issue}) for chapter "{chapter["title"]}"')
         return chapters[1:]
 
     def _extract_chapters_from_description(self, description, duration):