瀏覽代碼

[tudou] Extract player URL from the webpage

Sergey M․ 10 年之前
父節點
當前提交
238755752f
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      youtube_dl/extractor/tudou.py

+ 6 - 2
youtube_dl/extractor/tudou.py

@@ -30,7 +30,7 @@ class TudouIE(InfoExtractor):
     }]
     }]
 
 
     _PLAYER_URL = 'http://js.tudouui.com/bin/lingtong/PortalPlayer_177.swf'
     _PLAYER_URL = 'http://js.tudouui.com/bin/lingtong/PortalPlayer_177.swf'
-	
+
     def _url_for_id(self, id, quality=None):
     def _url_for_id(self, id, quality=None):
         info_url = "http://v2.tudou.com/f?id=" + str(id)
         info_url = "http://v2.tudou.com/f?id=" + str(id)
         if quality:
         if quality:
@@ -56,6 +56,10 @@ class TudouIE(InfoExtractor):
         thumbnail_url = self._search_regex(
         thumbnail_url = self._search_regex(
             r",pic:\s*[\"'](.+?)[\"']", webpage, 'thumbnail URL', fatal=False)
             r",pic:\s*[\"'](.+?)[\"']", webpage, 'thumbnail URL', fatal=False)
 
 
+        player_url = self._search_regex(
+            r"playerUrl\s*:\s*['\"](.+?\.swf)[\"']",
+            webpage, 'player URL', default=self._PLAYER_URL)
+
         segs_json = self._search_regex(r'segs: \'(.*)\'', webpage, 'segments')
         segs_json = self._search_regex(r'segs: \'(.*)\'', webpage, 'segments')
         segments = json.loads(segs_json)
         segments = json.loads(segs_json)
         # It looks like the keys are the arguments that have to be passed as
         # It looks like the keys are the arguments that have to be passed as
@@ -79,7 +83,7 @@ class TudouIE(InfoExtractor):
                 'title': title,
                 'title': title,
                 'thumbnail': thumbnail_url,
                 'thumbnail': thumbnail_url,
                 'http_headers': {
                 'http_headers': {
-                    'Referer': self._PLAYER_URL,
+                    'Referer': player_url,
                 },
                 },
             }
             }
             result.append(part_info)
             result.append(part_info)