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