Exemplo n.º 1
0
    def reload_playlist(self):
        if self.closed:
            return

        self.reader.buffer.wait_free()
        log.debug("Reloading playlist")

        if self.stream.channel:
            parsed = urlparse(self.stream.url)
            if self.stream._first_netloc is None:
                # save the first netloc
                self.stream._first_netloc = parsed.netloc
            # always use the first saved netloc
            new_stream_url = parsed._replace(
                netloc=self.stream._first_netloc).geturl()
        else:
            new_stream_url = self.stream.url

        try:
            res = self.session.http.get(new_stream_url,
                                        exception=StreamError,
                                        retries=self.playlist_reload_retries,
                                        **self.reader.request_params)
        except StreamError as err:
            if (hasattr(self.stream, "watch_timeout") and any(
                    x in str(err)
                    for x in ("403 Client Error", "502 Server Error"))):
                self.stream.watch_timeout = 0
                self.playlist_reload_time = 0
                log.debug(
                    f"Force reloading the channel playlist on error: {err}")
                return
            raise err

        try:
            playlist = load_hls_playlist(res.text, res.url)
        except ValueError as err:
            raise StreamError(err)

        if playlist.is_master:
            raise StreamError("Attempted to play a variant playlist, use "
                              "'hls://{0}' instead".format(self.stream.url))

        if playlist.iframes_only:
            raise StreamError(
                "Streams containing I-frames only is not playable")

        media_sequence = playlist.media_sequence or 0
        sequences = [
            Sequence(media_sequence + i, s)
            for i, s in enumerate(playlist.segments)
        ]

        if sequences:
            self.process_sequences(playlist, sequences)
Exemplo n.º 2
0
    def _reload_playlist(self, text, url):
        self.playlist_reloads += 1
        playlist = load_hls_playlist(text,
                                     url,
                                     parser=TwitchM3U8Parser,
                                     disable_ads=self.stream.disable_ads,
                                     low_latency=self.stream.low_latency)
        if (self.stream.disable_ads and self.playlist_reloads == 1
                and not next(
                    (s for s in playlist.segments if not s.ad), False)):
            log.info("Waiting for pre-roll ads to finish, be patient")

        return playlist
Exemplo n.º 3
0
 def _reload_playlist(self, text, url):
     return load_hls_playlist(text, url, parser=TwitchM3U8Parser)
Exemplo n.º 4
0
 def _reload_playlist(self, *args):
     return load_hls_playlist(*args, parser=TwitchM3U8Parser, m3u8=TwitchM3U8)
Exemplo n.º 5
0
 def _get_variant_playlist(cls, res):
     return load_hls_playlist(res.text, base_uri=res.url)
Exemplo n.º 6
0
 def _reload_playlist(self, text, url):
     return load_hls_playlist(text, url)
Exemplo n.º 7
0
 def _get_variant_playlist(cls, *args, **kwargs):
     return load_hls_playlist(*args, **kwargs)
Exemplo n.º 8
0
 def _reload_playlist(self, *args, **kwargs):
     return load_hls_playlist(*args, **kwargs)