1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-30 23:24:16 +01:00
svtplay-dl/lib/svtplay_dl/service/facebook.py

33 lines
1.4 KiB
Python
Raw Normal View History

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
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
class Facebook(Service, OpenGraphThumbMixin):
supported_domains_re = ["www.facebook.com"]
def get(self):
data = self.get_urldata()
match = re.search('params","([^"]+)"', data)
if not match:
yield ServiceError("Cant find params info. video need to be public.")
return
2019-08-25 00:33:51 +02:00
data2 = json.loads('["{}"]'.format(match.group(1)))
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]:
yield HTTP(copy.copy(self.config), data2["video_data"]["progressive"][0]["sd_src_no_ratelimit"], "240", output=self.output)
else:
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]:
yield HTTP(copy.copy(self.config), data2["video_data"]["progressive"][0]["hd_src_no_ratelimit"], "720", output=self.output)
else:
2015-11-29 16:40:29 +01:00
if data2["video_data"]["progressive"][0]["hd_src"]:
yield HTTP(copy.copy(self.config), data2["video_data"]["progressive"][0]["hd_src"], "720", output=self.output)