Link Here
|
74 |
_VIDEO_PAGE_TAHOE_TEMPLATE = 'https://www.facebook.com/video/tahoe/async/%s/?chain=true&isvideo=true&payloadtype=primary' |
74 |
_VIDEO_PAGE_TAHOE_TEMPLATE = 'https://www.facebook.com/video/tahoe/async/%s/?chain=true&isvideo=true&payloadtype=primary' |
75 |
|
75 |
|
76 |
_TESTS = [{ |
76 |
_TESTS = [{ |
|
|
77 |
'url': 'https://www.facebook.com/radiokicksfm/videos/3676516585958356/', |
78 |
'info_dict': { |
79 |
'id': '3676516585958356', |
80 |
'ext': 'mp4', |
81 |
'title': 'dr Adam Przygoda', |
82 |
'description': 'md5:34675bda53336b1d16400265c2bb9b3b', |
83 |
'uploader': 'RADIO KICKS FM', |
84 |
'upload_date': '20230818', |
85 |
'timestamp': 1692346159, |
86 |
'thumbnail': r're:^https?://.*', |
87 |
'uploader_id': '100063551323670', |
88 |
'duration': 3132.184, |
89 |
'view_count': int, |
90 |
'concurrent_view_count': 0, |
91 |
}, |
92 |
}, { |
77 |
'url': 'https://www.facebook.com/video.php?v=637842556329505&fref=nf', |
93 |
'url': 'https://www.facebook.com/video.php?v=637842556329505&fref=nf', |
78 |
'md5': '6a40d33c0eccbb1af76cf0485a052659', |
94 |
'md5': '6a40d33c0eccbb1af76cf0485a052659', |
79 |
'info_dict': { |
95 |
'info_dict': { |
Link Here
|
401 |
|
417 |
|
402 |
def extract_metadata(webpage): |
418 |
def extract_metadata(webpage): |
403 |
post_data = [self._parse_json(j, video_id, fatal=False) for j in re.findall( |
419 |
post_data = [self._parse_json(j, video_id, fatal=False) for j in re.findall( |
404 |
r'handleWithCustomApplyEach\(\s*ScheduledApplyEach\s*,\s*(\{.+?\})\s*\);', webpage)] |
420 |
r'data-sjs>({.*?ScheduledServerJS.*?})</script>', webpage)] |
405 |
post = traverse_obj(post_data, ( |
421 |
post = traverse_obj(post_data, ( |
406 |
..., 'require', ..., ..., ..., '__bbox', 'result', 'data'), expected_type=dict) or [] |
422 |
..., 'require', ..., ..., ..., '__bbox', 'require', ..., ..., ..., '__bbox', 'result', 'data'), expected_type=dict) or [] |
407 |
media = traverse_obj(post, (..., 'attachments', ..., lambda k, v: ( |
423 |
media = traverse_obj(post, (..., 'attachments', ..., lambda k, v: ( |
408 |
k == 'media' and str(v['id']) == video_id and v['__typename'] == 'Video')), expected_type=dict) |
424 |
k == 'media' and str(v['id']) == video_id and v['__typename'] == 'Video')), expected_type=dict) |
409 |
title = get_first(media, ('title', 'text')) |
425 |
title = get_first(media, ('title', 'text')) |
Link Here
|
493 |
|
509 |
|
494 |
def extract_relay_data(_filter): |
510 |
def extract_relay_data(_filter): |
495 |
return self._parse_json(self._search_regex( |
511 |
return self._parse_json(self._search_regex( |
496 |
r'handleWithCustomApplyEach\([^,]+,\s*({.*?%s.*?})\);' % _filter, |
512 |
r'data-sjs>({.*?%s.*?})</script>' % _filter, |
497 |
webpage, 'replay data', default='{}'), video_id, fatal=False) or {} |
513 |
webpage, 'replay data', default='{}'), video_id, fatal=False) or {} |
498 |
|
514 |
|
499 |
def extract_relay_prefetched_data(_filter): |
515 |
def extract_relay_prefetched_data(_filter): |
500 |
replay_data = extract_relay_data(_filter) |
516 |
return traverse_obj(extract_relay_data(_filter), ( |
501 |
for require in (replay_data.get('require') or []): |
517 |
'require', (None, (..., ..., ..., '__bbox', 'require')), |
502 |
if require[0] == 'RelayPrefetchedStreamCache': |
518 |
lambda _, v: 'RelayPrefetchedStreamCache' in v, ..., ..., |
503 |
return try_get(require, lambda x: x[3][1]['__bbox']['result']['data'], dict) or {} |
519 |
'__bbox', 'result', 'data', {dict}), get_all=False) or {} |
504 |
|
520 |
|
505 |
if not video_data: |
521 |
if not video_data: |
506 |
server_js_data = self._parse_json(self._search_regex([ |
522 |
server_js_data = self._parse_json(self._search_regex([ |
Link Here
|
511 |
|
527 |
|
512 |
if not video_data: |
528 |
if not video_data: |
513 |
data = extract_relay_prefetched_data( |
529 |
data = extract_relay_prefetched_data( |
514 |
r'"(?:dash_manifest|playable_url(?:_quality_hd)?)"\s*:\s*"[^"]+"') |
530 |
r'"(?:dash_manifest|playable_url(?:_quality_hd)?)') |
515 |
if data: |
531 |
if data: |
516 |
entries = [] |
532 |
entries = [] |
517 |
|
533 |
|
Link Here
|
526 |
formats = [] |
542 |
formats = [] |
527 |
q = qualities(['sd', 'hd']) |
543 |
q = qualities(['sd', 'hd']) |
528 |
for key, format_id in (('playable_url', 'sd'), ('playable_url_quality_hd', 'hd'), |
544 |
for key, format_id in (('playable_url', 'sd'), ('playable_url_quality_hd', 'hd'), |
529 |
('playable_url_dash', '')): |
545 |
('playable_url_dash', ''), ('browser_native_hd_url', 'hd'), |
|
|
546 |
('browser_native_sd_url', 'sd')): |
530 |
playable_url = video.get(key) |
547 |
playable_url = video.get(key) |
531 |
if not playable_url: |
548 |
if not playable_url: |
532 |
continue |
549 |
continue |