diff --git a/youtube_dl/extractor/iqiyi.py b/youtube_dl/extractor/iqiyi.py index cd11aa70f..cf0ac8de2 100644 --- a/youtube_dl/extractor/iqiyi.py +++ b/youtube_dl/extractor/iqiyi.py @@ -19,6 +19,7 @@ from ..utils import ( ExtractorError, ohdave_rsa_encrypt, remove_start, + extract_attributes, ) @@ -306,10 +307,14 @@ class IqiyiIE(InfoExtractor): def _extract_playlist(self, webpage): PAGE_SIZE = 50 - links = re.findall( - r']+class="site-piclist_pic_link"[^>]+href="(http://www\.iqiyi\.com/.+\.html)"', - webpage) - if not links: + links = [] + for link in re.findall(r']+class="[^"]*site-piclist_pic_link[^"]*"[^>]*>', webpage): + attribs = extract_attributes(link) + # It must be a valid url, and links on the playlist page have NO title-Attribute in them + # (links to other videos on the video page have, so beware of that!) + if attribs['href'].startswith('http') and 'title' not in attribs: + links.append(attribs['href']) + if len(links) == 0: return album_id = self._search_regex( @@ -328,10 +333,13 @@ class IqiyiIE(InfoExtractor): errnote='Failed to download playlist page %d' % page_num) pagelist = self._parse_json( remove_start(pagelist_page, 'var tvInfoJs='), album_id) - vlist = pagelist['data']['vlist'] - for item in vlist: - entries.append(self.url_result(item['vurl'])) - if len(vlist) < PAGE_SIZE: + if 'data' in pagelist: + vlist = pagelist['data']['vlist'] + for item in vlist: + entries.append(self.url_result(item['vurl'])) + if len(vlist) < PAGE_SIZE: + break + else: break return self.playlist_result(entries, album_id, album_title)