Advertisement
urgoz

catcast

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