Paste Search Dynamic
Recent pastes
9anime-nineanime.py
  1. import re
  2. from streamlink.plugin import Plugin
  3. from streamlink.plugin.api import http
  4. from streamlink.plugin.api import useragents
  5. from streamlink.plugin.api import validate
  6. from streamlink.stream import HTTPStream
  7. from streamlink.compat import urlparse
  8.  
  9.  
  10.  class NineAnime(Plugin):
  11.     _episode_info_url = "http://9anime.ru/ajax/episode/info"
  12.     _episode_info_url = "//9anime.ru/ajax/episode/info"
  13.  
  14.      _info_schema = validate.Schema({
  15.         "grabber": validate.url(),
  16. @@ -27,31 +29,36 @@ class NineAnime(Plugin):
  17.         }]
  18.     })
  19.  
  20.      _user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) "\
  21.                   "Chrome/36.0.1944.9 Safari/537.36"
  22.     _url_re = re.compile(r"https?://9anime.ru/watch/(?:[^.]+?\.)(\w+)/(\w+)")
  23.  
  24.      @classmethod
  25.     def can_handle_url(cls, url):
  26.         return cls._url_re.match(url) is not none
  27.  
  28.      def add_scheme(self, url):
  29.         # update the scheme for the grabber url if required
  30.         if url.startswith("//"):
  31.             url = "{0}:{1}".format(urlparse(self.url).scheme, url)
  32.         return url
  33.  
  34.      def _get_streams(self):
  35.         match = self._url_re.match(self.url)
  36.         film_id, episode_id = match.groups()
  37.  
  38.          headers = {
  39.             "Referer": self.url,
  40.             "User-Agent": self._user_agent
  41.             "User-Agent": useragents.FIREFOX
  42.         }
  43.  
  44.          # Get the info about the Episode, including the Grabber API URL
  45.         info_res = http.get(self._episode_info_url,
  46.         info_res = http.get(self.add_scheme(self._episode_info_url),
  47.                             params=dict(update=0, film=film_id, id=episode_id),
  48.                             headers=headers)
  49.         info = http.json(info_res, schema=self._info_schema)
  50.  
  51.          # Get the data about the streams from the Grabber API
  52.         stream_list_res = http.get(info["grabber"], params=info["params"], headers=headers)
  53.         grabber_url = self.add_scheme(info["grabber"])
  54.         stream_list_res = http.get(grabber_url, params=info["params"], headers=headers)
  55.         stream_data = http.json(stream_list_res, schema=self._streams_schema)
  56.  
  57.          for stream in stream_data["data"]:
Parsed in 0.024 seconds