]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/c56.py
Imported Upstream version 2014.08.05
[youtubedl] / youtube_dl / extractor / c56.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7
8
9 class C56IE(InfoExtractor):
10 _VALID_URL = r'https?://(?:(?:www|player)\.)?56\.com/(?:.+?/)?(?:v_|(?:play_album.+-))(?P<textid>.+?)\.(?:html|swf)'
11 IE_NAME = '56.com'
12 _TEST = {
13 'url': 'http://www.56.com/u39/v_OTM0NDA3MTY.html',
14 'md5': 'e59995ac63d0457783ea05f93f12a866',
15 'info_dict': {
16 'id': '93440716',
17 'ext': 'flv',
18 'title': '网事知多少 第32期:车怒',
19 'duration': 283.813,
20 },
21 }
22
23 def _real_extract(self, url):
24 mobj = re.match(self._VALID_URL, url, flags=re.VERBOSE)
25 text_id = mobj.group('textid')
26
27 page = self._download_json(
28 'http://vxml.56.com/json/%s/' % text_id, text_id, 'Downloading video info')
29
30 info = page['info']
31
32 formats = [
33 {
34 'format_id': f['type'],
35 'filesize': int(f['filesize']),
36 'url': f['url']
37 } for f in info['rfiles']
38 ]
39 self._sort_formats(formats)
40
41 return {
42 'id': info['vid'],
43 'title': info['Subject'],
44 'duration': int(info['duration']) / 1000.0,
45 'formats': formats,
46 'thumbnail': info.get('bimg') or info.get('img'),
47 }