2017-05-08 00:14:05 +02:00
|
|
|
import re
|
2019-01-06 21:55:48 +01:00
|
|
|
import copy
|
2017-05-08 00:14:05 +02:00
|
|
|
|
|
|
|
from svtplay_dl.error import ServiceError
|
|
|
|
from svtplay_dl.service.svtplay import Svtplay
|
2019-01-06 21:55:48 +01:00
|
|
|
from svtplay_dl.subtitle import subtitle
|
2017-05-08 00:14:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Svt(Svtplay):
|
|
|
|
supported_domains = ['svt.se', 'www.svt.se']
|
|
|
|
|
|
|
|
def get(self):
|
2018-03-19 21:53:27 +01:00
|
|
|
|
|
|
|
data = self.get_urldata()
|
|
|
|
match_data_video_id = re.search("data-video-id=\"(.+?)\"", data)
|
|
|
|
|
|
|
|
if match_data_video_id:
|
|
|
|
id = match_data_video_id.group(1)
|
|
|
|
|
|
|
|
else:
|
2017-05-08 00:14:05 +02:00
|
|
|
yield ServiceError("Cant find video info.")
|
|
|
|
return
|
|
|
|
|
2018-03-19 21:53:27 +01:00
|
|
|
res = self.http.get("http://api.svt.se/videoplayer-api/video/{0}".format(id))
|
2017-05-08 00:14:05 +02:00
|
|
|
janson = res.json()
|
2019-01-06 21:55:48 +01:00
|
|
|
if "subtitleReferences" in janson:
|
|
|
|
for i in janson["subtitleReferences"]:
|
|
|
|
if i["format"] == "websrt" and "url" in i:
|
|
|
|
yield subtitle(copy.copy(self.config), "wrst", i["url"], output=self.output)
|
|
|
|
|
2017-05-08 00:14:05 +02:00
|
|
|
videos = self._get_video(janson)
|
|
|
|
for i in videos:
|
2018-02-26 00:02:53 +01:00
|
|
|
yield i
|