mirror of https://github.com/yt-dlp/yt-dlp.git
[facebook] Fix invalid video being extracted (Closes #9851)
This commit is contained in:
parent
07d7689f2e
commit
cedc70b292
|
@ -219,12 +219,23 @@ class FacebookIE(InfoExtractor):
|
||||||
|
|
||||||
BEFORE = '{swf.addParam(param[0], param[1]);});'
|
BEFORE = '{swf.addParam(param[0], param[1]);});'
|
||||||
AFTER = '.forEach(function(variable) {swf.addVariable(variable[0], variable[1]);});'
|
AFTER = '.forEach(function(variable) {swf.addVariable(variable[0], variable[1]);});'
|
||||||
m = re.search(re.escape(BEFORE) + '(?:\n|\\\\n)(.*?)' + re.escape(AFTER), webpage)
|
PATTERN = re.escape(BEFORE) + '(?:\n|\\\\n)(.*?)' + re.escape(AFTER)
|
||||||
if m:
|
|
||||||
swf_params = m.group(1).replace('\\\\', '\\').replace('\\"', '"')
|
for m in re.findall(PATTERN, webpage):
|
||||||
|
swf_params = m.replace('\\\\', '\\').replace('\\"', '"')
|
||||||
data = dict(json.loads(swf_params))
|
data = dict(json.loads(swf_params))
|
||||||
params_raw = compat_urllib_parse_unquote(data['params'])
|
params_raw = compat_urllib_parse_unquote(data['params'])
|
||||||
video_data = json.loads(params_raw)['video_data']
|
video_data_candidate = json.loads(params_raw)['video_data']
|
||||||
|
for _, f in video_data_candidate.items():
|
||||||
|
if not f:
|
||||||
|
continue
|
||||||
|
if isinstance(f, dict):
|
||||||
|
f = [f]
|
||||||
|
if isinstance(f, list):
|
||||||
|
continue
|
||||||
|
if f[0].get('video_id') == video_id:
|
||||||
|
video_data = video_data_candidate
|
||||||
|
break
|
||||||
|
|
||||||
def video_data_list2dict(video_data):
|
def video_data_list2dict(video_data):
|
||||||
ret = {}
|
ret = {}
|
||||||
|
|
Loading…
Reference in New Issue