From 66130655ea1801469702e6225a2b05e1fa737f28 Mon Sep 17 00:00:00 2001 From: oittaa Date: Thu, 7 Jan 2016 05:35:32 +0200 Subject: [PATCH 1/2] Don't add broken video formats from Crunchyroll Fixes #7930 - Error downloading some videos from crunchyroll -- TypeError: argument of type 'NoneType' is not iterable --- youtube_dl/extractor/crunchyroll.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/youtube_dl/extractor/crunchyroll.py b/youtube_dl/extractor/crunchyroll.py index 00d943f77..abd49e25c 100644 --- a/youtube_dl/extractor/crunchyroll.py +++ b/youtube_dl/extractor/crunchyroll.py @@ -338,6 +338,9 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text 'height': int_or_none(xpath_text(metadata, './height')), 'width': int_or_none(xpath_text(metadata, './width')), } + + if video_url is None: + continue if '.fplive.net/' in video_url: video_url = re.sub(r'^rtmpe?://', 'http://', video_url.strip()) From 2cbdf8c3a7e6b1b720235753e931e0d09dae9afd Mon Sep 17 00:00:00 2001 From: oittaa Date: Thu, 7 Jan 2016 07:26:14 +0200 Subject: [PATCH 2/2] check video_play_path and use xpath_text "This check should take place earlier and should be more general if not video_url:. Same should be done for video_play_path. Also these fields better extracted with xpath_text." Suggestions by @dstftw --- youtube_dl/extractor/crunchyroll.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/crunchyroll.py b/youtube_dl/extractor/crunchyroll.py index abd49e25c..785594df8 100644 --- a/youtube_dl/extractor/crunchyroll.py +++ b/youtube_dl/extractor/crunchyroll.py @@ -329,8 +329,10 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text streamdata_req, video_id, note='Downloading media info for %s' % video_format) stream_info = streamdata.find('./{default}preload/stream_info') - video_url = stream_info.find('./host').text - video_play_path = stream_info.find('./file').text + video_url = xpath_text(stream_info, './host') + video_play_path = xpath_text(stream_info, './file') + if not video_url or not video_play_path: + continue metadata = stream_info.find('./metadata') format_info = { 'format': video_format, @@ -338,9 +340,6 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text 'height': int_or_none(xpath_text(metadata, './height')), 'width': int_or_none(xpath_text(metadata, './width')), } - - if video_url is None: - continue if '.fplive.net/' in video_url: video_url = re.sub(r'^rtmpe?://', 'http://', video_url.strip())