示例#1
0
def check_version(force=False):
    cache = Cache(filename="cli.json")
    latest_version = cache.get("latest_version")

    if force or not latest_version:
        res = requests.get("https://pypi.python.org/pypi/streamlink/json")
        data = res.json()
        latest_version = data.get("info").get("version")
        cache.set("latest_version", latest_version, (60 * 60 * 24))

    version_info_printed = cache.get("version_info_printed")
    if not force and version_info_printed:
        return

    installed_version = StrictVersion(streamlink.version)
    latest_version = StrictVersion(latest_version)

    if latest_version > installed_version:
        log.info("A new version of Streamlink ({0}) is "
                 "available!".format(latest_version))
        cache.set("version_info_printed", True, (60 * 60 * 6))
    elif force:
        log.info("Your Streamlink version ({0}) is up to date!".format(
            installed_version))

    if force:
        sys.exit()
示例#2
0
 def __init__(self, url):
     super(WWENetwork, self).__init__(url)
     http.headers.update({"User-Agent": useragents.CHROME})
     self._session_attributes = Cache(filename="plugin-cache.json",
                                      key_prefix="wwenetwork:attributes")
     self._session_key = self.cache.get("session_key")
     self._authed = self._session_attributes.get(
         "ipid") and self._session_attributes.get("fprt")
示例#3
0
 def __init__(self, url):
     super(ABweb, self).__init__(url)
     self._session_attributes = Cache(filename='plugin-cache.json',
                                      key_prefix='abweb:attributes')
     self._authed = self._session_attributes.get(
         'ASP.NET_SessionId') and self._session_attributes.get(
             '.abportail1')
     self._expires = self._session_attributes.get(
         'expires',
         time.time() + self.expires_time)
 def bind(cls, session, module, user_input_requester=None):
     cls.cache = Cache(filename="plugin-cache.json", key_prefix=module)
     cls.logger = logging.getLogger("streamlink.plugin." + module)
     cls.module = module
     cls.session = session
     if user_input_requester is not None:
         if isinstance(user_input_requester, UserInputRequester):
             cls._user_input_requester = user_input_requester
         else:
             raise RuntimeError("user-input-requester must be an instance of UserInputRequester")
示例#5
0
    def __init__(self, options=None):
        self.http = api.HTTPSession()
        self.options = Options({
            "interface": None,
            "ipv4": False,
            "ipv6": False,
            "hds-live-edge": 10.0,
            "hds-segment-attempts": 3,
            "hds-segment-threads": 1,
            "hds-segment-timeout": 10.0,
            "hds-timeout": 60.0,
            "hls-live-edge": 3,
            "hls-segment-attempts": 3,
            "hls-segment-ignore-names": [],
            "hls-segment-threads": 1,
            "hls-segment-timeout": 10.0,
            "hls-segment-stream-data": False,
            "hls-timeout": 60.0,
            "hls-playlist-reload-attempts": 3,
            "hls-playlist-reload-time": "default",
            "hls-start-offset": 0,
            "hls-duration": None,
            "http-stream-timeout": 60.0,
            "hls-token-period": 60.0,
            "ringbuffer-size": 1024 * 1024 * 16,  # 16 MB
            "rtmp-timeout": 60.0,
            "rtmp-rtmpdump": is_win32 and "rtmpdump.exe" or "rtmpdump",
            "rtmp-proxy": None,
            "stream-segment-attempts": 3,
            "stream-segment-threads": 1,
            "stream-segment-timeout": 10.0,
            "stream-timeout": 60.0,
            "subprocess-errorlog": False,
            "subprocess-errorlog-path": None,
            "ffmpeg-ffmpeg": None,
            "ffmpeg-fout": None,
            "ffmpeg-video-transcode": None,
            "ffmpeg-audio-transcode": None,
            "ffmpeg-copyts": False,
            "ffmpeg-start-at-zero": False,
            "mux-subtitles": False,
            "locale": None,
            "user-input-requester": None
        })
        # felix add update headers cookies
        self.cache = Cache(filename="StreamlinkSession.json")

        if options:
            self.options.update(options)
        self.plugins = OrderedDict({})
        self.load_builtin_plugins()
示例#6
0
    def __init__(self, url):
        super(Zattoo, self).__init__(url)
        self._session_attributes = Cache(filename='plugin-cache.json', key_prefix='zattoo:attributes')
        self._authed = self._session_attributes.get('beaker.session.id') and self._session_attributes.get('pzuid') and self._session_attributes.get('power_guide_hash')
        self._uuid = self._session_attributes.get('uuid')
        self._expires = self._session_attributes.get('expires', 946684800)

        self.base_url = 'https://{0}'.format(Zattoo._url_re.match(url).group('base_url'))
        self.headers = {
            'User-Agent': useragents.CHROME,
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
            'X-Requested-With': 'XMLHttpRequest',
            'Referer': self.base_url
        }
示例#7
0
    def _pv_params(cls, session, pvswf, pv, **request_params):
        """Returns any parameters needed for Akamai HD player verification.

        Algorithm originally documented by KSV, source:
        http://stream-recorder.com/forum/showpost.php?p=43761&postcount=13
        """

        try:
            data, hdntl = pv.split(";")
        except ValueError:
            data = pv
            hdntl = ""

        cache = Cache(filename="stream.json")
        key = "akamaihd-player:" + pvswf
        cached = cache.get(key)

        request_params = deepcopy(request_params)
        headers = request_params.pop("headers", {})
        if cached:
            headers["If-Modified-Since"] = cached["modified"]
        swf = session.http.get(pvswf, headers=headers, **request_params)

        if cached and swf.status_code == 304:  # Server says not modified
            hash = cached["hash"]
        else:
            # Calculate SHA-256 hash of the uncompressed SWF file, base-64
            # encoded
            hash = sha256()
            hash.update(swfdecompress(swf.content))
            hash = base64.b64encode(hash.digest()).decode("ascii")
            modified = swf.headers.get("Last-Modified", "")

            # Only save in cache if a valid date is given
            if len(modified) < 40:
                cache.set(key, dict(hash=hash, modified=modified))

        msg = "st=0~exp=9999999999~acl=*~data={0}!{1}".format(data, hash)
        auth = hmac.new(AKAMAIHD_PV_KEY, msg.encode("ascii"), sha256)
        pvtoken = "{0}~hmac={1}".format(msg, auth.hexdigest())

        # The "hdntl" parameter can be accepted as a cookie or passed in the
        # query string, but the "pvtoken" parameter can only be in the query
        # string
        params = [("pvtoken", pvtoken)]
        params.extend(parse_qsl(hdntl, keep_blank_values=True))

        return params
示例#8
0
 def __init__(self, url):
     super().__init__(url)
     self.domain = self.match.group('base_url')
     self._session_attributes = Cache(
         filename='plugin-cache.json',
         key_prefix='zattoo:attributes:{0}'.format(self.domain))
     self._uuid = self._session_attributes.get('uuid')
     self._authed = (self._session_attributes.get('power_guide_hash')
                     and self._uuid
                     and self.session.http.cookies.get('pzuid', domain=self.domain)
                     and self.session.http.cookies.get('beaker.session.id', domain=self.domain)
                     )
     self._session_control = self._session_attributes.get('session_control',
                                                          False)
     self.base_url = 'https://{0}'.format(self.domain)
     self.headers = {
         'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
         'X-Requested-With': 'XMLHttpRequest',
         'Referer': self.base_url
     }
示例#9
0
 def bind(cls, session, module):
     cls.cache = Cache(filename="plugin-cache.json", key_prefix=module)
     cls.logger = logging.getLogger("streamlink.plugin." + module)
     cls.module = module
     cls.session = session
示例#10
0
 def __init__(self, url):
     super(Mitele, self).__init__(url)
     self.cache = Cache("mitele.cache")