コード例 #1
0
    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)
        )
コード例 #2
0
    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")
コード例 #3
0
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"
コード例 #4
0
    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)
コード例 #5
0
    def __init__(self, session_, url, buffered=True, **args):
        Stream.__init__(self, session_)

        self.args = dict(url=url, **args)
        self.buffered = buffered
コード例 #6
0
ファイル: playlist.py プロジェクト: ImAvinashSharma/sip-py
 def __json__(self):
     return dict(streams=self.streams,
                 duration=self.duration,
                 **Stream.__json__(self))
コード例 #7
0
ファイル: playlist.py プロジェクト: ImAvinashSharma/sip-py
    def __init__(self, session, streams, duration=None):
        Stream.__init__(self, session)

        self.streams = streams
        self.duration = duration
コード例 #8
0
 def test_base_stream(self):
     stream = Stream(self.session)
     self.assertEqual(None, stream_to_url(stream))
     self.assertRaises(TypeError, stream.to_url)
コード例 #9
0
ファイル: akamaihd.py プロジェクト: yuviDX/streamlink
    def __init__(self, session, url, swf=None, seek=None):
        Stream.__init__(self, session)

        self.seek = seek
        self.swf = swf
        self.url = url
コード例 #10
0
 def test_base_stream(self):
     stream = Stream(self.session)
     self.assertEqual(
         {"type": "stream"},
         stream.__json__()
     )
コード例 #11
0
def test_base_stream(session):
    stream = Stream(session)
    assert stream.__json__() == {
        "type": "stream",
    }
    assert stream.json == """{"type": "stream"}"""
コード例 #12
0
 def __json__(self):
     return dict(substreams=self.substreams,
                 subtitles=self.subtitles,
                 options=self.options,
                 **Stream.__json__(self))