2016-11-03 05:50:25 -06:00
|
|
|
from .common import InfoExtractor
|
2018-09-10 13:41:05 -06:00
|
|
|
from ..compat import compat_str
|
2016-11-03 05:50:25 -06:00
|
|
|
from ..utils import (
|
|
|
|
int_or_none,
|
|
|
|
float_or_none,
|
2018-09-10 13:41:05 -06:00
|
|
|
unified_timestamp,
|
|
|
|
url_or_none,
|
2016-11-03 05:50:25 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class VzaarIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'https?://(?:(?:www|view)\.)?vzaar\.com/(?:videos/)?(?P<id>\d+)'
|
2022-07-31 19:23:25 -06:00
|
|
|
_EMBED_REGEX = [r'<iframe[^>]+src=["\'](?P<url>(?:https?:)?//(?:view\.vzaar\.com)/[0-9]+)']
|
2016-11-03 05:50:25 -06:00
|
|
|
_TESTS = [{
|
2018-09-10 13:41:05 -06:00
|
|
|
# HTTP and HLS
|
2016-11-03 05:50:25 -06:00
|
|
|
'url': 'https://vzaar.com/videos/1152805',
|
|
|
|
'md5': 'bde5ddfeb104a6c56a93a06b04901dbf',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '1152805',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'sample video (public)',
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
'url': 'https://view.vzaar.com/27272/player',
|
|
|
|
'md5': '3b50012ac9bbce7f445550d54e0508f2',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '27272',
|
|
|
|
'ext': 'mp3',
|
|
|
|
'title': 'MP3',
|
|
|
|
},
|
2019-12-03 03:37:30 -07:00
|
|
|
}, {
|
|
|
|
# hlsAes = true
|
2019-12-03 04:31:16 -07:00
|
|
|
'url': 'https://view.vzaar.com/11379930/player',
|
2019-12-03 03:37:30 -07:00
|
|
|
'info_dict': {
|
2019-12-03 04:31:16 -07:00
|
|
|
'id': '11379930',
|
2019-12-03 03:37:30 -07:00
|
|
|
'ext': 'mp4',
|
2019-12-03 04:31:16 -07:00
|
|
|
'title': 'Videoaula',
|
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
# m3u8 download
|
|
|
|
'skip_download': True,
|
2019-12-03 03:37:30 -07:00
|
|
|
},
|
2019-07-03 10:16:40 -06:00
|
|
|
}, {
|
|
|
|
# with null videoTitle
|
|
|
|
'url': 'https://view.vzaar.com/20313539/download',
|
|
|
|
'only_matching': True,
|
2016-11-03 05:50:25 -06:00
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
video_data = self._download_json(
|
|
|
|
'http://view.vzaar.com/v2/%s/video' % video_id, video_id)
|
|
|
|
|
2019-07-03 10:16:40 -06:00
|
|
|
title = video_data.get('videoTitle') or video_id
|
2018-09-10 13:41:05 -06:00
|
|
|
|
|
|
|
formats = []
|
|
|
|
|
|
|
|
source_url = url_or_none(video_data.get('sourceUrl'))
|
|
|
|
if source_url:
|
|
|
|
f = {
|
|
|
|
'url': source_url,
|
|
|
|
'format_id': 'http',
|
2021-02-18 15:03:16 -07:00
|
|
|
'quality': 1,
|
2018-09-10 13:41:05 -06:00
|
|
|
}
|
|
|
|
if 'audio' in source_url:
|
|
|
|
f.update({
|
|
|
|
'vcodec': 'none',
|
|
|
|
'ext': 'mp3',
|
|
|
|
})
|
|
|
|
else:
|
|
|
|
f.update({
|
|
|
|
'width': int_or_none(video_data.get('width')),
|
|
|
|
'height': int_or_none(video_data.get('height')),
|
|
|
|
'ext': 'mp4',
|
|
|
|
'fps': float_or_none(video_data.get('fps')),
|
|
|
|
})
|
|
|
|
formats.append(f)
|
|
|
|
|
|
|
|
video_guid = video_data.get('guid')
|
|
|
|
usp = video_data.get('usp')
|
2019-12-03 03:37:30 -07:00
|
|
|
if video_data.get('uspEnabled') and isinstance(video_guid, compat_str) and isinstance(usp, dict):
|
|
|
|
hls_aes = video_data.get('hlsAes')
|
2019-12-03 04:23:08 -07:00
|
|
|
qs = '&'.join('%s=%s' % (k, v) for k, v in usp.items())
|
|
|
|
url_templ = 'http://%%s.vzaar.com/v5/usp%s/%s/%s.ism%%s?' % ('aes' if hls_aes else '', video_guid, video_id)
|
|
|
|
m3u8_formats = self._extract_m3u8_formats(
|
|
|
|
url_templ % ('fable', '/.m3u8') + qs, video_id, 'mp4', 'm3u8_native',
|
|
|
|
m3u8_id='hls', fatal=False)
|
|
|
|
if hls_aes:
|
|
|
|
for f in m3u8_formats:
|
2023-02-07 22:33:54 -07:00
|
|
|
f['hls_aes'] = {'uri': url_templ % ('goose', '') + qs}
|
2019-12-03 04:23:08 -07:00
|
|
|
formats.extend(m3u8_formats)
|
2018-09-10 13:41:05 -06:00
|
|
|
|
|
|
|
return {
|
2016-11-03 05:50:25 -06:00
|
|
|
'id': video_id,
|
2018-09-10 13:41:05 -06:00
|
|
|
'title': title,
|
2016-11-03 05:50:25 -06:00
|
|
|
'thumbnail': self._proto_relative_url(video_data.get('poster')),
|
|
|
|
'duration': float_or_none(video_data.get('videoDuration')),
|
2018-09-10 13:41:05 -06:00
|
|
|
'timestamp': unified_timestamp(video_data.get('ts')),
|
|
|
|
'formats': formats,
|
2016-11-03 05:50:25 -06:00
|
|
|
}
|