From: Sergey M․ Date: Thu, 1 Jun 2017 16:29:45 +0000 (+0700) Subject: [youtube] Improve chapters extraction (closes #13247) X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=39d4c1be4d601a3297157315652637ca52000965;p=youtube-dl [youtube] Improve chapters extraction (closes #13247) --- diff --git a/test/test_youtube_chapters.py b/test/test_youtube_chapters.py index cb12f8384..324ca8525 100644 --- a/test/test_youtube_chapters.py +++ b/test/test_youtube_chapters.py @@ -254,6 +254,13 @@ class TestYoutubeChapters(unittest.TestCase): 'title': '3 - Из серпов луны...[Iz serpov luny]', }] ), + ( + # https://www.youtube.com/watch?v=xZW70zEasOk + # time point more than duration + '''● LCS Spring finals: Saturday and Sunday from 13:30 outside the venue!
● PAX East: Fri, Sat & Sun - more info in tomorrows video on the main channel!''', + 283, + [] + ), ] def test_youtube_chapters(self): diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index 40ac1a019..bf4f4e139 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -1353,10 +1353,16 @@ class YoutubeIE(YoutubeBaseInfoExtractor): start_time = parse_duration(time_point) if start_time is None: continue + if start_time > duration: + break end_time = (duration if next_num == len(chapter_lines) else parse_duration(chapter_lines[next_num][1])) if end_time is None: continue + if end_time > duration: + end_time = duration + if start_time > end_time: + break chapter_title = re.sub( r']+>[^<]+', '', chapter_line).strip(' \t-') chapter_title = re.sub(r'\s+', ' ', chapter_title)