1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 21:54:17 +01:00

facebook: support for downloading public videos.

This commit is contained in:
Johan Andersson 2015-03-31 20:49:08 +02:00
parent 1d3f3ac96f
commit 6f20126ff7
2 changed files with 37 additions and 0 deletions

View File

@ -24,6 +24,7 @@ from svtplay_dl.service.dbtv import Dbtv
from svtplay_dl.service.disney import Disney
from svtplay_dl.service.dr import Dr
from svtplay_dl.service.expressen import Expressen
from svtplay_dl.service.facebook import Facebook
from svtplay_dl.service.hbo import Hbo
from svtplay_dl.service.justin import Justin
from svtplay_dl.service.kanal5 import Kanal5
@ -56,6 +57,7 @@ sites = [
Disney,
Dr,
Expressen,
Facebook,
Hbo,
Justin,
Lemonwhale,

View File

@ -0,0 +1,35 @@
from __future__ import absolute_import
import re
import json
import copy
from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.utils.urllib import unquote_plus
from svtplay_dl.fetcher.http import HTTP
from svtplay_dl.log import log
class Facebook(Service, OpenGraphThumbMixin):
supported_domains_re = ["www.facebook.com"]
def get(self, options):
error, data = self.get_urldata()
if error:
log.error("Cant download page")
return
match = re.search('params","([^"]+)"', data)
if not match:
log.error("Cant find params info. public video?")
return
data2 = json.loads('["%s"]' % match.group(1))
data2 = json.loads(unquote_plus(data2[0]))
if "sd_src_no_ratelimit" in data2["video_data"][0]:
yield HTTP(copy.copy(options), data2["video_data"][0]["sd_src_no_ratelimit"], "240")
else:
yield HTTP(copy.copy(options), data2["video_data"][0]["sd_src"], "240")
if "hd_src_no_ratelimit" in data2["video_data"][0]:
yield HTTP(copy.copy(options), data2["video_data"][0]["hd_src_no_ratelimit"], "720")
else:
if data2["video_data"][0]["hd_src"]:
yield HTTP(copy.copy(options), data2["video_data"][0]["hd_src"], "720")