From ad607f20a87e61e34f307823087d64f4ed7da6dd Mon Sep 17 00:00:00 2001 From: remitamine Date: Sat, 10 Oct 2015 12:28:12 +0100 Subject: [PATCH 1/2] [adultswim] detect when video needs authentication --- youtube_dl/extractor/adultswim.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/adultswim.py b/youtube_dl/extractor/adultswim.py index 27de07587..0eb21b16d 100644 --- a/youtube_dl/extractor/adultswim.py +++ b/youtube_dl/extractor/adultswim.py @@ -41,7 +41,8 @@ class AdultSwimIE(InfoExtractor): 'id': 'rQxZvXQ4ROaSOqq-or2Mow', 'title': 'Rick and Morty - Pilot', 'description': "Rick moves in with his daughter's family and establishes himself as a bad influence on his grandson, Morty. " - } + }, + 'skip': 'This video is only available for registered users', }, { 'url': 'http://www.adultswim.com/videos/playlists/american-parenting/putting-francine-out-of-business/', 'playlist': [ @@ -84,7 +85,10 @@ class AdultSwimIE(InfoExtractor): def find_video_info(collection, slug): for video in collection.get('videos'): if video.get('slug') == slug: - return video + if video.get('auth'): + raise ExtractorError('This video is only available for registered users', expected=True) + else: + return video @staticmethod def find_collection_by_linkURL(collections, linkURL): @@ -97,7 +101,10 @@ class AdultSwimIE(InfoExtractor): for collection in collections: for video in collection.get('videos'): if video.get('slug') == slug: - return collection, video + if video.get('auth'): + raise ExtractorError('This video is only available for registered users', expected=True) + else: + return collection, video return None, None def _real_extract(self, url): @@ -128,6 +135,8 @@ class AdultSwimIE(InfoExtractor): if video_info is None: if bootstrapped_data.get('slugged_video', {}).get('slug') == episode_path: video_info = bootstrapped_data['slugged_video'] + if video_info.get('auth'): + raise ExtractorError('This video is only available for registered users', expected=True) else: raise ExtractorError('Unable to find video info') From bda1b53ae37e8e250d446c70d99557eea141f709 Mon Sep 17 00:00:00 2001 From: remitamine Date: Sat, 10 Oct 2015 17:57:05 +0100 Subject: [PATCH 2/2] [adultswim] raise ExtractorError if no clips in video_info --- youtube_dl/extractor/adultswim.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/youtube_dl/extractor/adultswim.py b/youtube_dl/extractor/adultswim.py index 0eb21b16d..35606878d 100644 --- a/youtube_dl/extractor/adultswim.py +++ b/youtube_dl/extractor/adultswim.py @@ -85,10 +85,7 @@ class AdultSwimIE(InfoExtractor): def find_video_info(collection, slug): for video in collection.get('videos'): if video.get('slug') == slug: - if video.get('auth'): - raise ExtractorError('This video is only available for registered users', expected=True) - else: - return video + return video @staticmethod def find_collection_by_linkURL(collections, linkURL): @@ -101,10 +98,7 @@ class AdultSwimIE(InfoExtractor): for collection in collections: for video in collection.get('videos'): if video.get('slug') == slug: - if video.get('auth'): - raise ExtractorError('This video is only available for registered users', expected=True) - else: - return collection, video + return collection, video return None, None def _real_extract(self, url): @@ -135,15 +129,18 @@ class AdultSwimIE(InfoExtractor): if video_info is None: if bootstrapped_data.get('slugged_video', {}).get('slug') == episode_path: video_info = bootstrapped_data['slugged_video'] - if video_info.get('auth'): - raise ExtractorError('This video is only available for registered users', expected=True) else: raise ExtractorError('Unable to find video info') show = bootstrapped_data['show'] show_title = show['title'] stream = video_info.get('stream') - clips = [stream] if stream else video_info['clips'] + clips = [stream] if stream else video_info.get('clips') + if not clips: + if video_info.get('auth'): + raise ExtractorError('This video is only available for registered users', expected=True) + else: + raise ExtractorError('Unable to find clips') segment_ids = [clip['videoPlaybackID'] for clip in clips] episode_id = video_info['id']