2015-03-31 20:49:08 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
import re
|
|
|
|
import json
|
|
|
|
import copy
|
2018-01-30 22:07:21 +01:00
|
|
|
from urllib.parse import unquote_plus
|
2015-03-31 20:49:08 +02:00
|
|
|
|
|
|
|
from svtplay_dl.service import Service, OpenGraphThumbMixin
|
|
|
|
from svtplay_dl.fetcher.http import HTTP
|
2015-09-06 14:19:10 +02:00
|
|
|
from svtplay_dl.error import ServiceError
|
2015-03-31 20:49:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Facebook(Service, OpenGraphThumbMixin):
|
|
|
|
supported_domains_re = ["www.facebook.com"]
|
|
|
|
|
2015-12-26 11:46:14 +01:00
|
|
|
def get(self):
|
2015-08-30 00:06:20 +02:00
|
|
|
data = self.get_urldata()
|
2015-03-31 20:49:08 +02:00
|
|
|
|
|
|
|
match = re.search('params","([^"]+)"', data)
|
|
|
|
if not match:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Cant find params info. video need to be public.")
|
2015-03-31 20:49:08 +02:00
|
|
|
return
|
2017-10-09 22:35:13 +02:00
|
|
|
data2 = json.loads('["{0}"]'.format(match.group(1)))
|
2015-03-31 20:49:08 +02:00
|
|
|
data2 = json.loads(unquote_plus(data2[0]))
|
2015-11-29 16:40:29 +01:00
|
|
|
if "sd_src_no_ratelimit" in data2["video_data"]["progressive"][0]:
|
2018-05-13 13:06:45 +02:00
|
|
|
yield HTTP(copy.copy(self.config), data2["video_data"]["progressive"][0]["sd_src_no_ratelimit"], "240")
|
2015-03-31 20:49:08 +02:00
|
|
|
else:
|
2018-05-13 13:06:45 +02:00
|
|
|
yield HTTP(copy.copy(self.config), data2["video_data"]["progressive"][0]["sd_src"], "240")
|
2015-11-29 16:40:29 +01:00
|
|
|
if "hd_src_no_ratelimit" in data2["video_data"]["progressive"][0]:
|
2018-05-13 13:06:45 +02:00
|
|
|
yield HTTP(copy.copy(self.config), data2["video_data"]["progressive"][0]["hd_src_no_ratelimit"], "720")
|
2015-03-31 20:49:08 +02:00
|
|
|
else:
|
2015-11-29 16:40:29 +01:00
|
|
|
if data2["video_data"]["progressive"][0]["hd_src"]:
|
2018-05-13 13:06:45 +02:00
|
|
|
yield HTTP(copy.copy(self.config), data2["video_data"]["progressive"][0]["hd_src"], "720")
|