Esempio n. 1
0
    def test_repr(self):
        session = Streamlink()

        stream = hls.HLSStream(session, "https://foo.bar/playlist.m3u8")
        self.assertEqual(repr(stream),
                         "<HLSStream('https://foo.bar/playlist.m3u8', None)>")

        stream = hls.HLSStream(session, "https://foo.bar/playlist.m3u8",
                               "https://foo.bar/master.m3u8")
        self.assertEqual(
            repr(stream),
            "<HLSStream('https://foo.bar/playlist.m3u8', 'https://foo.bar/master.m3u8')>"
        )
Esempio n. 2
0
    def start_streamlink(self, data, reload_time):
        streamlink = Streamlink()
        streamlink.set_option("hls-playlist-reload-time", reload_time)
        streamlink.set_option("hls-live-edge", 3)

        streams = [
            b""
            for i in itertools.chain.from_iterable([elem[3] for elem in data])
        ]
        playlists = [self.getPlaylist(*args) for args in data]

        with requests_mock.Mocker() as mock:
            mock.get(self.url_playlist, [{"text": p} for p in playlists])
            for i, stream in enumerate(streams):
                mock.get(self.url_segment.format(i), content=stream)

            hlsstream = hls.HLSStream(streamlink, self.url_playlist)
            reader = hlsstream.open()
            reader.close()

            return reader