mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-25 04:35:52 +01:00
[vimeo] Fix extractors
Closes #3037, Closes #2858, Closes #2880, Closes #3712 May also fix #3602, #3360
This commit is contained in:
parent
d6bf1161db
commit
aedaa455d9
@ -137,7 +137,7 @@ def _real_extract(self, url):
|
||||
return {
|
||||
'_type': 'url_transparent',
|
||||
'ie_key': VHXEmbedIE.ie_key(),
|
||||
'url': embed_url,
|
||||
'url': VHXEmbedIE._smuggle_referrer(embed_url, 'https://www.dropout.tv'),
|
||||
'id': self._search_regex(r'embed\.vhx\.tv/videos/(.+?)\?', embed_url, 'id'),
|
||||
'display_id': display_id,
|
||||
'title': title,
|
||||
|
@ -2954,7 +2954,7 @@ def _real_extract(self, url):
|
||||
if vimeo_urls:
|
||||
return self.playlist_from_matches(vimeo_urls, video_id, video_title, ie=VimeoIE.ie_key())
|
||||
|
||||
vhx_url = VHXEmbedIE._extract_url(webpage)
|
||||
vhx_url = VHXEmbedIE._extract_url(url, webpage)
|
||||
if vhx_url:
|
||||
return self.url_result(vhx_url, VHXEmbedIE.ie_key())
|
||||
|
||||
|
@ -40,6 +40,18 @@ class VimeoBaseInfoExtractor(InfoExtractor):
|
||||
_LOGIN_REQUIRED = False
|
||||
_LOGIN_URL = 'https://vimeo.com/log_in'
|
||||
|
||||
@staticmethod
|
||||
def _smuggle_referrer(url, referrer_url):
|
||||
return smuggle_url(url, {'http_headers': {'Referer': referrer_url}})
|
||||
|
||||
def _unsmuggle_headers(self, url):
|
||||
"""@returns (url, smuggled_data, headers)"""
|
||||
url, data = unsmuggle_url(url, {})
|
||||
headers = self.get_param('http_headers').copy()
|
||||
if 'http_headers' in data:
|
||||
headers.update(data['http_headers'])
|
||||
return url, data, headers
|
||||
|
||||
def _perform_login(self, username, password):
|
||||
webpage = self._download_webpage(
|
||||
self._LOGIN_URL, None, 'Downloading login page')
|
||||
@ -717,10 +729,6 @@ class VimeoIE(VimeoBaseInfoExtractor):
|
||||
# vimeo embed with check-password page protected by Referer header
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def _smuggle_referrer(url, referrer_url):
|
||||
return smuggle_url(url, {'http_headers': {'Referer': referrer_url}})
|
||||
|
||||
@staticmethod
|
||||
def _extract_urls(url, webpage):
|
||||
urls = []
|
||||
@ -754,8 +762,8 @@ def _verify_player_video_password(self, url, video_id, headers):
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
})
|
||||
checked = self._download_json(
|
||||
url + '/check-password', video_id,
|
||||
'Verifying the password', data=data, headers=headers)
|
||||
f'{compat_urlparse.urlsplit(url)._replace(query=None).geturl()}/check-password',
|
||||
video_id, 'Verifying the password', data=data, headers=headers)
|
||||
if checked is False:
|
||||
raise ExtractorError('Wrong video password', expected=True)
|
||||
return checked
|
||||
@ -830,10 +838,7 @@ def _try_album_password(self, url):
|
||||
raise
|
||||
|
||||
def _real_extract(self, url):
|
||||
url, data = unsmuggle_url(url, {})
|
||||
headers = self.get_param('http_headers').copy()
|
||||
if 'http_headers' in data:
|
||||
headers.update(data['http_headers'])
|
||||
url, data, headers = self._unsmuggle_headers(url)
|
||||
if 'Referer' not in headers:
|
||||
headers['Referer'] = url
|
||||
|
||||
@ -1383,14 +1388,15 @@ class VHXEmbedIE(VimeoBaseInfoExtractor):
|
||||
_VALID_URL = r'https?://embed\.vhx\.tv/videos/(?P<id>\d+)'
|
||||
|
||||
@staticmethod
|
||||
def _extract_url(webpage):
|
||||
def _extract_url(url, webpage):
|
||||
mobj = re.search(
|
||||
r'<iframe[^>]+src="(https?://embed\.vhx\.tv/videos/\d+[^"]*)"', webpage)
|
||||
return unescapeHTML(mobj.group(1)) if mobj else None
|
||||
return VimeoIE._smuggle_referrer(unescapeHTML(mobj.group(1)), url) if mobj else None
|
||||
|
||||
def _real_extract(self, url):
|
||||
video_id = self._match_id(url)
|
||||
webpage = self._download_webpage(url, video_id)
|
||||
url, _, headers = self._unsmuggle_headers(url)
|
||||
webpage = self._download_webpage(url, video_id, headers=headers)
|
||||
config_url = self._parse_json(self._search_regex(
|
||||
r'window\.OTTData\s*=\s*({.+})', webpage,
|
||||
'ott data'), video_id, js_to_json)['config_url']
|
||||
|
Loading…
Reference in New Issue
Block a user