]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/c56.py
update changelog.
[youtubedl] / youtube_dl / extractor / c56.py
1 # coding: utf-8
2
3 import re
4 import json
5
6 from .common import InfoExtractor
7 from ..utils import determine_ext
8
9 class C56IE(InfoExtractor):
10 _VALID_URL = r'https?://((www|player)\.)?56\.com/(.+?/)?(v_|(play_album.+-))(?P<textid>.+?)\.(html|swf)'
11 IE_NAME = u'56.com'
12
13 _TEST ={
14 u'url': u'http://www.56.com/u39/v_OTM0NDA3MTY.html',
15 u'file': u'93440716.flv',
16 u'md5': u'e59995ac63d0457783ea05f93f12a866',
17 u'info_dict': {
18 u'title': u'网事知多少 第32期:车怒',
19 },
20 }
21
22 def _real_extract(self, url):
23 mobj = re.match(self._VALID_URL, url, flags=re.VERBOSE)
24 text_id = mobj.group('textid')
25 info_page = self._download_webpage('http://vxml.56.com/json/%s/' % text_id,
26 text_id, u'Downloading video info')
27 info = json.loads(info_page)['info']
28 best_format = sorted(info['rfiles'], key=lambda f: int(f['filesize']))[-1]
29 video_url = best_format['url']
30
31 return {'id': info['vid'],
32 'title': info['Subject'],
33 'url': video_url,
34 'ext': determine_ext(video_url),
35 'thumbnail': info.get('bimg') or info.get('img'),
36 }