Compare commits

...

22 Commits

Author SHA1 Message Date
ringus1
545c1608d1
Merge 3302588c77 into be3579aaf0 2024-11-08 18:57:37 +01:00
bashonly
3302588c77
Merge branch 'yt-dlp:master' into pr/fb_parsedata_error 2024-02-15 17:02:42 -06:00
ringus1
163533ee17 PR changes 2024-02-13 12:03:07 +01:00
ringus1
88ac2d3915 Flake fix 2024-02-05 11:46:58 +01:00
ringus1
eb0cfc7420 Raising error only if video parsing fails 2024-02-05 11:45:23 +01:00
ringus1
0a8b675da9 Move getting cookies before making first request 2024-02-01 09:56:34 +01:00
ringus1
5143f916f3 PR fixes - clear up messages 2024-02-01 08:14:23 +01:00
ringus1
8f0d32fa83 Simplify login error check 2024-01-31 17:04:09 +01:00
ringus1
8e01382707 Fix props getter 2024-01-31 16:54:26 +01:00
ringus1
94f85add47 Merge branch 'fb_parsedata_error' of https://github.com/ringus1/yt-dlp into fb_parsedata_error 2024-01-31 16:38:20 +01:00
ringus1
18b4296aa3 MR fixes 2024-01-31 16:38:02 +01:00
bashonly
6ef07d4ec9
Merge branch 'master' into fb_parsedata_error 2024-01-31 08:53:05 -06:00
ringus1
821ac9c0b8 More messages for account suspension 2024-01-24 21:52:46 +01:00
ringus1
4916a77720 Add one more case when account is locked 2024-01-24 12:22:09 +01:00
ringus1
c22e4bd29f Fix double quotes 2024-01-15 13:05:53 +01:00
ringus1
6a04a4aaec Detect mobile number checkpoint 2024-01-15 10:43:10 +01:00
ringus1
1bd55358a0 Flake fix 2024-01-12 15:04:27 +01:00
ringus1
6542c5124c Formatting 2024-01-12 14:48:46 +01:00
ringus1
f1ed988c5f One more exception handling 2024-01-11 17:01:20 +01:00
ringus1
6be151fed7 Handle removed content 2024-01-11 16:02:41 +01:00
ringus1
4f58aabe67 Add better login handling 2024-01-11 14:39:52 +01:00
ringus1
fcff2c5cd0 Adding potential fix 2024-01-10 16:11:45 +01:00

View File

@ -443,7 +443,9 @@ class FacebookIE(InfoExtractor):
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')
@ -476,13 +478,41 @@ class FacebookIE(InfoExtractor):
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)
@ -810,6 +840,10 @@ class FacebookIE(InfoExtractor):
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: