]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vlive.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  10 from ..compat 
import compat_urllib_parse
 
  13 class VLiveIE(InfoExtractor
): 
  15     _VALID_URL 
= r
'https?://(?:(?:www|m)\.)?vlive\.tv/video/(?P<id>[0-9]+)' 
  17         'url': 'http://www.vlive.tv/video/1326', 
  18         'md5': 'cc7314812855ce56de70a06a27314983', 
  22             'title': "[V] Girl's Day's Broadcast", 
  23             'creator': "Girl's Day", 
  28     def _real_extract(self
, url
): 
  29         video_id 
= self
._match
_id
(url
) 
  31         webpage 
= self
._download
_webpage
( 
  32             'http://www.vlive.tv/video/%s' % video_id
, video_id
) 
  34         long_video_id 
= self
._search
_regex
( 
  35             r
'vlive\.tv\.video\.ajax\.request\.handler\.init\(\s*"[0-9]+"\s*,\s*"[^"]*"\s*,\s*"([^"]+)"', 
  36             webpage
, 'long video id') 
  38         key 
= self
._search
_regex
( 
  39             r
'vlive\.tv\.video\.ajax\.request\.handler\.init\(\s*"[0-9]+"\s*,\s*"[^"]*"\s*,\s*"[^"]+"\s*,\s*"([^"]+)"', 
  42         title 
= self
._og
_search
_title
(webpage
) 
  44         playinfo 
= self
._download
_json
( 
  45             'http://global.apis.naver.com/rmcnmv/rmcnmv/vod_play_videoInfo.json?%s' 
  46             % compat_urllib_parse
.urlencode({ 
  47                 'videoId': long_video_id
, 
  50                 'doct': 'json',  # document type (xml or json) 
  51                 'cpt': 'vtt',  # captions type (vtt or ttml) 
  56             'format_id': vid
.get('encodingOption', {}).get('name'), 
  57             'abr': float_or_none(vid
.get('bitrate', {}).get('audio')), 
  58             'vbr': float_or_none(vid
.get('bitrate', {}).get('video')), 
  59             'width': int_or_none(vid
.get('encodingOption', {}).get('width')), 
  60             'height': int_or_none(vid
.get('encodingOption', {}).get('height')), 
  61             'filesize': int_or_none(vid
.get('size')), 
  62         } for vid 
in playinfo
.get('videos', {}).get('list', []) if vid
.get('source')] 
  63         self
._sort
_formats
(formats
) 
  65         thumbnail 
= self
._og
_search
_thumbnail
(webpage
) 
  66         creator 
= self
._html
_search
_regex
( 
  67             r
'<div[^>]+class="info_area"[^>]*>\s*<strong[^>]+class="name"[^>]*>([^<]+)</strong>', 
  68             webpage
, 'creator', fatal
=False) 
  70         view_count 
= int_or_none(playinfo
.get('meta', {}).get('count')) 
  73         for caption 
in playinfo
.get('captions', {}).get('list', []): 
  74             lang 
= dict_get(caption
, ('language', 'locale', 'country', 'label')) 
  75             if lang 
and caption
.get('source'): 
  78                     'url': caption
['source']}] 
  84             'thumbnail': thumbnail
, 
  85             'view_count': view_count
, 
  87             'subtitles': subtitles
,