diff options
| author | Philipp Hagemeister <phihag@phihag.de> | 2014-09-01 00:16:26 +0200 | 
|---|---|---|
| committer | Philipp Hagemeister <phihag@phihag.de> | 2014-09-01 00:16:26 +0200 | 
| commit | 8bdfddf641b56731c8dcc864f8684e69e6b3fe3c (patch) | |
| tree | 4fd9a5ef9f8a8ea3ec823ce82164550dfd42dcee /youtube_dl/extractor/tudou.py | |
| parent | 36d65b61d4d7f39b66c89a61aecf431521d23f46 (diff) | |
[tudou] Modernize
Diffstat (limited to 'youtube_dl/extractor/tudou.py')
| -rw-r--r-- | youtube_dl/extractor/tudou.py | 48 | 
1 files changed, 25 insertions, 23 deletions
diff --git a/youtube_dl/extractor/tudou.py b/youtube_dl/extractor/tudou.py index 7a3891b89..3da9978b8 100644 --- a/youtube_dl/extractor/tudou.py +++ b/youtube_dl/extractor/tudou.py @@ -1,5 +1,7 @@  # coding: utf-8 +from __future__ import unicode_literals +  import re  import json @@ -9,22 +11,21 @@ from .common import InfoExtractor  class TudouIE(InfoExtractor):      _VALID_URL = r'(?:http://)?(?:www\.)?tudou\.com/(?:listplay|programs|albumplay)/(?:view|(.+?))/(?:([^/]+)|([^/]+))(?:\.html)?'      _TESTS = [{ -        u'url': u'http://www.tudou.com/listplay/zzdE77v6Mmo/2xN2duXMxmw.html', -        u'file': u'159448201.f4v', -        u'md5': u'140a49ed444bd22f93330985d8475fcb', -        u'info_dict': { -            u"title": u"卡马乔国足开大脚长传冲吊集锦" +        'url': 'http://www.tudou.com/listplay/zzdE77v6Mmo/2xN2duXMxmw.html', +        'md5': '140a49ed444bd22f93330985d8475fcb', +        'info_dict': { +            'id': '159448201', +            'ext': 'f4v', +            'title': '卡马乔国足开大脚长传冲吊集锦', +            'thumbnail': 're:^https?://.*\.jpg$',          } -    }, -    { -        u'url': u'http://www.tudou.com/albumplay/TenTw_JgiPM/PzsAs5usU9A.html', -        u'file': u'todo.mp4', -        u'md5': u'todo.mp4', -        u'info_dict': { -            u'title': u'todo.mp4', +    }, { +        'url': 'http://www.tudou.com/albumplay/TenTw_JgiPM/PzsAs5usU9A.html', +        'info_dict': { +            'title': 'todo.mp4',          }, -        u'add_ie': [u'Youku'], -        u'skip': u'Only works from China' +        'add_ie': ['Youku'], +        'skip': 'Only works from China'      }]      def _url_for_id(self, id, quality = None): @@ -44,14 +45,14 @@ class TudouIE(InfoExtractor):          if m and m.group(1):              return {                  '_type': 'url', -                'url': u'youku:' + m.group(1), +                'url': 'youku:' + m.group(1),                  'ie_key': 'Youku'              }          title = self._search_regex( -            r",kw:\s*['\"](.+?)[\"']", webpage, u'title') +            r",kw:\s*['\"](.+?)[\"']", webpage, 'title')          thumbnail_url = self._search_regex( -            r",pic:\s*[\"'](.+?)[\"']", webpage, u'thumbnail URL', fatal=False) +            r",pic:\s*[\"'](.+?)[\"']", webpage, 'thumbnail URL', fatal=False)          segs_json = self._search_regex(r'segs: \'(.*)\'', webpage, 'segments')          segments = json.loads(segs_json) @@ -67,12 +68,13 @@ class TudouIE(InfoExtractor):              part_id = part['k']              final_url = self._url_for_id(part_id, quality)              ext = (final_url.split('?')[0]).split('.')[-1] -            part_info = {'id': part_id, -                          'url': final_url, -                          'ext': ext, -                          'title': title, -                          'thumbnail': thumbnail_url, -                          } +            part_info = { +                'id': '%s' % part_id, +                'url': final_url, +                'ext': ext, +                'title': title, +                'thumbnail': thumbnail_url, +            }              result.append(part_info)          return result  | 
