[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / vbox7.py
blobf5d0502fb7dbc17bb5596ce5eee8078e78a0e48a
1 from .common import InfoExtractor
2 from ..utils import ExtractorError, base_url, int_or_none, url_basename
3 from ..utils.traversal import traverse_obj
6 class Vbox7IE(InfoExtractor):
7 _VALID_URL = r'''(?x)
8 https?://
9 (?:[^/]+\.)?vbox7\.com/
10 (?:
11 play:|
12 (?:
13 emb/external\.php|
14 player/ext\.swf
15 )\?.*?\bvid=
17 (?P<id>[\da-fA-F]+)
18 '''
19 _EMBED_REGEX = [r'<iframe[^>]+src=(?P<q>["\'])(?P<url>(?:https?:)?//vbox7\.com/emb/external\.php.+?)(?P=q)']
20 _GEO_COUNTRIES = ['BG']
21 _TESTS = [{
22 'url': 'http://vbox7.com/play:0946fff23c',
23 'md5': '50ca1f78345a9c15391af47d8062d074',
24 'info_dict': {
25 'id': '0946fff23c',
26 'ext': 'mp4',
27 'title': 'Борисов: Притеснен съм за бъдещето на България',
28 'description': 'По думите му е опасно страната ни да бъде обявена за "сигурна"',
29 'thumbnail': r're:^https?://.*\.jpg$',
30 'timestamp': 1470982814,
31 'upload_date': '20160812',
32 'uploader': 'zdraveibulgaria',
33 'view_count': int,
34 'duration': 2640,
36 }, {
37 'url': 'http://vbox7.com/play:249bb972c2',
38 'md5': 'da1dd2eb245200cb86e6d09d43232116',
39 'info_dict': {
40 'id': '249bb972c2',
41 'ext': 'mp4',
42 'title': 'Смях! Чудо - чист за секунди - Скрита камера',
43 'uploader': 'svideteliat_ot_varshava',
44 'view_count': int,
45 'timestamp': 1360215023,
46 'thumbnail': 'https://i49.vbox7.com/o/249/249bb972c20.jpg',
47 'description': 'Смях! Чудо - чист за секунди - Скрита камера',
48 'upload_date': '20130207',
49 'duration': 83,
51 'expected_warnings': ['Failed to download m3u8 information'],
52 }, {
53 'url': 'http://vbox7.com/emb/external.php?vid=a240d20f9c&autoplay=1',
54 'only_matching': True,
55 }, {
56 'url': 'http://i49.vbox7.com/player/ext.swf?vid=0946fff23c&autoplay=1',
57 'only_matching': True,
60 def _real_extract(self, url):
61 video_id = self._match_id(url)
63 data = self._download_json(
64 'https://www.vbox7.com/aj/player/item/options', video_id,
65 query={'vid': video_id})['options']
67 src_url = data.get('src')
68 if src_url in (None, '', 'blank'):
69 raise ExtractorError('Video is unavailable', expected=True)
71 fmt_base = url_basename(src_url).rsplit('.', 1)[0].rsplit('_', 1)[0]
72 if fmt_base == 'vn':
73 self.raise_geo_restricted()
75 fmt_base = base_url(src_url) + fmt_base
77 formats = self._extract_m3u8_formats(
78 f'{fmt_base}.m3u8', video_id, m3u8_id='hls', fatal=False)
79 # TODO: Add MPD formats, when dash range support is added
80 for res in traverse_obj(data, ('resolutions', lambda _, v: v != 0, {int})):
81 formats.append({
82 'url': f'{fmt_base}_{res}.mp4',
83 'format_id': f'http-{res}',
84 'height': res,
87 return {
88 'id': video_id,
89 'formats': formats,
90 **self._search_json_ld(self._download_webpage(
91 f'https://www.vbox7.com/play:{video_id}', video_id, fatal=False) or '', video_id, fatal=False),
92 **traverse_obj(data, {
93 'title': ('title', {str}),
94 'uploader': ('uploader', {str}),
95 'duration': ('duration', {int_or_none}),
96 }),