2016-05-22 00:48:17 +09:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
2016-06-04 18:47:43 +09:00
|
|
|
from .common import InfoExtractor
|
2016-05-22 00:48:17 +09:00
|
|
|
from ..utils import int_or_none
|
|
|
|
|
|
|
|
|
|
|
|
class VidioIE(InfoExtractor):
|
2016-06-04 18:47:43 +09:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?vidio\.com/watch/(?P<id>\d+)-(?P<display_id>[^/?#&]+)'
|
|
|
|
_TESTS = [{
|
2016-05-22 00:48:17 +09:00
|
|
|
'url': 'http://www.vidio.com/watch/165683-dj_ambred-booyah-live-2015',
|
2016-06-04 18:47:43 +09:00
|
|
|
'md5': 'cd2801394afc164e9775db6a140b91fe',
|
2016-05-22 00:48:17 +09:00
|
|
|
'info_dict': {
|
|
|
|
'id': '165683',
|
2016-06-04 18:47:43 +09:00
|
|
|
'display_id': 'dj_ambred-booyah-live-2015',
|
2016-05-22 00:48:17 +09:00
|
|
|
'ext': 'mp4',
|
2016-06-04 18:47:43 +09:00
|
|
|
'title': 'DJ_AMBRED - Booyah (Live 2015)',
|
2016-05-22 00:48:17 +09:00
|
|
|
'description': 'md5:27dc15f819b6a78a626490881adbadf8',
|
2017-01-02 21:08:07 +09:00
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
2016-06-04 18:47:43 +09:00
|
|
|
'duration': 149,
|
|
|
|
'like_count': int,
|
2016-05-22 00:48:17 +09:00
|
|
|
},
|
2016-06-04 18:47:43 +09:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.vidio.com/watch/77949-south-korea-test-fires-missile-that-can-strike-all-of-the-north',
|
|
|
|
'only_matching': True,
|
|
|
|
}]
|
2016-05-22 00:48:17 +09:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
mobj = re.match(self._VALID_URL, url)
|
|
|
|
video_id, display_id = mobj.group('id', 'display_id')
|
|
|
|
|
|
|
|
webpage = self._download_webpage(url, display_id)
|
|
|
|
|
2016-06-04 18:47:43 +09:00
|
|
|
title = self._og_search_title(webpage)
|
|
|
|
|
|
|
|
m3u8_url, duration, thumbnail = [None] * 3
|
2016-05-22 00:48:17 +09:00
|
|
|
|
2016-06-04 18:47:43 +09:00
|
|
|
clips = self._parse_json(
|
|
|
|
self._html_search_regex(
|
|
|
|
r'data-json-clips\s*=\s*(["\'])(?P<data>\[.+?\])\1',
|
|
|
|
webpage, 'video data', default='[]', group='data'),
|
|
|
|
display_id, fatal=False)
|
|
|
|
if clips:
|
|
|
|
clip = clips[0]
|
|
|
|
m3u8_url = clip.get('sources', [{}])[0].get('file')
|
|
|
|
duration = clip.get('clip_duration')
|
|
|
|
thumbnail = clip.get('image')
|
|
|
|
|
|
|
|
m3u8_url = m3u8_url or self._search_regex(
|
2018-02-23 00:50:39 +09:00
|
|
|
r'data(?:-vjs)?-clip-hls-url=(["\'])(?P<url>(?:(?!\1).)+)\1',
|
|
|
|
webpage, 'hls url', group='url')
|
2017-04-23 13:48:51 +09:00
|
|
|
formats = self._extract_m3u8_formats(
|
|
|
|
m3u8_url, display_id, 'mp4', entry_protocol='m3u8_native')
|
|
|
|
self._sort_formats(formats)
|
2016-06-04 18:47:43 +09:00
|
|
|
|
|
|
|
duration = int_or_none(duration or self._search_regex(
|
2017-07-23 02:44:50 +09:00
|
|
|
r'data-video-duration=(["\'])(?P<duration>\d+)\1', webpage,
|
|
|
|
'duration', fatal=False, group='duration'))
|
2016-06-04 18:47:43 +09:00
|
|
|
thumbnail = thumbnail or self._og_search_thumbnail(webpage)
|
|
|
|
|
|
|
|
like_count = int_or_none(self._search_regex(
|
|
|
|
(r'<span[^>]+data-comment-vote-count=["\'](\d+)',
|
|
|
|
r'<span[^>]+class=["\'].*?\blike(?:__|-)count\b.*?["\'][^>]*>\s*(\d+)'),
|
|
|
|
webpage, 'like count', fatal=False))
|
2016-05-22 00:48:17 +09:00
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
2016-06-04 18:47:43 +09:00
|
|
|
'display_id': display_id,
|
|
|
|
'title': title,
|
2016-05-22 00:48:17 +09:00
|
|
|
'description': self._og_search_description(webpage),
|
2016-06-04 18:47:43 +09:00
|
|
|
'thumbnail': thumbnail,
|
|
|
|
'duration': duration,
|
|
|
|
'like_count': like_count,
|
|
|
|
'formats': formats,
|
2016-05-22 00:48:17 +09:00
|
|
|
}
|