2 from __future__ import unicode_literals
6 from .common import InfoExtractor
16 class VidioIE(InfoExtractor):
17 _VALID_URL = r'https?://(?:www\.)?vidio\.com/watch/(?P<id>\d+)-(?P<display_id>[^/?#&]+)'
19 'url': 'http://www.vidio.com/watch/165683-dj_ambred-booyah-live-2015',
20 'md5': 'cd2801394afc164e9775db6a140b91fe',
23 'display_id': 'dj_ambred-booyah-live-2015',
25 'title': 'DJ_AMBRED - Booyah (Live 2015)',
26 'description': 'md5:27dc15f819b6a78a626490881adbadf8',
27 'thumbnail': r're:^https?://.*\.jpg$',
30 'uploader': 'TWELVE Pic',
31 'timestamp': 1444902800,
32 'upload_date': '20151015',
33 'uploader_id': 'twelvepictures',
34 'channel': 'Cover Music Video',
35 'channel_id': '280236',
42 'url': 'https://www.vidio.com/watch/77949-south-korea-test-fires-missile-that-can-strike-all-of-the-north',
43 'only_matching': True,
46 def _real_initialize(self):
47 self._api_key = self._download_json(
48 'https://www.vidio.com/auth', None, data=b'')['api_key']
50 def _real_extract(self, url):
51 video_id, display_id = re.match(self._VALID_URL, url).groups()
52 data = self._download_json(
53 'https://api.vidio.com/videos/' + video_id, display_id, headers={
54 'Content-Type': 'application/vnd.api+json',
55 'X-API-KEY': self._api_key,
57 video = data['videos'][0]
58 title = video['title'].strip()
60 formats = self._extract_m3u8_formats(
61 data['clips'][0]['hls_url'], display_id, 'mp4', 'm3u8_native')
62 self._sort_formats(formats)
64 get_first = lambda x: try_get(data, lambda y: y[x + 's'][0], dict) or {}
65 channel = get_first('channel')
66 user = get_first('user')
67 username = user.get('username')
68 get_count = lambda x: int_or_none(video.get('total_' + x))
72 'display_id': display_id,
74 'description': strip_or_none(video.get('description')),
75 'thumbnail': video.get('image_url_medium'),
76 'duration': int_or_none(video.get('duration')),
77 'like_count': get_count('likes'),
79 'uploader': user.get('name'),
80 'timestamp': parse_iso8601(video.get('created_at')),
81 'uploader_id': username,
82 'uploader_url': 'https://www.vidio.com/@' + username if username else None,
83 'channel': channel.get('name'),
84 'channel_id': str_or_none(channel.get('id')),
85 'view_count': get_count('view_count'),
86 'dislike_count': get_count('dislikes'),
87 'comment_count': get_count('comments'),
88 'tags': video.get('tag_list'),