mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 09:01:43 +00:00
[ie/Vbox7] Fix extractor (#9100)
Closes #1098, Closes #5661 Authored by: seproDev
This commit is contained in:
parent
9b5efaf86b
commit
67bb70cd70
@ -1,5 +1,6 @@
|
|||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import ExtractorError
|
from ..utils import ExtractorError, base_url, int_or_none, url_basename
|
||||||
|
from ..utils.traversal import traverse_obj
|
||||||
|
|
||||||
|
|
||||||
class Vbox7IE(InfoExtractor):
|
class Vbox7IE(InfoExtractor):
|
||||||
@ -19,7 +20,7 @@ class Vbox7IE(InfoExtractor):
|
|||||||
_GEO_COUNTRIES = ['BG']
|
_GEO_COUNTRIES = ['BG']
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://vbox7.com/play:0946fff23c',
|
'url': 'http://vbox7.com/play:0946fff23c',
|
||||||
'md5': 'a60f9ab3a3a2f013ef9a967d5f7be5bf',
|
'md5': '50ca1f78345a9c15391af47d8062d074',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '0946fff23c',
|
'id': '0946fff23c',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
@ -29,19 +30,25 @@ class Vbox7IE(InfoExtractor):
|
|||||||
'timestamp': 1470982814,
|
'timestamp': 1470982814,
|
||||||
'upload_date': '20160812',
|
'upload_date': '20160812',
|
||||||
'uploader': 'zdraveibulgaria',
|
'uploader': 'zdraveibulgaria',
|
||||||
},
|
'view_count': int,
|
||||||
'params': {
|
'duration': 2640,
|
||||||
'proxy': '127.0.0.1:8118',
|
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://vbox7.com/play:249bb972c2',
|
'url': 'http://vbox7.com/play:249bb972c2',
|
||||||
'md5': '99f65c0c9ef9b682b97313e052734c3f',
|
'md5': 'da1dd2eb245200cb86e6d09d43232116',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '249bb972c2',
|
'id': '249bb972c2',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Смях! Чудо - чист за секунди - Скрита камера',
|
'title': 'Смях! Чудо - чист за секунди - Скрита камера',
|
||||||
|
'uploader': 'svideteliat_ot_varshava',
|
||||||
|
'view_count': int,
|
||||||
|
'timestamp': 1360215023,
|
||||||
|
'thumbnail': 'https://i49.vbox7.com/design/iconci/png/noimg6.png',
|
||||||
|
'description': 'Смях! Чудо - чист за секунди - Скрита камера',
|
||||||
|
'upload_date': '20130207',
|
||||||
|
'duration': 83,
|
||||||
},
|
},
|
||||||
'skip': 'georestricted',
|
'expected_warnings': ['Failed to download m3u8 information'],
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://vbox7.com/emb/external.php?vid=a240d20f9c&autoplay=1',
|
'url': 'http://vbox7.com/emb/external.php?vid=a240d20f9c&autoplay=1',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
@ -53,41 +60,38 @@ class Vbox7IE(InfoExtractor):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
response = self._download_json(
|
data = self._download_json(
|
||||||
'https://www.vbox7.com/ajax/video/nextvideo.php?vid=%s' % video_id,
|
'https://www.vbox7.com/aj/player/item/options', video_id,
|
||||||
video_id)
|
query={'vid': video_id})['options']
|
||||||
|
|
||||||
if 'error' in response:
|
src_url = data.get('src')
|
||||||
raise ExtractorError(
|
if src_url in (None, '', 'blank'):
|
||||||
'%s said: %s' % (self.IE_NAME, response['error']), expected=True)
|
raise ExtractorError('Video is unavailable', expected=True)
|
||||||
|
|
||||||
video = response['options']
|
fmt_base = url_basename(src_url).rsplit('.', 1)[0].rsplit('_', 1)[0]
|
||||||
|
if fmt_base == 'vn':
|
||||||
|
self.raise_geo_restricted()
|
||||||
|
|
||||||
title = video['title']
|
fmt_base = base_url(src_url) + fmt_base
|
||||||
video_url = video['src']
|
|
||||||
|
|
||||||
if '/na.mp4' in video_url:
|
formats = self._extract_m3u8_formats(
|
||||||
self.raise_geo_restricted(countries=self._GEO_COUNTRIES)
|
f'{fmt_base}.m3u8', video_id, m3u8_id='hls', fatal=False)
|
||||||
|
# TODO: Add MPD formats, when dash range support is added
|
||||||
|
for res in traverse_obj(data, ('resolutions', lambda _, v: v != 0, {int})):
|
||||||
|
formats.append({
|
||||||
|
'url': f'{fmt_base}_{res}.mp4',
|
||||||
|
'format_id': f'http-{res}',
|
||||||
|
'height': res,
|
||||||
|
})
|
||||||
|
|
||||||
uploader = video.get('uploader')
|
return {
|
||||||
|
|
||||||
webpage = self._download_webpage(
|
|
||||||
'http://vbox7.com/play:%s' % video_id, video_id, fatal=None)
|
|
||||||
|
|
||||||
info = {}
|
|
||||||
|
|
||||||
if webpage:
|
|
||||||
info = self._search_json_ld(
|
|
||||||
webpage.replace('"/*@context"', '"@context"'), video_id,
|
|
||||||
fatal=False)
|
|
||||||
|
|
||||||
info.update({
|
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'formats': formats,
|
||||||
'url': video_url,
|
**self._search_json_ld(self._download_webpage(
|
||||||
'uploader': uploader,
|
f'https://www.vbox7.com/play:{video_id}', video_id, fatal=False) or '', video_id, fatal=False),
|
||||||
'thumbnail': self._proto_relative_url(
|
**traverse_obj(data, {
|
||||||
info.get('thumbnail') or self._og_search_thumbnail(webpage),
|
'title': ('title', {str}),
|
||||||
'http:'),
|
'uploader': ('uploader', {str}),
|
||||||
})
|
'duration': ('duration', {int_or_none}),
|
||||||
return info
|
}),
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user