Merge branch 'master' of https://github.com/linhua55/youtube-dl into linhua55-master
authorYen Chi Hsuan <yan12125@gmail.com>
Sat, 12 Sep 2015 14:41:51 +0000 (22:41 +0800)
committerYen Chi Hsuan <yan12125@gmail.com>
Sat, 12 Sep 2015 14:41:51 +0000 (22:41 +0800)
1  2 
youtube_dl/extractor/tudou.py

index 84fe71aef8501dcd9055dc517ae9097844d99a5d,8095e18d2838bebaa9ce1b4db00af218595348c2..e800477e2c1014593df0763b9806c21ff73dd3f9
@@@ -9,7 -9,7 +9,7 @@@ from .common import InfoExtracto
  
  
  class TudouIE(InfoExtractor):
-     _VALID_URL = r'https?://(?:www\.)?tudou\.com/(?:listplay|programs(?:/view)?|albumplay)/.*?/(?P<id>[^/?#]+?)(?:\.html)?/?(?:$|[?#])'
+     _VALID_URL = r'https?://(?:www\.)?tudou\.com/(?:listplay|programs(?:/view)?|albumplay)/?.*/(?P<id>[^/?#]+?)(?:\.html)?/?(?:$|[?#])'
      _TESTS = [{
          'url': 'http://www.tudou.com/listplay/zzdE77v6Mmo/2xN2duXMxmw.html',
          'md5': '140a49ed444bd22f93330985d8475fcb',
@@@ -29,8 -29,6 +29,8 @@@
          }
      }]
  
 +    _PLAYER_URL = 'http://js.tudouui.com/bin/lingtong/PortalPlayer_177.swf'
 +
      def _url_for_id(self, id, quality=None):
          info_url = "http://v2.tudou.com/f?id=" + str(id)
          if quality:
          thumbnail_url = self._search_regex(
              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')
          segments = json.loads(segs_json)
          # It looks like the keys are the arguments that have to be passed as
@@@ -82,9 -76,6 +82,9 @@@
                  'ext': ext,
                  'title': title,
                  'thumbnail': thumbnail_url,
 +                'http_headers': {
 +                    'Referer': player_url,
 +                },
              }
              result.append(part_info)