2015-03-31 20:49:08 +02:00
|
|
|
import copy
|
2019-08-25 00:40:39 +02:00
|
|
|
import json
|
|
|
|
import re
|
2018-01-30 22:07:21 +01:00
|
|
|
from urllib.parse import unquote_plus
|
2015-03-31 20:49:08 +02:00
|
|
|
|
2015-09-06 14:19:10 +02:00
|
|
|
from svtplay_dl.error import ServiceError
|
2019-08-25 00:40:39 +02:00
|
|
|
from svtplay_dl.fetcher.http import HTTP
|
|
|
|
from svtplay_dl.service import OpenGraphThumbMixin
|
|
|
|
from svtplay_dl.service import Service
|
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
|
2021-04-27 19:44:09 +02:00
|
|
|
data2 = json.loads(f'["{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]:
|
2019-09-06 22:49:49 +02:00
|
|
|
yield HTTP(copy.copy(self.config), data2["video_data"]["progressive"][0]["sd_src_no_ratelimit"], "240", output=self.output)
|
2015-03-31 20:49:08 +02:00
|
|
|
else:
|
2019-09-06 22:49:49 +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]:
|
2019-09-06 22:49:49 +02:00
|
|
|
yield HTTP(copy.copy(self.config), data2["video_data"]["progressive"][0]["hd_src_no_ratelimit"], "720", output=self.output)
|
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"]:
|
2019-09-06 22:49:49 +02:00
|
|
|
yield HTTP(copy.copy(self.config), data2["video_data"]["progressive"][0]["hd_src"], "720", output=self.output)
|