5 from .common
import InfoExtractor
7 compat_etree_fromstring
,
9 compat_urllib_parse_unquote
,
36 class FacebookIE(InfoExtractor
):
40 (?:[\w-]+\.)?(?:facebook\.com|facebookwkhpilnemxj7asaniu7vnjjbiltxjqhye3mhbshg7kx5tfyd\.onion)/
50 )\?(?:.*?)(?:v|video_id|story_fbid)=|
51 [^/]+/videos/(?:[^/]+/)?|
53 groups/[^/]+/permalink/|
61 r
'<iframe[^>]+?src=(["\'])(?P
<url
>https?
://www\
.facebook\
.com
/(?
:video
/embed|plugins
/video\
.php
).+?
)\
1',
62 # Facebook API embed https://developers.facebook.com/docs/plugins/embedded-video-player
64 class=(?P<q1>[\'"])[^\'"]*\bfb-(?:video|post)\b[^\'"]*(?P=q1)[^>]+
65 data-href=(?P<q2>[\'"])(?P<url>(?:https?:)?//(?:www\.)?facebook.com/.+?)(?P=q2)''',
67 _LOGIN_URL = 'https
://www
.facebook
.com
/login
.php?next
=http
%3A
%2F
%2Ffacebook
.com
%2Fhome
.php
&login_attempt
=1'
68 _CHECKPOINT_URL = 'https
://www
.facebook
.com
/checkpoint
/?next
=http
%3A
%2F
%2Ffacebook
.com
%2Fhome
.php
&_fb_noscript
=1'
69 _NETRC_MACHINE = 'facebook
'
72 _VIDEO_PAGE_TEMPLATE = 'https
://www
.facebook
.com
/video
/video
.php?v
=%s'
73 _VIDEO_PAGE_TAHOE_TEMPLATE = 'https
://www
.facebook
.com
/video
/tahoe
/async/%s/?chain
=true
&isvideo
=true
&payloadtype
=primary
'
76 'url
': 'https
://www
.facebook
.com
/video
.php?v
=637842556329505&fref
=nf
',
77 'md5
': '6a40d33c0eccbb1af76cf0485a052659
',
79 'id': '637842556329505',
81 'title
': 're
:Did you know Kei Nishikori
is the first Asian man to ever reach a Grand Slam
',
82 'uploader
': 'Tennis on Facebook
',
83 'upload_date
': '20140908',
84 'timestamp
': 1410199200,
86 'skip
': 'Requires logging
in',
89 'url
': 'https
://www
.facebook
.com
/video
.php?v
=274175099429670',
91 'id': '274175099429670',
93 'title
': 'Asif Nawab Butt
',
94 'description
': 'Asif Nawab Butt
',
95 'uploader
': 'Asif Nawab Butt
',
96 'upload_date
': '20140506',
97 'timestamp
': 1399398998,
98 'thumbnail
': r're
:^https?
://.*',
100 'expected_warnings
': [
104 'note
': 'Video
with DASH manifest
',
105 'url
': 'https
://www
.facebook
.com
/video
.php?v
=957955867617029',
106 'md5
': 'b2c28d528273b323abe5c6ab59f0f030
',
108 'id': '957955867617029',
110 'title
': 'When you post epic content on instagram
.com
/433 8 million followers
, this
is ...',
111 'uploader
': 'Demy de Zeeuw
',
112 'upload_date
': '20160110',
113 'timestamp
': 1452431627,
115 'skip
': 'Requires logging
in',
117 'url
': 'https
://www
.facebook
.com
/maxlayn
/posts
/10153807558977570',
118 'md5
': '037b1fa7f3c2d02b7a0d7bc16031ecc6
',
120 'id': '544765982287235',
122 'title
': '"What are you doing running in the snow?"',
123 'uploader
': 'FailArmy
',
125 'skip
': 'Video gone
',
127 'url
': 'https
://m
.facebook
.com
/story
.php?story_fbid
=1035862816472149&id=116132035111903',
128 'md5
': '1deb90b6ac27f7efcf6d747c8a27f5e3
',
130 'id': '1035862816472149',
132 'title
': 'What the Flock Is Going On In New Zealand Credit
: ViralHog
',
133 'uploader
': 'S
. Saint
',
135 'skip
': 'Video gone
',
137 'note
': 'swf params escaped
',
138 'url
': 'https
://www
.facebook
.com
/barackobama
/posts
/10153664894881749',
139 'md5
': '97ba073838964d12c70566e0085c2b91
',
141 'id': '10153664894881749',
143 'title
': 'Average time to confirm recent Supreme Court nominees
: 67 days Longest it
\'s t
...',
144 'thumbnail
': r're
:^https?
://.*',
145 'timestamp
': 1456259628,
146 'upload_date
': '20160223',
147 'uploader
': 'Barack Obama
',
149 'skip
': 'Gif on giphy
.com gone
',
151 # have 1080P, but only up to 720p in swf params
152 # data.video.story.attachments[].media
153 'url
': 'https
://www
.facebook
.com
/cnn
/videos
/10155529876156509/',
154 'md5
': '3f3798adb2b73423263e59376f1f5eb7
',
156 'id': '10155529876156509',
158 'title
': 'Holocaust survivor becomes US citizen
',
159 'description
': 'She survived the holocaust —
and years later
, she’s getting her citizenship so she can vote
for Hillary Clinton http
://cnn
.it
/2eERh5f
',
160 'timestamp
': 1477818095,
161 'upload_date
': '20161030',
163 'thumbnail
': r're
:^https?
://.*',
167 # bigPipe.onPageletArrive ... onPageletArrive pagelet_group_mall
168 # data.node.comet_sections.content.story.attachments[].style_type_renderer.attachment.media
169 'url
': 'https
://www
.facebook
.com
/yaroslav
.korpan
/videos
/1417995061575415/',
171 'id': '1417995061575415',
173 'title
': 'Ukrainian Scientists Worldwide | Довгоочікуване відео
',
174 'description
': 'Довгоочікуване відео
',
175 'timestamp
': 1486648771,
176 'upload_date
': '20170209',
177 'uploader
': 'Yaroslav Korpan
',
178 'uploader_id
': '100000948048708',
181 'skip_download
': True,
185 'url
': 'https
://www
.facebook
.com
/LaGuiaDelVaron
/posts
/1072691702860471',
187 'id': '1072691702860471',
189 'title
': 'md5
:ae2d22a93fbb12dad20dc393a869739d
',
190 'timestamp
': 1477305000,
191 'upload_date
': '20161024',
192 'uploader
': 'La Guía Del Varón
',
193 'thumbnail
': r're
:^https?
://.*',
196 'skip_download
': True,
199 # data.node.comet_sections.content.story.attachments[].style_type_renderer.attachment.media
200 'url
': 'https
://www
.facebook
.com
/groups
/1024490957622648/permalink
/1396382447100162/',
202 'id': '202882990186699',
204 'title
': 'birb (O v O
") | Hello? Yes your uber ride is here',
205 'description': 'Hello? Yes your uber ride is here * Jukin Media Verified * Find this video and others like it by visiting...',
206 'timestamp': 1486035513,
207 'upload_date': '20170202',
208 'uploader': 'Elisabeth Ahtn',
209 'uploader_id': '100013949973717',
212 'skip_download': True,
215 'url': 'https://www.facebook.com/video.php?v=10204634152394104',
216 'only_matching': True,
218 'url': 'https://www.facebook.com/amogood/videos/1618742068337349/?fref=nf',
219 'only_matching': True,
221 # data.mediaset.currMedia.edges
222 'url': 'https://www.facebook.com/ChristyClarkForBC/videos/vb.22819070941/10153870694020942/?type=2&theater',
223 'only_matching': True,
225 # data.video.story.attachments[].media
226 'url': 'facebook:544765982287235',
227 'only_matching': True,
229 # data.node.comet_sections.content.story.attachments[].style_type_renderer.attachment.media
230 'url': 'https://www.facebook.com/groups/164828000315060/permalink/764967300301124/',
231 'only_matching': True,
233 # data.video.creation_story.attachments[].media
234 'url': 'https://zh-hk.facebook.com/peoplespower/videos/1135894589806027/',
235 'only_matching': True,
238 'url': 'https://www.facebookwkhpilnemxj7asaniu7vnjjbiltxjqhye3mhbshg7kx5tfyd.onion/video.php?v=274175099429670',
239 'only_matching': True,
242 'url': 'https://www.facebook.com/onlycleverentertainment/videos/1947995502095005/',
243 'only_matching': True,
246 'url': 'https://www.facebook.com/WatchESLOne/videos/359649331226507/',
248 'id': '359649331226507',
250 'title': 'Fnatic vs. EG - Group A - Opening Match - ESL One Birmingham Day 1',
251 'description': '#ESLOne VoD - Birmingham Finals Day#1 Fnatic vs. @Evil Geniuses',
252 'timestamp': 1527084179,
253 'upload_date': '20180523',
254 'uploader': 'ESL One Dota 2',
255 'uploader_id': '234218833769558',
258 'skip_download': True,
261 # data.node.comet_sections.content.story.attachments[].style_type_renderer.attachment.all_subattachments.nodes[].media
262 'url': 'https://www.facebook.com/100033620354545/videos/106560053808006/',
264 'id': '106560053808006',
268 # data.video.story.attachments[].media
269 'url': 'https://www.facebook.com/watch/?v=647537299265662',
270 'only_matching': True,
272 # FIXME: https://github.com/yt-dlp/yt-dlp/issues/542
273 # data.node.comet_sections.content.story.attachments[].style_type_renderer.attachment.all_subattachments.nodes[].media
274 'url': 'https://www.facebook.com/PankajShahLondon/posts/10157667649866271',
276 'id': '10157667649866271',
280 # data.nodes[].comet_sections.content.story.attachments[].style_type_renderer.attachment.media
281 'url': 'https://m.facebook.com/Alliance.Police.Department/posts/4048563708499330',
283 'id': '117576630041613',
285 # TODO: title can be extracted from video page
286 'title': 'Facebook video #117576630041613',
287 'uploader_id': '189393014416438',
288 'upload_date': '20201123',
289 'timestamp': 1606162592,
291 'skip': 'Requires logging in',
293 # node.comet_sections.content.story.attached_story.attachments.style_type_renderer.attachment.media
294 'url': 'https://www.facebook.com/groups/ateistiskselskab/permalink/10154930137678856/',
296 'id': '211567722618337',
298 'title': 'Facebook video #211567722618337',
299 'uploader_id': '127875227654254',
300 'upload_date': '20161122',
301 'timestamp': 1479793574,
305 # data.video.creation_story.attachments[].media
306 'url': 'https://www.facebook.com/watch/live/?v=1823658634322275',
307 'only_matching': True,
309 'url': 'https://www.facebook.com/watchparty/211641140192478',
311 'id': '211641140192478',
314 'skip': 'Requires logging in',
316 _SUPPORTED_PAGLETS_REGEX = r'(?:pagelet_group_mall|permalink_video_pagelet|hyperfeed_story_id_[0-9a-f]+)'
318 'graphURI': '/api/graphql/'
321 def _perform_login(self, username, password):
322 login_page_req = sanitized_Request(self._LOGIN_URL)
323 self._set_cookie('facebook.com', 'locale', 'en_US')
324 login_page = self._download_webpage(login_page_req, None,
325 note='Downloading login page',
326 errnote='Unable to download login page')
327 lsd = self._search_regex(
328 r'<input type="hidden
" name="lsd
" value="([^
"]*)"',
330 lgnrnd = self._search_regex(r'name
="lgnrnd" value
="([^"]*?
)"', login_page, 'lgnrnd')
337 'next': 'http://facebook.com/home.php',
338 'default_persistent': '0',
339 'legacy_return': '1',
343 request = sanitized_Request(self._LOGIN_URL, urlencode_postdata(login_form))
344 request.add_header('Content-Type', 'application/x-www-form-urlencoded')
346 login_results = self._download_webpage(request, None,
347 note='Logging in', errnote='unable to fetch login page')
348 if re.search(r'<form(.*)name="login
"(.*)</form>', login_results) is not None:
349 error = self._html_search_regex(
350 r'(?s)<div[^>]+class=(["\']).*?login_error_box
.*?\
1[^
>]*><div
[^
>]*>.*?
</div
><div
[^
>]*>(?P
<error
>.+?
)</div
>',
351 login_results, 'login error
', default=None, group='error
')
353 raise ExtractorError('Unable to login
: %s' % error, expected=True)
354 self.report_warning('unable to log
in: bad username
/password
, or exceeded login rate
limit (~
3/min). Check credentials
or wait
.')
357 fb_dtsg = self._search_regex(
358 r'name
="fb_dtsg" value
="(.+?)"', login_results, 'fb_dtsg
', default=None)
359 h = self._search_regex(
360 r'name
="h"\s
+(?
:\w
+="[^"]+"\s+)*?value="([^
"]+)"', login_results, 'h
', default=None)
362 if not fb_dtsg or not h:
368 'name_action_selected
': 'dont_save
',
370 check_req = sanitized_Request(self._CHECKPOINT_URL, urlencode_postdata(check_form))
371 check_req.add_header('Content
-Type
', 'application
/x
-www
-form
-urlencoded
')
372 check_response = self._download_webpage(check_req, None,
373 note='Confirming login
')
374 if re.search(r'id="checkpointSubmitButton"', check_response) is not None:
375 self.report_warning('Unable to confirm login
, you have to login
in your browser
and authorize the login
.')
376 except network_exceptions as err:
377 self.report_warning('unable to log
in: %s' % error_to_compat_str(err))
380 def _extract_from_url(self, url, video_id):
381 webpage = self._download_webpage(
382 url.replace('://m
.facebook
.com
/', '://www
.facebook
.com
/'), video_id)
384 def extract_metadata(webpage):
385 post_data = [self._parse_json(j, video_id, fatal=False) for j in re.findall(
386 r'handleWithCustomApplyEach\
(\s
*ScheduledApplyEach\s
*,\s
*(\{.+?\}
)\s
*\
);', webpage)]
387 post = traverse_obj(post_data, (
388 ..., 'require
', ..., ..., ..., '__bbox
', 'result
', 'data
'), expected_type=dict) or []
389 media = traverse_obj(post, (..., 'attachments
', ..., lambda k, v: (
390 k == 'media
' and str(v['id']) == video_id and v['__typename
'] == 'Video
')), expected_type=dict)
391 title = get_first(media, ('title
', 'text
'))
392 description = get_first(media, ('creation_story
', 'comet_sections
', 'message
', 'story
', 'message
', 'text
'))
393 uploader_data = get_first(media, 'owner
') or get_first(post, ('node
', 'actors
', ...)) or {}
395 page_title = title or self._html_search_regex((
396 r'<h2\s
+[^
>]*class="uiHeaderTitle"[^
>]*>(?P
<content
>[^
<]*)</h2
>',
397 r'(?s
)<span
class="fbPhotosPhotoCaption".*?
id="fbPhotoPageCaption"><span
class="hasCaption">(?P
<content
>.*?
)</span
>',
398 self._meta_regex('og
:title
'), self._meta_regex('twitter
:title
'), r'<title
>(?P
<content
>.+?
)</title
>'
399 ), webpage, 'title
', default=None, group='content
')
400 description = description or self._html_search_meta(
401 ['description
', 'og
:description
', 'twitter
:description
'],
402 webpage, 'description
', default=None)
403 uploader = uploader_data.get('name
') or (
404 clean_html(get_element_by_id('fbPhotoPageAuthorName
', webpage))
405 or self._search_regex(
406 (r'ownerName\s
*:\s
*"([^"]+)"', *self._og_regexes('title')), webpage, 'uploader', fatal=False))
408 timestamp = int_or_none(self._search_regex(
409 r'<abbr[^>]+data-utime=["\'](\d
+)', webpage,
410 'timestamp
', default=None))
411 thumbnail = self._html_search_meta(
412 ['og
:image
', 'twitter
:image
'], webpage, 'thumbnail
', default=None)
413 # some webpages contain unretrievable thumbnail urls
414 # like https://lookaside.fbsbx.com/lookaside/crawler/media/?media_id=10155168902769113&get_thumbnail=1
415 # in https://www.facebook.com/yaroslav.korpan/videos/1417995061575415/
416 if thumbnail and not re.search(r'\
.(?
:jpg|png
)', thumbnail):
418 view_count = parse_count(self._search_regex(
419 r'\bviewCount\s
*:\s
*["\']([\d,.]+)', webpage, 'view count',
422 'description': description,
423 'uploader': uploader,
424 'uploader_id': uploader_data.get('id'),
425 'timestamp': timestamp,
426 'thumbnail': thumbnail,
427 'view_count': view_count,
430 info_json_ld = self._search_json_ld(webpage, video_id, default={})
431 info_json_ld['title'] = (re.sub(r'\s*\|\s*Facebook$', '', title or info_json_ld.get('title') or page_title or '')
432 or (description or '').replace('\n', ' ') or f'Facebook video #{video_id}')
433 return merge_dicts(info_json_ld, info_dict)
437 def extract_video_data(instances):
439 for item in instances:
440 if try_get(item, lambda x: x[1][0]) == 'VideoConfig':
441 video_item = item[2][0]
442 if video_item.get('video_id'):
443 video_data.append(video_item['videoData'])
446 server_js_data = self._parse_json(self._search_regex(
447 [r'handleServerJS\(({.+})(?:\);|,")', r'\bs\
.handle\
(({.+?}
)\
);'],
448 webpage, 'server js data
', default='{}'), video_id, fatal=False)
451 video_data = extract_video_data(server_js_data.get('instances
', []))
453 def extract_from_jsmods_instances(js_data):
455 return extract_video_data(try_get(
456 js_data, lambda x: x['jsmods
']['instances
'], list) or [])
458 def extract_dash_manifest(video, formats):
459 dash_manifest = video.get('dash_manifest
')
461 formats.extend(self._parse_mpd_formats(
462 compat_etree_fromstring(urllib.parse.unquote_plus(dash_manifest))))
464 def process_formats(formats):
465 # Downloads with browser's User
-Agent are rate limited
. Working around
466 # with non-browser User-Agent.
468 f
.setdefault('http_headers', {})['User-Agent'] = 'facebookexternalhit/1.1'
470 self
._sort
_formats
(formats
, ('res', 'quality'))
472 def extract_relay_data(_filter
):
473 return self
._parse
_json
(self
._search
_regex
(
474 r
'handleWithCustomApplyEach\([^,]+,\s*({.*?%s.*?})\);' % _filter
,
475 webpage
, 'replay data', default
='{}'), video_id, fatal=False) or {}
477 def extract_relay_prefetched_data(_filter):
478 replay_data = extract_relay_data(_filter)
479 for require in (replay_data.get('require
') or []):
480 if require[0] == 'RelayPrefetchedStreamCache
':
481 return try_get(require, lambda x: x[3][1]['__bbox
']['result
']['data
'], dict) or {}
484 server_js_data = self._parse_json(self._search_regex([
485 r'bigPipe\
.onPageletArrive\
(({.+?}
)\
)\s
*;\s
*}\s
*\
)\s
*,\s
*["\']onPageletArrive\s+' + self._SUPPORTED_PAGLETS_REGEX,
486 r'bigPipe\.onPageletArrive\(({.*?id\s*:\s*"%s".*?})\);' % self._SUPPORTED_PAGLETS_REGEX
487 ], webpage, 'js data', default='{}'), video_id, js_to_json, False)
488 video_data = extract_from_jsmods_instances(server_js_data)
491 data = extract_relay_prefetched_data(
492 r'"(?
:dash_manifest|
playable_url(?
:_quality_hd
)?
)"\s*:\s*"[^
"]+"')
496 def parse_graphql_video(video):
498 q = qualities(['sd
', 'hd
'])
499 for key, format_id in (('playable_url
', 'sd
'), ('playable_url_quality_hd
', 'hd
'),
500 ('playable_url_dash
', '')):
501 playable_url = video.get(key)
504 if determine_ext(playable_url) == 'mpd
':
505 formats.extend(self._extract_mpd_formats(playable_url, video_id))
508 'format_id
': format_id,
509 'quality
': q(format_id),
512 extract_dash_manifest(video, formats)
513 process_formats(formats)
514 v_id = video.get('videoId
') or video.get('id') or video_id
518 'thumbnail
': traverse_obj(
519 video, ('thumbnailImage
', 'uri
'), ('preferred_thumbnail
', 'image
', 'uri
')),
520 'uploader_id
': try_get(video, lambda x: x['owner
']['id']),
521 'timestamp
': int_or_none(video.get('publish_time
')),
522 'duration
': float_or_none(video.get('playable_duration_in_ms
'), 1000),
524 description = try_get(video, lambda x: x['savable_description
']['text
'])
525 title = video.get('name
')
529 'description
': description,
532 info['title
'] = description or 'Facebook video
#%s' % v_id
535 def parse_attachment(attachment
, key
='media'):
536 media
= attachment
.get(key
) or {}
537 if media
.get('__typename') == 'Video':
538 return parse_graphql_video(media
)
540 nodes
= variadic(traverse_obj(data
, 'nodes', 'node') or [])
541 attachments
= traverse_obj(nodes
, (
542 ..., 'comet_sections', 'content', 'story', (None, 'attached_story'), 'attachments',
543 ..., ('styles', 'style_type_renderer'), 'attachment'), expected_type
=dict) or []
544 for attachment
in attachments
:
545 ns
= try_get(attachment
, lambda x
: x
['all_subattachments']['nodes'], list) or []
548 parse_attachment(attachment
)
550 edges
= try_get(data
, lambda x
: x
['mediaset']['currMedia']['edges'], list) or []
552 parse_attachment(edge
, key
='node')
554 video
= data
.get('video') or {}
556 attachments
= try_get(video
, [
557 lambda x
: x
['story']['attachments'],
558 lambda x
: x
['creation_story']['attachments']
560 for attachment
in attachments
:
561 parse_attachment(attachment
)
563 parse_graphql_video(video
)
566 return self
.playlist_result(entries
, video_id
)
568 video_info
= entries
[0]
569 webpage_info
= extract_metadata(webpage
)
570 # honor precise duration in video info
571 if video_info
.get('duration'):
572 webpage_info
['duration'] = video_info
['duration']
573 return merge_dicts(webpage_info
, video_info
)
576 m_msg
= re
.search(r
'class="[^"]*uiInterstitialContent[^"]*"><div>(.*?)</div>', webpage
)
577 if m_msg
is not None:
578 raise ExtractorError(
579 'The video is not available, Facebook said: "%s"' % m_msg
.group(1),
581 elif any(p
in webpage
for p
in (
582 '>You must log in to continue',
584 'id="loginbutton"')):
585 self
.raise_login_required()
587 if not video_data
and '/watchparty/' in url
:
589 'doc_id': 3731964053542869,
590 'variables': json
.dumps({
591 'livingRoomID': video_id
,
595 prefetched_data
= extract_relay_prefetched_data(r
'"login_data"\s*:\s*{')
597 lsd
= try_get(prefetched_data
, lambda x
: x
['login_data']['lsd'], dict)
599 post_data
[lsd
['name']] = lsd
['value']
601 relay_data
= extract_relay_data(r
'\[\s*"RelayAPIConfigDefaults"\s*,')
602 for define
in (relay_data
.get('define') or []):
603 if define
[0] == 'RelayAPIConfigDefaults':
604 self
._api
_config
= define
[2]
606 living_room
= self
._download
_json
(
607 urljoin(url
, self
._api
_config
['graphURI']), video_id
,
608 data
=urlencode_postdata(post_data
))['data']['living_room']
611 for edge
in (try_get(living_room
, lambda x
: x
['recap']['watched_content']['edges']) or []):
612 video
= try_get(edge
, lambda x
: x
['node']['video']) or {}
613 v_id
= video
.get('id')
616 v_id
= compat_str(v_id
)
617 entries
.append(self
.url_result(
618 self
._VIDEO
_PAGE
_TEMPLATE
% v_id
,
619 self
.ie_key(), v_id
, video
.get('name')))
621 return self
.playlist_result(entries
, video_id
)
624 # Video info not in first request, do a secondary request using
625 # tahoe player specific URL
626 tahoe_data
= self
._download
_webpage
(
627 self
._VIDEO
_PAGE
_TAHOE
_TEMPLATE
% video_id
, video_id
,
628 data
=urlencode_postdata({
630 '__pc': self
._search
_regex
(
631 r
'pkg_cohort["\']\s
*:\s
*["\'](.+?)["\']', webpage,
632 'pkg cohort
', default='PHASED
:DEFAULT
'),
633 '__rev
': self._search_regex(
634 r'client_revision
["\']\s*:\s*(\d+),', webpage,
635 'client revision', default='3944515'),
636 'fb_dtsg': self._search_regex(
637 r'"DTSGInitialData
"\s*,\s*\[\]\s*,\s*{\s*"token
"\s*:\s*"([^
"]+)"',
638 webpage, 'dtsg token
', default=''),
641 'Content
-Type
': 'application
/x
-www
-form
-urlencoded
',
643 tahoe_js_data = self._parse_json(
645 r'for\s
+\
(\s
*;\s
*;\s
*\
)\s
*;(.+)', tahoe_data,
646 'tahoe js data
', default='{}'),
647 video_id, fatal=False)
648 video_data = extract_from_jsmods_instances(tahoe_js_data)
651 raise ExtractorError('Cannot parse data
')
653 if len(video_data) > 1:
656 video_url = v[0].get('video_url
')
659 entries.append(self.url_result(urljoin(
660 url, video_url), self.ie_key(), v[0].get('video_id
')))
661 return self.playlist_result(entries, video_id)
662 video_data = video_data[0]
667 format_id = f['stream_type
']
668 if f and isinstance(f, dict):
670 if not f or not isinstance(f, list):
672 for quality in ('sd
', 'hd
'):
673 for src_type in ('src
', 'src_no_ratelimit
'):
674 src = f[0].get('%s_%s' % (quality, src_type))
676 preference = -10 if format_id == 'progressive
' else -1
680 'format_id
': '%s_%s_%s' % (format_id, quality, src_type),
682 'quality
': preference,
683 'height
': 720 if quality == 'hd
' else None
685 extract_dash_manifest(f[0], formats)
686 subtitles_src = f[0].get('subtitles_src
')
688 subtitles.setdefault('en
', []).append({'url': subtitles_src})
690 process_formats(formats)
695 'subtitles
': subtitles,
697 info_dict.update(extract_metadata(webpage))
701 def _real_extract(self, url):
702 video_id = self._match_id(url)
704 real_url = self._VIDEO_PAGE_TEMPLATE % video_id if url.startswith('facebook
:') else url
705 return self._extract_from_url(real_url, video_id)
708 class FacebookPluginsVideoIE(InfoExtractor):
709 _VALID_URL = r'https?
://(?
:[\w
-]+\
.)?facebook\
.com
/plugins
/video\
.php
\?.*?
\bhref
=(?P
<id>https
.+)'
712 'url
': 'https
://www
.facebook
.com
/plugins
/video
.php?href
=https
%3A
%2F
%2Fwww
.facebook
.com
%2Fgov
.sg
%2Fvideos
%2F10154383743583686
%2F
&show_text
=0&width
=560',
713 'md5
': '5954e92cdfe51fe5782ae9bda7058a07
',
715 'id': '10154383743583686',
717 # TODO: Fix title, uploader
718 'title
': 'What to do during the haze?
',
719 'uploader
': 'Gov
.sg
',
720 'upload_date
': '20160826',
721 'timestamp
': 1472184808,
723 'add_ie
': [FacebookIE.ie_key()],
725 'url
': 'https
://www
.facebook
.com
/plugins
/video
.php?href
=https
%3A
%2F
%2Fwww
.facebook
.com
%2Fvideo
.php
%3Fv
%3D10204634152394104
',
726 'only_matching
': True,
728 'url
': 'https
://www
.facebook
.com
/plugins
/video
.php?href
=https
://www
.facebook
.com
/gov
.sg
/videos
/10154383743583686/&show_text
=0&width
=560',
729 'only_matching
': True,
732 def _real_extract(self, url):
733 return self.url_result(
734 compat_urllib_parse_unquote(self._match_id(url)),
738 class FacebookRedirectURLIE(InfoExtractor):
739 IE_DESC = False # Do not list
740 _VALID_URL = r'https?
://(?
:[\w
-]+\
.)?facebook\
.com
/flx
/warn
[/?
]'
742 'url
': 'https
://www
.facebook
.com
/flx
/warn
/?h
=TAQHsoToz
&u
=https
%3A
%2F
%2Fwww
.youtube
.com
%2Fwatch
%3Fv
%3DpO8h3EaFRdo
&s
=1',
746 'title
': 'Tripeo Boiler Room x Dekmantel Festival DJ Set
',
747 'description
': 'md5
:2d713ccbb45b686a1888397b2c77ca6b
',
748 'channel_id
': 'UCGBpxWJr9FNOcFYA5GkKrMg
',
749 'playable_in_embed
': True,
750 'categories
': ['Music
'],
751 'channel
': 'Boiler Room
',
752 'uploader_id
': 'brtvofficial
',
753 'uploader
': 'Boiler Room
',
756 'live_status
': 'not_live
',
757 'thumbnail
': 'https
://i
.ytimg
.com
/vi
/pO8h3EaFRdo
/maxresdefault
.jpg
',
758 'channel_url
': 'https
://www
.youtube
.com
/channel
/UCGBpxWJr9FNOcFYA5GkKrMg
',
759 'availability
': 'public
',
760 'uploader_url
': 'http
://www
.youtube
.com
/user
/brtvofficial
',
761 'upload_date
': '20150917',
766 'add_ie
': ['Youtube
'],
767 'params
': {'skip_download': 'Youtube'},
770 def _real_extract(self, url):
771 redirect_url = url_or_none(parse_qs(url).get('u
', [None])[-1])
773 raise ExtractorError('Invalid facebook redirect URL
', expected=True)
774 return self.url_result(redirect_url)
777 class FacebookReelIE(InfoExtractor):
778 _VALID_URL = r'https?
://(?
:[\w
-]+\
.)?facebook\
.com
/reel
/(?P
<id>\d
+)'
779 IE_NAME = 'facebook
:reel
'
782 'url
': 'https
://www
.facebook
.com
/reel
/1195289147628387',
783 'md5
': 'c4ff9a7182ff9ff7d6f7a83603bae831
',
785 'id': '1195289147628387',
787 'title
': 'md5
:9f5b142921b2dc57004fa13f76005f87
',
788 'description
': 'md5
:24ea7ef062215d295bdde64e778f5474
',
789 'uploader
': 'Beast Camp Training
',
790 'uploader_id
': '1738535909799870',
792 'thumbnail
': r're
:^https?
://.*',
793 'upload_date
': '20211121',
794 'timestamp
': 1637502604,
798 def _real_extract(self, url):
799 video_id = self._match_id(url)
800 return self.url_result(
801 f'https
://m
.facebook
.com
/watch
/?v
={video_id}
&_rdr
', FacebookIE, video_id)