# request basic data
basic_data_params = {
'vid': video_id,
- 'ccode': '0402' if 'tudou.com' in url else '0401',
+ 'ccode': '0507',
'client_ip': '192.168.1.1',
'utid': cna,
'client_ts': time.time() / 1000,
}, {
# Ongoing playlist. The initial page is the last one
'url': 'http://list.youku.com/show/id_za7c275ecd7b411e1a19e.html',
- 'only_matchine': True,
+ 'only_matching': True,
+ }, {
+ # 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']
+ 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))
if drama_list is None:
r'<div[^>]+id="(reload_\d+)', first_page, 'first page reload id')
# The first reload_id has the same items as first_page
reload_ids = re.findall('<li[^>]+data-id="([^"]+)">', first_page)
+ entries.extend(initial_entries)
for idx, reload_id in enumerate(reload_ids):
if reload_id == first_page_reload_id:
- entries.extend(initial_entries)
continue
_, new_entries = self._extract_entries(
'http://list.youku.com/show/episode', show_id,
'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)