mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 06:10:12 +01:00
Compare commits
23 Commits
f0040d25b9
...
1451fd78f3
Author | SHA1 | Date | |
---|---|---|---|
|
1451fd78f3 | ||
|
4b5eec0aaa | ||
|
3302588c77 | ||
|
163533ee17 | ||
|
88ac2d3915 | ||
|
eb0cfc7420 | ||
|
0a8b675da9 | ||
|
5143f916f3 | ||
|
8f0d32fa83 | ||
|
8e01382707 | ||
|
94f85add47 | ||
|
18b4296aa3 | ||
|
6ef07d4ec9 | ||
|
821ac9c0b8 | ||
|
4916a77720 | ||
|
c22e4bd29f | ||
|
6a04a4aaec | ||
|
1bd55358a0 | ||
|
6542c5124c | ||
|
f1ed988c5f | ||
|
6be151fed7 | ||
|
4f58aabe67 | ||
|
fcff2c5cd0 |
|
@ -59,16 +59,15 @@ def _extract_from_api(self, video_id, tld):
|
|||
'Accept': 'application/json',
|
||||
}, fatal=False, impersonate=True) or {}
|
||||
|
||||
status = response.get('room_status')
|
||||
if status != 'public':
|
||||
if error := self._ERROR_MAP.get(status):
|
||||
raise ExtractorError(error, expected=True)
|
||||
self.report_warning('Falling back to webpage extraction')
|
||||
return None
|
||||
|
||||
m3u8_url = response.get('url')
|
||||
if not m3u8_url:
|
||||
status = response.get('room_status')
|
||||
if error := self._ERROR_MAP.get(status):
|
||||
raise ExtractorError(error, expected=True)
|
||||
if status == 'public':
|
||||
self.raise_geo_restricted()
|
||||
self.report_warning(f'Got status "{status}" from API; falling back to webpage extraction')
|
||||
return None
|
||||
|
||||
return {
|
||||
'id': video_id,
|
||||
|
|
|
@ -446,7 +446,9 @@ def _perform_login(self, username, password):
|
|||
try:
|
||||
login_results = self._download_webpage(request, None,
|
||||
note='Logging in', errnote='unable to fetch login page')
|
||||
if re.search(r'<form(.*)name="login"(.*)</form>', login_results) is not None:
|
||||
if 'Your Request Couldn' in login_results:
|
||||
self.raise_login_required('Failed to login with credentials', method='cookies')
|
||||
elif re.search(r'<form[^>]*name="login"[^<]*</form>', login_results):
|
||||
error = self._html_search_regex(
|
||||
r'(?s)<div[^>]+class=(["\']).*?login_error_box.*?\1[^>]*><div[^>]*>.*?</div><div[^>]*>(?P<error>.+?)</div>',
|
||||
login_results, 'login error', default=None, group='error')
|
||||
|
@ -479,13 +481,41 @@ def _perform_login(self, username, password):
|
|||
return
|
||||
|
||||
def _extract_from_url(self, url, video_id):
|
||||
cookies = self._get_cookies(url)
|
||||
# user passed logged-in cookies or attempted to login
|
||||
login_data = cookies.get('c_user') and cookies.get('xs')
|
||||
logged_in = False
|
||||
|
||||
webpage = self._download_webpage(
|
||||
url.replace('://m.facebook.com/', '://www.facebook.com/'), video_id)
|
||||
|
||||
def extract_metadata(webpage):
|
||||
post_data = [self._parse_json(j, video_id, fatal=False) for j in re.findall(
|
||||
sjs_data = [self._parse_json(j, video_id, fatal=False) for j in re.findall(
|
||||
r'data-sjs>({.*?ScheduledServerJS.*?})</script>', webpage)]
|
||||
post = traverse_obj(post_data, (
|
||||
|
||||
if login_data:
|
||||
logged_in = get_first(sjs_data, (
|
||||
'require', ..., ..., ..., '__bbox', 'define',
|
||||
lambda _, v: 'CurrentUserInitialData' in v, ..., 'ACCOUNT_ID'), default='0') != '0'
|
||||
if logged_in and (info := get_first(sjs_data, ('require', ..., ..., ..., '__bbox', 'require', ..., ..., ...,
|
||||
'__bbox', 'result', 'data', (('ufac_client', 'state',
|
||||
(('set_contact_point_state_renderer', 'title'),
|
||||
('intro_state_renderer', 'header_title'))),
|
||||
('epsilon_checkpoint', 'screen', 'title'))))):
|
||||
if any(content in info for content in ['days left to appeal', 'suspended your account']):
|
||||
raise ExtractorError('Your account is suspended', expected=True)
|
||||
if 'Enter mobile number' == info:
|
||||
raise ExtractorError('Facebook is requiring mobile number confirmation', expected=True)
|
||||
if 'your account has been locked' in info:
|
||||
raise ExtractorError('Your account has been locked', expected=True)
|
||||
|
||||
if props := get_first(sjs_data, (
|
||||
'require', ..., ..., ..., '__bbox', 'require', ..., ..., ..., 'rootView',
|
||||
lambda _, v: v['title'].startswith('This content isn\'t available'))):
|
||||
raise ExtractorError(
|
||||
f'Content unavailable. Facebook said: {props.get("body") or props["title"]}', expected=True)
|
||||
|
||||
def extract_metadata(webpage):
|
||||
post = traverse_obj(sjs_data, (
|
||||
..., 'require', ..., ..., ..., '__bbox', 'require', ..., ..., ..., '__bbox', 'result', 'data'), expected_type=dict) or []
|
||||
media = traverse_obj(post, (..., 'attachments', ..., lambda k, v: (
|
||||
k == 'media' and str(v['id']) == video_id and v['__typename'] == 'Video')), expected_type=dict)
|
||||
|
@ -838,6 +868,10 @@ def parse_attachment(attachment, key='media'):
|
|||
video_data = extract_from_jsmods_instances(tahoe_js_data)
|
||||
|
||||
if not video_data:
|
||||
if not login_data:
|
||||
raise ExtractorError('Cannot parse data. Try logging in.', expected=True)
|
||||
if not logged_in:
|
||||
raise ExtractorError('Failed to login with provided data.', expected=True)
|
||||
raise ExtractorError('Cannot parse data')
|
||||
|
||||
if len(video_data) > 1:
|
||||
|
|
Loading…
Reference in New Issue
Block a user