Advertisement
urgoz

catcast_old2

Jul 21st, 2023 (edited)
1,591
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. from streamlink.plugin.api import useragents
  2.  
  3. @pluginmatcher(re.compile(r'https?://catcast.tv/player/(?P<id>\d+)'))
  4.  
  5. class Catcast(Plugin):
  6.     api_url = "https://api.catcast.tv/api/channels/{id}/getcurrentprogram"      
  7.     def _get_streams(self):
  8.         channel_id = self.match.group("id")
  9.         headers = {"User-Agent": useragents.CHROME,
  10.                    "Origin": "https://catcast.tv",
  11.                    "Referer": "https://catcast.tv"}
  12.         body = self.session.http.get(self.api_url.format(id=channel_id), headers=headers).text
  13.         mrl = None
  14.         xat = re.search(r'token":"(.*?)\"', body)
  15.         match = re.search(r'full_url":"(.*?)\"', body)
  16.         if xat:
  17.             headers["X-Access-Token"] = xat.group(1)
  18.         if match:
  19.             mrl = match.group(1).replace('\/','/')
  20.         if mrl:
  21.             yield "live", HLSStream(self.session, mrl, headers=headers)
  22.  
  23. __plugin__ = Catcast
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement