[iqiyi] Fix playlist detection (#12504)
authorYen Chi Hsuan <yan12125@gmail.com>
Sat, 22 Apr 2017 14:11:37 +0000 (22:11 +0800)
committerYen Chi Hsuan <yan12125@gmail.com>
Sat, 22 Apr 2017 14:11:37 +0000 (22:11 +0800)
ChangeLog
youtube_dl/extractor/iqiyi.py

index 8dc6e6857508e3cc9d0b25b8a8c39494f668d609..50daa1a690d1e16d5cf2d00f2603b45805cc0caf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@ Core
 * [socks] Handle cases where credentials are required but missing
 
 Extractors
+* [iqiyi] Fix playlist detection (#12504)
 - [azubu] Remove extractor (#12813)
 * [porn91] Fix extraction (#12814)
 + [generic] Support Brightcove videos in <iframe> (#12482)
index 2af6a6db4da0dd5186436672ae95905c9612df6a..8a711afb92dbdccd04548361131e4ad47224d6a8 100644 (file)
@@ -337,13 +337,16 @@ class IqiyiIE(InfoExtractor):
             url, 'temp_id', note='download video page')
 
         # There's no simple way to determine whether an URL is a playlist or not
-        # So detect it
-        playlist_result = self._extract_playlist(webpage)
-        if playlist_result:
-            return playlist_result
-
+        # Sometimes there are playlist links in individual videos, so treat it
+        # as a single video first
         tvid = self._search_regex(
-            r'data-player-tvid\s*=\s*[\'"](\d+)', webpage, 'tvid')
+            r'data-player-tvid\s*=\s*[\'"](\d+)', webpage, 'tvid', default=None)
+        if tvid is None:
+            playlist_result = self._extract_playlist(webpage)
+            if playlist_result:
+                return playlist_result
+            raise ExtractorError('Can\'t find any video')
+
         video_id = self._search_regex(
             r'data-player-videoid\s*=\s*[\'"]([a-f\d]+)', webpage, 'video_id')