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

36 lines
965 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)
2016-06-23 23:13:15 +03:00
title = r1(r'<title id="pageTitle">(.+)</title>', html)
if title is None:
title = url
sd_urls = list(set([
2016-06-23 23:13:15 +03:00
unicodize(str.replace(i, '\\/', '/'))
2017-01-17 01:29:21 +03:00
for i in re.findall(r'sd_src_no_ratelimit:"([^"]*)"', html)
]))
hd_urls = list(set([
unicodize(str.replace(i, '\\/', '/'))
2017-01-17 01:29:21 +03:00
for i in re.findall(r'hd_src_no_ratelimit:"([^"]*)"', html)
]))
urls = hd_urls if hd_urls else sd_urls
type, ext, size = url_info(urls[0], True)
size = urls_size(urls)
2013-01-27 02:50:38 +04:00
print_info(site_info, title, type, size)
if not info_only:
download_urls(urls, title, ext, size, output_dir, merge=False)
2013-01-27 02:50:38 +04:00
site_info = "Facebook.com"
download = facebook_download
download_playlist = playlist_not_supported('facebook')