]> jfr.im git - yt-dlp.git/commitdiff
[Vimeo] Better extraction of original file (#599)
authorAshish <redacted>
Mon, 2 Aug 2021 01:53:12 +0000 (07:23 +0530)
committerGitHub <redacted>
Mon, 2 Aug 2021 01:53:12 +0000 (07:23 +0530)
Authored by: Ashish0804

yt_dlp/extractor/vimeo.py

index 785dcc457ce532170cff20e44a29e69dcf1e56cb..8ddd1d298e9abb10362bac406ddd1e085b34a65c 100644 (file)
@@ -253,6 +253,30 @@ def _extract_original_format(self, url, video_id, unlisted_hash=None):
                             'quality': 1,
                         }
 
+        jwt_response = self._download_json(
+            'https://vimeo.com/_rv/viewer', video_id, note='Downloading jwt token', fatal=False) or {}
+        if not jwt_response.get('jwt'):
+            return
+        headers = {'Authorization': 'jwt %s' % jwt_response['jwt']}
+        original_response = self._download_json(
+            f'https://api.vimeo.com/videos/{video_id}', video_id,
+            headers=headers, fatal=False) or {}
+        for download_data in original_response.get('download') or {}:
+            download_url = download_data.get('link')
+            if not download_url or download_data.get('quality') != 'source':
+                continue
+            query = compat_urlparse.parse_qs(compat_urlparse.urlparse(download_url).query)
+            return {
+                'url': download_url,
+                'ext': determine_ext(query.get('filename', [''])[0].lower()),
+                'format_id': download_data.get('public_name', 'Original'),
+                'width': int_or_none(download_data.get('width')),
+                'height': int_or_none(download_data.get('height')),
+                'fps': int_or_none(download_data.get('fps')),
+                'filesize': int_or_none(download_data.get('size')),
+                'quality': 1,
+            }
+
 
 class VimeoIE(VimeoBaseInfoExtractor):
     """Information extractor for vimeo.com."""
@@ -426,6 +450,22 @@ class VimeoIE(VimeoBaseInfoExtractor):
                 'description': 'md5:ae23671e82d05415868f7ad1aec21147',
             },
         },
+        {
+            'note': 'Contains original format not accessible in webpage',
+            'url': 'https://vimeo.com/393756517',
+            'md5': 'c464af248b592190a5ffbb5d33f382b0',
+            'info_dict': {
+                'id': '393756517',
+                'ext': 'mov',
+                'timestamp': 1582642091,
+                'uploader_id': 'frameworkla',
+                'title': 'Straight To Hell - Sabrina: Netflix',
+                'uploader': 'Framework Studio',
+                'description': 'md5:f2edc61af3ea7a5592681ddbb683db73',
+                'upload_date': '20200225',
+            },
+            'expected_warnings': ['Unable to download JSON metadata'],
+        },
         {
             # only available via https://vimeo.com/channels/tributes/6213729 and
             # not via https://vimeo.com/6213729