From 7b17cbc1533cc9b4c73074e13f854de98aa46ebd Mon Sep 17 00:00:00 2001 From: JianxinLi Date: Mon, 1 Jan 2018 19:31:51 +0800 Subject: [PATCH 1/2] [youku] Fix list extraction.(close #15135) Change-Id: I2e9c920143f4f16012252625943a8f18b8ff40eb --- youtube_dl/extractor/youku.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/youku.py b/youtube_dl/extractor/youku.py index c7947d4a1..a533d654d 100644 --- a/youtube_dl/extractor/youku.py +++ b/youtube_dl/extractor/youku.py @@ -245,13 +245,20 @@ class YoukuShowIE(InfoExtractor): # No data-id value. 'url': 'http://list.youku.com/show/id_zefbfbd61237fefbfbdef.html', 'only_matching': True, + }, { + # Wrong number of reload_id. + 'url': 'http://list.youku.com/show/id_z20eb4acaf5c211e3b2ad.html', + 'only_matching': True, }] def _extract_entries(self, playlist_data_url, show_id, note, query): query['callback'] = 'cb' - playlist_data = self._download_json( - playlist_data_url, show_id, query=query, note=note, - transform_source=lambda s: js_to_json(strip_jsonp(s)))['html'] + try: + playlist_data = self._download_json( + playlist_data_url, show_id, query=query, note=note, + transform_source=lambda s: js_to_json(strip_jsonp(s)))['html'] + except KeyError: + return [None, None] drama_list = (get_element_by_class('p-drama-grid', playlist_data) or get_element_by_class('p-drama-half-row', playlist_data)) if drama_list is None: @@ -291,8 +298,8 @@ class YoukuShowIE(InfoExtractor): 'id': page_config['showid'], 'stage': reload_id, }) - entries.extend(new_entries) - + if new_entries is not None: + entries.extend(new_entries) desc = self._html_search_meta('description', webpage, fatal=False) playlist_title = desc.split(',')[0] if desc else None detail_li = get_element_by_class('p-intro', webpage) From f824c42a6c2e5fbde60c5657200e227419f760be Mon Sep 17 00:00:00 2001 From: JianxinLi Date: Thu, 4 Jan 2018 22:06:39 +0800 Subject: [PATCH 2/2] [youku] Remove KeyError try-except Change-Id: Ic46327905cbef1356b7b12d5eb3db5d9746ca338 --- youtube_dl/extractor/youku.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/youku.py b/youtube_dl/extractor/youku.py index a533d654d..5b0b248cd 100644 --- a/youtube_dl/extractor/youku.py +++ b/youtube_dl/extractor/youku.py @@ -253,11 +253,10 @@ class YoukuShowIE(InfoExtractor): def _extract_entries(self, playlist_data_url, show_id, note, query): query['callback'] = 'cb' - try: - playlist_data = self._download_json( - playlist_data_url, show_id, query=query, note=note, - transform_source=lambda s: js_to_json(strip_jsonp(s)))['html'] - except KeyError: + playlist_data = self._download_json( + playlist_data_url, show_id, query=query, note=note, + transform_source=lambda s: js_to_json(strip_jsonp(s))).get('html') + if playlist_data is None: return [None, None] drama_list = (get_element_by_class('p-drama-grid', playlist_data) or get_element_by_class('p-drama-half-row', playlist_data))