2
from __future__ import unicode_literals
5
from hashlib import sha1
6
from base64 import b64encode
9
from .common import InfoExtractor
14
from ..compat import compat_urllib_parse
17
class VLiveIE(InfoExtractor):
19
# www.vlive.tv/video/ links redirect to m.vlive.tv/video/ for mobile devices
20
_VALID_URL = r'https?://(?:(www|m)\.)?vlive\.tv/video/(?P<id>[0-9]+)'
22
'url': 'http://m.vlive.tv/video/1326',
23
'md5': 'cc7314812855ce56de70a06a27314983',
27
'title': '[V] Girl\'s Day\'s Broadcast',
28
'creator': 'Girl\'s Day',
31
_SECRET = 'rFkwZet6pqk1vQt6SxxUkAHX7YL3lmqzUMrU4IDusTo4jEBdtOhNfT4BYYAdArwH'
33
def _real_extract(self, url):
34
video_id = self._match_id(url)
36
webpage = self._download_webpage(
37
'http://m.vlive.tv/video/%s' % video_id,
38
video_id, note='Download video page')
40
title = self._og_search_title(webpage)
41
thumbnail = self._og_search_thumbnail(webpage)
42
creator = self._html_search_regex(
43
r'<span[^>]+class="name">([^<>]+)</span>', webpage, 'creator')
45
url = 'http://global.apis.naver.com/globalV/globalV/vod/%s/playinfo?' % video_id
46
msgpad = '%.0f' % (time() * 1000)
48
hmac.new(self._SECRET.encode('ascii'),
49
(url[:255] + msgpad).encode('ascii'), sha1).digest()
51
url += '&' + compat_urllib_parse.urlencode({'msgpad': msgpad, 'md': md})
52
playinfo = self._download_json(url, video_id, 'Downloading video json')
54
if playinfo.get('message', '') != 'success':
55
raise ExtractorError(playinfo.get('message', 'JSON request unsuccessful'))
57
if not playinfo.get('result'):
58
raise ExtractorError('No videos found.')
61
for vid in playinfo['result'].get('videos', {}).get('list', []):
65
'abr': vid.get('bitrate', {}).get('audio'),
66
'vbr': vid.get('bitrate', {}).get('video'),
67
'format_id': vid['encodingOption']['name'],
68
'height': vid.get('height'),
69
'width': vid.get('width'),
71
self._sort_formats(formats)
74
for caption in playinfo['result'].get('captions', {}).get('list', []):
75
subtitles[caption['language']] = [
76
{'ext': determine_ext(caption['source'], default_ext='vtt'),
77
'url': caption['source']}]
83
'thumbnail': thumbnail,
85
'subtitles': subtitles,