you-get/src/you_get/extractors/facebook.py

30 lines
806 B
Python
Raw Normal View History

2013-01-27 02:50:38 +04:00
#!/usr/bin/env python
__all__ = ['facebook_download']
from ..common import *
import json
2013-01-27 02:50:38 +04:00
def facebook_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
2013-01-27 02:50:38 +04:00
html = get_html(url)
2013-01-27 02:50:38 +04:00
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]
2013-01-27 02:50:38 +04:00
for fmt in ["hd_src", "sd_src"]:
src = video_data[fmt]
2013-01-27 02:50:38 +04:00
if src:
break
type, ext, size = url_info(src, True)
2013-01-27 02:50:38 +04:00
print_info(site_info, title, type, size)
if not info_only:
download_urls([src], title, ext, size, output_dir, merge=merge)
2013-01-27 02:50:38 +04:00
site_info = "Facebook.com"
download = facebook_download
download_playlist = playlist_not_supported('facebook')