mirror of
https://github.com/soimort/you-get.git
synced 2025-02-03 08:43:58 +03:00
Fix facebook extractor
Previously would throw error if there is no hd_src Modified to use json parser and check if hd_src is None
This commit is contained in:
parent
e22fb5269d
commit
90fb2f4842
@ -3,18 +3,22 @@
|
|||||||
__all__ = ['facebook_download']
|
__all__ = ['facebook_download']
|
||||||
|
|
||||||
from ..common import *
|
from ..common import *
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
def facebook_download(url, output_dir='.', merge=True, info_only=False):
|
def facebook_download(url, output_dir='.', merge=True, info_only=False):
|
||||||
html = get_html(url)
|
html = get_html(url)
|
||||||
|
|
||||||
title = r1(r'<title id="pageTitle">(.+) \| Facebook</title>', html)
|
title = r1(r'<title id="pageTitle">(.+) \| Facebook</title>', html)
|
||||||
|
s2 = parse.unquote(unicodize(r1(r'\["params","([^"]*)"\]', html)))
|
||||||
|
data = json.loads(s2)
|
||||||
|
video_data = data["video_data"][0]
|
||||||
for fmt in ["hd_src", "sd_src"]:
|
for fmt in ["hd_src", "sd_src"]:
|
||||||
src= re.sub(r'\\/', r'/', r1(r'"' + fmt + '":"([^"]*)"', parse.unquote(unicodize(r1(r'\["params","([^"]*)"\]', html)))))
|
src = video_data[fmt]
|
||||||
if src:
|
if src:
|
||||||
break
|
break
|
||||||
|
|
||||||
type, ext, size = url_info(src)
|
type, ext, size = url_info(src, True)
|
||||||
|
|
||||||
print_info(site_info, title, type, size)
|
print_info(site_info, title, type, size)
|
||||||
if not info_only:
|
if not info_only:
|
||||||
|
Loading…
Reference in New Issue
Block a user