]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/c56.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
   7 from ..utils 
import js_to_json
 
  10 class C56IE(InfoExtractor
): 
  11     _VALID_URL 
= r
'https?://(?:(?:www|player)\.)?56\.com/(?:.+?/)?(?:v_|(?:play_album.+-))(?P<textid>.+?)\.(?:html|swf)' 
  14         'url': 'http://www.56.com/u39/v_OTM0NDA3MTY.html', 
  15         'md5': 'e59995ac63d0457783ea05f93f12a866', 
  19             'title': '网事知多少 第32期:车怒', 
  23         'url': 'http://www.56.com/u47/v_MTM5NjQ5ODc2.html', 
  33     def _real_extract(self
, url
): 
  34         mobj 
= re
.match(self
._VALID
_URL
, url
, flags
=re
.VERBOSE
) 
  35         text_id 
= mobj
.group('textid') 
  37         webpage 
= self
._download
_webpage
(url
, text_id
) 
  38         sohu_video_info_str 
= self
._search
_regex
( 
  39             r
'var\s+sohuVideoInfo\s*=\s*({[^}]+});', webpage
, 'Sohu video info', default
=None) 
  40         if sohu_video_info_str
: 
  41             sohu_video_info 
= self
._parse
_json
( 
  42                 sohu_video_info_str
, text_id
, transform_source
=js_to_json
) 
  43             return self
.url_result(sohu_video_info
['url'], 'Sohu') 
  45         page 
= self
._download
_json
( 
  46             'http://vxml.56.com/json/%s/' % text_id
, text_id
, 'Downloading video info') 
  52                 'format_id': f
['type'], 
  53                 'filesize': int(f
['filesize']), 
  55             } for f 
in info
['rfiles'] 
  57         self
._sort
_formats
(formats
) 
  61             'title': info
['Subject'], 
  62             'duration': int(info
['duration']) / 1000.0, 
  64             'thumbnail': info
.get('bimg') or info
.get('img'),