Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- from streamlink.plugin import Plugin, pluginmatcher
- from streamlink.stream import HLSStream
- from streamlink.plugin.api import useragents
- @pluginmatcher(re.compile(r'https?://catcast.tv/player/(?P<id>\d+)'))
- class Catcast(Plugin):
- api_url = "https://api.catcast.tv/api/channels/{id}/getcurrentprogram"
- def _get_streams(self):
- channel_id = self.match.group("id")
- headers = {"User-Agent": useragents.CHROME,
- "Origin": "https://catcast.tv",
- "Referer": "https://catcast.tv"}
- body = self.session.http.get(self.api_url.format(id=channel_id), headers=headers).text
- mrl = None
- xat = re.search(r'token":"(.*?)\"', body)
- match = re.search(r'full_url":"(.*?)\"', body)
- if xat:
- headers["X-Access-Token"] = xat.group(1)
- if match:
- mrl = match.group(1).replace('\\/','/')
- if mrl:
- yield "live", HLSStream(self.session, mrl, headers=headers)
- __plugin__ = Catcast
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement