Repository: yt-dlp/yt-dlp

Issue:
[Broken] Vbox7 issues 
<!--

######################################################################
  WARNING!
  IGNORING THE FOLLOWING TEMPLATE WILL RESULT IN ISSUE CLOSED AS INCOMPLETE
######################################################################

-->


## Checklist

<!--
Carefully read and work through this check list in order to prevent the most common mistakes and misuse of yt-dlp:
- First of, make sure you are using the latest version of yt-dlp. Run `yt-dlp --version` and ensure your version is 2021.09.25. If it's not, see https://github.com/yt-dlp/yt-dlp on how to update. Issues with outdated version will be REJECTED.
- Make sure that all provided video/audio/playlist URLs (if any) are alive and playable in a browser.
- Make sure that all URLs and arguments with special characters are properly quoted or escaped as explained in https://github.com/yt-dlp/yt-dlp.
- Search the bugtracker for similar issues: https://github.com/yt-dlp/yt-dlp. DO NOT post duplicates.
- Finally, put x into all relevant boxes like this [x] (Dont forget to delete the empty space)
-->

- [x] I'm reporting a broken site support
- [x] I've verified that I'm running yt-dlp version **2021.09.25**
- [x] I've checked that all provided URLs are alive and playable in a browser
- [x] I've checked that all URLs and arguments with special characters are properly quoted or escaped
- [x] I've searched the bugtracker for similar issues including closed ones


## Verbose log

<!--
Provide the complete verbose output of yt-dlp that clearly demonstrates the problem.
Add the `-v` flag to your command line you run yt-dlp with (`yt-dlp -v <your command line>`), copy the WHOLE output and insert it below. It should look similar to this:
 [debug] System config: []
 [debug] User config: []
 [debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKc']
 [debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
 [debug] yt-dlp version 2021.09.25
 [debug] Python version 2.7.11 - Windows-2003Server-5.2.3790-SP2
 [debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4
 [debug] Proxy map: {}
 <more lines>
-->

```
[Vbox7] f9840099c3: Downloading JSON metadata
[Vbox7] f9840099c3: Downloading webpage
WARNING: [Vbox7] unable to extract JSON-LD ; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
WARNING: [Vbox7] unable to extract thumbnail URL; please report this issue on  https://github.com/yt-dlp/yt-dlp . Make sure you are using the latest version; see  https://github.com/yt-dlp/yt-dlp  on how to update. Be sure to call yt-dlp with the --verbose flag and include its complete output.
[info] f9840099c3: Downloading 1 format(s): 0
[download] Destination: Where there's a wheel there's a way - Japanese unicycle specialist shows off her skills [f9840099c3].mpd
[download] 100% of 58.76KiB in 00:02

```
<!--
Do not remove the above ```
-->


## Description

<!--
Provide an explanation of your issue in an arbitrary form. Provide any additional information, suggested solution and as much context and examples as possible.
If work on your issue requires account credentials please provide them or explain how one can obtain them.
-->

What it downloaded from the following link was a useless tiny piece of file: 
https://www.vbox7.com/play:f9840099c3

I also tried some other links from Vbox7 and got the same issue. Please fix! Thank you so very much!



Discussion:
Upstream pr https://github.com/ytdl-org/youtube-dl/pull/29680
Looks like they are using a workaround. The ideal solution would be to improve the mpd parser to handle the format
This needs to be urgently fixed - on February 22nd Vbox7 will be privating nearly all their videos. Archivists and regular users need an easy way to back up videos/channels, whether individually or en masse.

https://www.reddit.com/r/Archiveteam/comments/19d6ou7/video_platform_vbox7_is_about_to_restrict_access/

Resolving patch:
diff --git a/yt_dlp/extractor/vbox7.py b/yt_dlp/extractor/vbox7.py
--- a/yt_dlp/extractor/vbox7.py
+++ b/yt_dlp/extractor/vbox7.py
@@ -1,5 +1,6 @@
 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):
@@ -19,7 +20,7 @@ class Vbox7IE(InfoExtractor):
     _GEO_COUNTRIES = ['BG']
     _TESTS = [{
         'url': 'http://vbox7.com/play:0946fff23c',
-        'md5': 'a60f9ab3a3a2f013ef9a967d5f7be5bf',
+        'md5': '50ca1f78345a9c15391af47d8062d074',
         'info_dict': {
             'id': '0946fff23c',
             'ext': 'mp4',
@@ -29,19 +30,25 @@ class Vbox7IE(InfoExtractor):
             'timestamp': 1470982814,
             'upload_date': '20160812',
             'uploader': 'zdraveibulgaria',
-        },
-        'params': {
-            'proxy': '127.0.0.1:8118',
+            'view_count': int,
+            'duration': 2640,
         },
     }, {
         'url': 'http://vbox7.com/play:249bb972c2',
-        'md5': '99f65c0c9ef9b682b97313e052734c3f',
+        'md5': 'da1dd2eb245200cb86e6d09d43232116',
         'info_dict': {
             'id': '249bb972c2',
             'ext': 'mp4',
             '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',
         'only_matching': True,
@@ -53,41 +60,38 @@ class Vbox7IE(InfoExtractor):
     def _real_extract(self, url):
         video_id = self._match_id(url)
 
-        response = self._download_json(
-            'https://www.vbox7.com/ajax/video/nextvideo.php?vid=%s' % video_id,
-            video_id)
-
-        if 'error' in response:
-            raise ExtractorError(
-                '%s said: %s' % (self.IE_NAME, response['error']), expected=True)
-
-        video = response['options']
-
-        title = video['title']
-        video_url = video['src']
-
-        if '/na.mp4' in video_url:
-            self.raise_geo_restricted(countries=self._GEO_COUNTRIES)
+        data = self._download_json(
+            'https://www.vbox7.com/aj/player/item/options', video_id,
+            query={'vid': video_id})['options']
 
-        uploader = video.get('uploader')
+        src_url = data.get('src')
+        if src_url in (None, '', 'blank'):
+            raise ExtractorError('Video is unavailable', expected=True)
 
-        webpage = self._download_webpage(
-            'http://vbox7.com/play:%s' % video_id, video_id, fatal=None)
+        fmt_base = url_basename(src_url).rsplit('.', 1)[0].rsplit('_', 1)[0]
+        if fmt_base == 'vn':
+            self.raise_geo_restricted()
 
-        info = {}
+        fmt_base = base_url(src_url) + fmt_base
 
-        if webpage:
-            info = self._search_json_ld(
-                webpage.replace('"/*@context"', '"@context"'), video_id,
-                fatal=False)
+        formats = self._extract_m3u8_formats(
+            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,
+            })
 
-        info.update({
+        return {
             'id': video_id,
-            'title': title,
-            'url': video_url,
-            'uploader': uploader,
-            'thumbnail': self._proto_relative_url(
-                info.get('thumbnail') or self._og_search_thumbnail(webpage),
-                'http:'),
-        })
-        return info
+            'formats': formats,
+            **self._search_json_ld(self._download_webpage(
+                f'https://www.vbox7.com/play:{video_id}', video_id, fatal=False) or '', video_id, fatal=False),
+            **traverse_obj(data, {
+                'title': ('title', {str}),
+                'uploader': ('uploader', {str}),
+                'duration': ('duration', {int_or_none}),
+            }),
+        }


Test patch: