Advertisement
urgoz

catcast_old

Jun 27th, 2023 (edited)
760
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import re
  2. from streamlink.plugin import Plugin
  3. from streamlink.stream import HLSStream
  4. from streamlink.plugin.api import useragents
  5.  
  6. class Catcast(Plugin):
  7.     url_re = re.compile(r'https?://catcast.tv/player/(?P<id>\d+)')
  8.     api_url = "https://api.catcast.tv/api/channels/{id}/getcurrentprogram"
  9.     @classmethod
  10.     def can_handle_url(cls, url):
  11.         return cls.url_re.match(url) is not None
  12.        
  13.     def _get_streams(self):
  14.         channel_id = self.url_re.match(self.url).group("id")
  15.         headers = {"User-Agent": useragents.CHROME}
  16.         body = self.session.http.get(self.api_url.format(id=channel_id), headers=headers).text
  17.         mrl = None
  18.         match = re.search(r'full_mobile_url":"(.*?)\"', body)
  19.         if match:
  20.             mrl = match.group(1).replace('\/','/')
  21.         if mrl:
  22.             yield "live", HLSStream(self.session, mrl)
  23.  
  24. __plugin__ = Catcast
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement