From 967457dc517009f3358f307c2b3076b933c5cf9f Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Sat, 26 Jan 2013 23:50:38 +0100 Subject: [PATCH] add support for Facebook, fix #74 --- README.md | 2 ++ README.txt | 1 + you_get/downloader/__init__.py | 1 + you_get/downloader/facebook.py | 25 +++++++++++++++++++++++++ you_get/main.py | 1 + 5 files changed, 30 insertions(+) create mode 100644 you_get/downloader/facebook.py diff --git a/README.md b/README.md index ecc61b88..2c8ce16b 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Fork me on GitHub: * YouTube * Vimeo * Dailymotion +* Facebook * Google+ * Tumblr * SoundCloud @@ -205,6 +206,7 @@ You-Get基于优酷下载脚本[iambus/youku-lixian](https://github.com/iambus/y * YouTube * Vimeo * Dailymotion +* Facebook * Google+ * Tumblr * SoundCloud diff --git a/README.txt b/README.txt index 262c7cbc..01f6d559 100644 --- a/README.txt +++ b/README.txt @@ -16,6 +16,7 @@ Supported Sites (As of Now) * YouTube http://www.youtube.com * Vimeo http://vimeo.com * Dailymotion http://dailymotion.com +* Facebook http://facebook.com * Google+ http://plus.google.com * Tumblr http://www.tumblr.com * SoundCloud http://soundcloud.com diff --git a/you_get/downloader/__init__.py b/you_get/downloader/__init__.py index 71d32301..b25bcb0a 100644 --- a/you_get/downloader/__init__.py +++ b/you_get/downloader/__init__.py @@ -4,6 +4,7 @@ from .acfun import * from .bilibili import * from .cntv import * from .dailymotion import * +from .facebook import * from .googleplus import * from .ifeng import * from .iqiyi import * diff --git a/you_get/downloader/facebook.py b/you_get/downloader/facebook.py new file mode 100644 index 00000000..5be7313b --- /dev/null +++ b/you_get/downloader/facebook.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +__all__ = ['facebook_download'] + +from ..common import * + +def facebook_download(url, output_dir = '.', merge = True, info_only = False): + html = get_html(url) + + title = r1(r'(.+) \| Facebook', html) + + for fmt in ["hd_src", "sd_src"]: + src = parse.unquote(unicodize(r1(r'\["' + fmt + '","([^"]*)', html))) + if src: + break + + type, ext, size = url_info(src) + + print_info(site_info, title, type, size) + if not info_only: + download_urls([src], title, ext, size, output_dir, merge = merge) + +site_info = "Facebook.com" +download = facebook_download +download_playlist = playlist_not_supported('facebook') diff --git a/you_get/main.py b/you_get/main.py index cd843147..8083398b 100644 --- a/you_get/main.py +++ b/you_get/main.py @@ -24,6 +24,7 @@ def url_to_module(url): 'bilibili': bilibili, 'cntv': cntv, 'dailymotion': dailymotion, + 'facebook': facebook, 'google': googleplus, 'iask': sina, 'ifeng': ifeng,