mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-25 21:59:04 +01:00
[ie/dropbox] Fix password-protected video extraction (#11636)
Some checks failed
CodeQL / Analyze (push) Has been cancelled
Core Tests / Core Tests (push) Has been cancelled
Download Tests / Quick Download Tests (push) Has been cancelled
Download Tests / Full Download Tests (push) Has been cancelled
Quick Test / Core Test (push) Has been cancelled
Quick Test / Code check (push) Has been cancelled
Release (master) / release (push) Has been cancelled
Release (master) / publish_pypi (push) Has been cancelled
Some checks failed
CodeQL / Analyze (push) Has been cancelled
Core Tests / Core Tests (push) Has been cancelled
Download Tests / Quick Download Tests (push) Has been cancelled
Download Tests / Full Download Tests (push) Has been cancelled
Quick Test / Core Test (push) Has been cancelled
Quick Test / Code check (push) Has been cancelled
Release (master) / release (push) Has been cancelled
Release (master) / publish_pypi (push) Has been cancelled
Closes #11634 Authored by: bashonly
This commit is contained in:
parent
910ecc4229
commit
00dcde7286
1 changed files with 18 additions and 20 deletions
|
@ -48,32 +48,30 @@ class DropboxIE(InfoExtractor):
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
fn = urllib.parse.unquote(url_basename(url))
|
fn = urllib.parse.unquote(url_basename(url))
|
||||||
title = os.path.splitext(fn)[0]
|
title = os.path.splitext(fn)[0]
|
||||||
password = self.get_param('videopassword')
|
content_id = None
|
||||||
|
|
||||||
for part in self._yield_decoded_parts(webpage):
|
for part in self._yield_decoded_parts(webpage):
|
||||||
if '/sm/password' in part:
|
if '/sm/password' in part:
|
||||||
webpage = self._download_webpage(
|
content_id = self._search_regex(r'content_id=([\w.+=/-]+)', part, 'content ID')
|
||||||
update_url('https://www.dropbox.com/sm/password', query=part.partition('?')[2]), video_id)
|
|
||||||
break
|
break
|
||||||
|
|
||||||
if (self._og_search_title(webpage, default=None) == 'Dropbox - Password Required'
|
if content_id:
|
||||||
or 'Enter the password for this link' in webpage):
|
password = self.get_param('videopassword')
|
||||||
if password:
|
if not password:
|
||||||
response = self._download_json(
|
|
||||||
'https://www.dropbox.com/sm/auth', video_id, 'POSTing video password',
|
|
||||||
headers={'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'},
|
|
||||||
data=urlencode_postdata({
|
|
||||||
'is_xhr': 'true',
|
|
||||||
't': self._get_cookies('https://www.dropbox.com')['t'].value,
|
|
||||||
'content_id': self._search_regex(r'content_id=([\w.+=/-]+)["\']', webpage, 'content id'),
|
|
||||||
'password': password,
|
|
||||||
'url': url,
|
|
||||||
}))
|
|
||||||
|
|
||||||
if response.get('status') != 'authed':
|
|
||||||
raise ExtractorError('Invalid password', expected=True)
|
|
||||||
elif not self._get_cookies('https://dropbox.com').get('sm_auth'):
|
|
||||||
raise ExtractorError('Password protected video, use --video-password <password>', expected=True)
|
raise ExtractorError('Password protected video, use --video-password <password>', expected=True)
|
||||||
|
|
||||||
|
response = self._download_json(
|
||||||
|
'https://www.dropbox.com/sm/auth', video_id, 'POSTing video password',
|
||||||
|
data=urlencode_postdata({
|
||||||
|
'is_xhr': 'true',
|
||||||
|
't': self._get_cookies('https://www.dropbox.com')['t'].value,
|
||||||
|
'content_id': content_id,
|
||||||
|
'password': password,
|
||||||
|
'url': update_url(url, scheme='', netloc=''),
|
||||||
|
}))
|
||||||
|
if response.get('status') != 'authed':
|
||||||
|
raise ExtractorError('Invalid password', expected=True)
|
||||||
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
formats, subtitles = [], {}
|
formats, subtitles = [], {}
|
||||||
|
|
Loading…
Reference in a new issue