2016-09-04 20:44:25 +02:00
|
|
|
import re
|
2018-01-30 22:07:21 +01:00
|
|
|
from urllib.parse import urlparse
|
|
|
|
|
2016-09-04 20:44:25 +02:00
|
|
|
from svtplay_dl.error import ServiceError
|
2019-08-25 00:40:39 +02:00
|
|
|
from svtplay_dl.fetcher.hls import hlsparse
|
|
|
|
from svtplay_dl.service import OpenGraphThumbMixin
|
|
|
|
from svtplay_dl.service import Service
|
2016-09-04 20:44:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Pokemon(Service, OpenGraphThumbMixin):
|
2019-08-25 00:27:31 +02:00
|
|
|
supported_domains = ["pokemon.com"]
|
2016-09-04 20:44:25 +02:00
|
|
|
|
|
|
|
def get(self):
|
|
|
|
data = self.get_urldata()
|
|
|
|
|
|
|
|
parse = urlparse(self.url)
|
2019-08-25 00:27:31 +02:00
|
|
|
match = re.search(r"^/([a-z]{2})/", parse.path)
|
2016-09-04 20:44:25 +02:00
|
|
|
if not match:
|
|
|
|
yield ServiceError("Cant county code")
|
|
|
|
return
|
|
|
|
|
2021-04-27 19:44:09 +02:00
|
|
|
res = self.http.get(f"http://www.pokemon.com/api/pokemontv/channels?region={match.group(1)}")
|
2016-09-04 20:44:25 +02:00
|
|
|
janson = res.json()
|
|
|
|
match = re.search('data-video-season="([0-9]+)"', data)
|
|
|
|
season = match.group(1)
|
|
|
|
match = re.search('data-video-episode="([0-9]+)"', data)
|
|
|
|
episode = match.group(1)
|
|
|
|
|
|
|
|
for i in janson:
|
|
|
|
for n in i["media"]:
|
|
|
|
if season == n["season"] and episode == n["episode"]:
|
|
|
|
stream = n["stream_url"]
|
|
|
|
|
2018-05-13 13:06:45 +02:00
|
|
|
self.output["title"] = "pokemon"
|
|
|
|
self.output["season"] = season
|
|
|
|
self.output["episode"] = episode
|
2016-09-04 20:44:25 +02:00
|
|
|
|
2021-05-16 02:22:37 +02:00
|
|
|
yield from hlsparse(self.config, self.http.request("get", stream), stream, output=self.output)
|