def __init__(self, session, baseurl, url, bootstrap, metadata=None, timeout=60, **request_params): Stream.__init__(self, session) self.baseurl = baseurl self.url = url self.bootstrap = bootstrap self.metadata = metadata self.timeout = timeout # Deep copy request params to make it mutable self.request_params = deepcopy(request_params) parsed = urlparse(self.url) if parsed.query: params = parse_qsl(parsed.query) if params: if not self.request_params.get("params"): self.request_params["params"] = {} self.request_params["params"].update(params) self.url = urlunparse( (parsed.scheme, parsed.netloc, parsed.path, None, None, None) )
def test_handle_stream_output_stream(self, args: Mock, mock_output_stream: Mock): """ Test that the formatter does define the correct variables """ args.json = False args.subprocess_cmdline = False args.stream_url = False args.output = False args.stdout = False args.url = "URL" args.player_passthrough = [] args.player_external_http = False args.player_continuous_http = False mock_output_stream.return_value = True plugin = _TestPlugin("") plugin.author = "AUTHOR" plugin.category = "CATEGORY" plugin.title = "TITLE" stream = Stream(session=Mock()) streams = {"best": stream} handle_stream(plugin, streams, "best") self.assertEqual(mock_output_stream.call_count, 1) paramStream, paramFormatter = mock_output_stream.call_args[0] self.assertIs(paramStream, stream) self.assertIsInstance(paramFormatter, Formatter) self.assertEqual( paramFormatter.title( "{url} - {author} - {category}/{game} - {title}"), "URL - AUTHOR - CATEGORY/CATEGORY - TITLE")
def test_base_stream(session): stream = Stream(session) with pytest.raises(TypeError) as cm: stream.to_url() assert str(cm.value) == "<Stream [stream]> cannot be translated to a URL" with pytest.raises(TypeError) as cm: stream.to_manifest_url() assert str( cm.value) == "<Stream [stream]> cannot be translated to a manifest URL"
def test_handle_stream_output_stream(self, args: Mock, mock_output_stream: Mock): args.json = False args.subprocess_cmdline = False args.stream_url = False args.output = False args.stdout = False args.player_passthrough = [] args.player_external_http = False args.player_continuous_http = False mock_output_stream.return_value = True plugin = FakePlugin("") stream = Stream(session=Mock()) streams = {"best": stream} handle_stream(plugin, streams, "best") self.assertEqual(mock_output_stream.call_count, 1) paramStream, paramFormatter = mock_output_stream.call_args[0] self.assertIs(paramStream, stream) self.assertIsInstance(paramFormatter, Formatter)
def __init__(self, session_, url, buffered=True, **args): Stream.__init__(self, session_) self.args = dict(url=url, **args) self.buffered = buffered
def __json__(self): return dict(streams=self.streams, duration=self.duration, **Stream.__json__(self))
def __init__(self, session, streams, duration=None): Stream.__init__(self, session) self.streams = streams self.duration = duration
def test_base_stream(self): stream = Stream(self.session) self.assertEqual(None, stream_to_url(stream)) self.assertRaises(TypeError, stream.to_url)
def __init__(self, session, url, swf=None, seek=None): Stream.__init__(self, session) self.seek = seek self.swf = swf self.url = url
def test_base_stream(self): stream = Stream(self.session) self.assertEqual( {"type": "stream"}, stream.__json__() )
def test_base_stream(session): stream = Stream(session) assert stream.__json__() == { "type": "stream", } assert stream.json == """{"type": "stream"}"""
def __json__(self): return dict(substreams=self.substreams, subtitles=self.subtitles, options=self.options, **Stream.__json__(self))