mirror of https://github.com/blackjack4494/yt-dlc
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
3.2 KiB
Python
90 lines
3.2 KiB
Python
9 years ago
|
# coding: utf-8
|
||
|
from __future__ import unicode_literals
|
||
|
|
||
|
import re
|
||
|
|
||
9 years ago
|
from .common import InfoExtractor
|
||
4 years ago
|
from ..utils import (
|
||
|
int_or_none,
|
||
|
parse_iso8601,
|
||
|
str_or_none,
|
||
|
strip_or_none,
|
||
|
try_get,
|
||
|
)
|
||
9 years ago
|
|
||
|
|
||
|
class VidioIE(InfoExtractor):
|
||
9 years ago
|
_VALID_URL = r'https?://(?:www\.)?vidio\.com/watch/(?P<id>\d+)-(?P<display_id>[^/?#&]+)'
|
||
|
_TESTS = [{
|
||
9 years ago
|
'url': 'http://www.vidio.com/watch/165683-dj_ambred-booyah-live-2015',
|
||
9 years ago
|
'md5': 'cd2801394afc164e9775db6a140b91fe',
|
||
9 years ago
|
'info_dict': {
|
||
|
'id': '165683',
|
||
9 years ago
|
'display_id': 'dj_ambred-booyah-live-2015',
|
||
9 years ago
|
'ext': 'mp4',
|
||
9 years ago
|
'title': 'DJ_AMBRED - Booyah (Live 2015)',
|
||
9 years ago
|
'description': 'md5:27dc15f819b6a78a626490881adbadf8',
|
||
8 years ago
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||
9 years ago
|
'duration': 149,
|
||
|
'like_count': int,
|
||
4 years ago
|
'uploader': 'TWELVE Pic',
|
||
|
'timestamp': 1444902800,
|
||
|
'upload_date': '20151015',
|
||
|
'uploader_id': 'twelvepictures',
|
||
|
'channel': 'Cover Music Video',
|
||
|
'channel_id': '280236',
|
||
|
'view_count': int,
|
||
|
'dislike_count': int,
|
||
|
'comment_count': int,
|
||
|
'tags': 'count:4',
|
||
9 years ago
|
},
|
||
9 years ago
|
}, {
|
||
|
'url': 'https://www.vidio.com/watch/77949-south-korea-test-fires-missile-that-can-strike-all-of-the-north',
|
||
|
'only_matching': True,
|
||
|
}]
|
||
9 years ago
|
|
||
4 years ago
|
def _real_initialize(self):
|
||
|
self._api_key = self._download_json(
|
||
|
'https://www.vidio.com/auth', None, data=b'')['api_key']
|
||
9 years ago
|
|
||
4 years ago
|
def _real_extract(self, url):
|
||
|
video_id, display_id = re.match(self._VALID_URL, url).groups()
|
||
|
data = self._download_json(
|
||
|
'https://api.vidio.com/videos/' + video_id, display_id, headers={
|
||
|
'Content-Type': 'application/vnd.api+json',
|
||
|
'X-API-KEY': self._api_key,
|
||
|
})
|
||
|
video = data['videos'][0]
|
||
|
title = video['title'].strip()
|
||
9 years ago
|
|
||
8 years ago
|
formats = self._extract_m3u8_formats(
|
||
4 years ago
|
data['clips'][0]['hls_url'], display_id, 'mp4', 'm3u8_native')
|
||
8 years ago
|
self._sort_formats(formats)
|
||
9 years ago
|
|
||
4 years ago
|
get_first = lambda x: try_get(data, lambda y: y[x + 's'][0], dict) or {}
|
||
|
channel = get_first('channel')
|
||
|
user = get_first('user')
|
||
|
username = user.get('username')
|
||
|
get_count = lambda x: int_or_none(video.get('total_' + x))
|
||
9 years ago
|
|
||
|
return {
|
||
|
'id': video_id,
|
||
9 years ago
|
'display_id': display_id,
|
||
|
'title': title,
|
||
4 years ago
|
'description': strip_or_none(video.get('description')),
|
||
|
'thumbnail': video.get('image_url_medium'),
|
||
|
'duration': int_or_none(video.get('duration')),
|
||
|
'like_count': get_count('likes'),
|
||
9 years ago
|
'formats': formats,
|
||
4 years ago
|
'uploader': user.get('name'),
|
||
|
'timestamp': parse_iso8601(video.get('created_at')),
|
||
|
'uploader_id': username,
|
||
|
'uploader_url': 'https://www.vidio.com/@' + username if username else None,
|
||
|
'channel': channel.get('name'),
|
||
|
'channel_id': str_or_none(channel.get('id')),
|
||
|
'view_count': get_count('view_count'),
|
||
|
'dislike_count': get_count('dislikes'),
|
||
|
'comment_count': get_count('comments'),
|
||
|
'tags': video.get('tag_list'),
|
||
9 years ago
|
}
|