From e129469557d16e716f27bca5c826e103308667b1 Mon Sep 17 00:00:00 2001 From: Luc Ritchie Date: Mon, 1 Jan 2018 18:34:17 -0500 Subject: [PATCH 1/2] [twitch] Determine ids from URLs when extracting playlist This allows videos to be filtered using download_archive without needing to fetch the info JSON for each video. --- youtube_dl/extractor/twitch.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/twitch.py b/youtube_dl/extractor/twitch.py index bf57eac01..90a2245f6 100644 --- a/youtube_dl/extractor/twitch.py +++ b/youtube_dl/extractor/twitch.py @@ -358,9 +358,17 @@ class TwitchPlaylistBaseIE(TwitchBaseIE): break offset += limit return self.playlist_result( - [self.url_result(entry) for entry in orderedSet(entries)], + [self._make_url_result(entry) for entry in orderedSet(entries)], channel_id, channel_name) + def _make_url_result(self, url): + try: + video_id = 'v%s' % TwitchVodIE._match_id(url) + return self.url_result(url, TwitchVodIE.ie_key(), video_id=video_id) + except AssertionError: + self.to_screen('Unable to match video ID from URL: %s' % url) + return self.url_result(url) + def _extract_playlist_page(self, response): videos = response.get('videos') return [video['url'] for video in videos] if videos else [] From eb26087326d5a4ec948e2de0ba3bf79f9ec6e78c Mon Sep 17 00:00:00 2001 From: Luc Ritchie Date: Tue, 2 Jan 2018 13:22:39 -0500 Subject: [PATCH 2/2] [twitch] Drop log line if id can't be extracted from URL --- youtube_dl/extractor/twitch.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/youtube_dl/extractor/twitch.py b/youtube_dl/extractor/twitch.py index 90a2245f6..f9164af09 100644 --- a/youtube_dl/extractor/twitch.py +++ b/youtube_dl/extractor/twitch.py @@ -366,8 +366,7 @@ class TwitchPlaylistBaseIE(TwitchBaseIE): video_id = 'v%s' % TwitchVodIE._match_id(url) return self.url_result(url, TwitchVodIE.ie_key(), video_id=video_id) except AssertionError: - self.to_screen('Unable to match video ID from URL: %s' % url) - return self.url_result(url) + return self.url_result(url) def _extract_playlist_page(self, response): videos = response.get('videos')