mirror of
https://github.com/streamlink/streamlink
synced 2024-09-11 05:57:52 +02:00
plugins.stream: Attempt to eval parameters as Python values.
This commit is contained in:
parent
d5e9173fc9
commit
88cebc881a
@ -4,6 +4,7 @@ from livestreamer.plugin import Plugin
|
||||
from livestreamer.stream import (AkamaiHDStream, HDSStream, HLSStream,
|
||||
HTTPStream, RTMPStream)
|
||||
|
||||
import ast
|
||||
import re
|
||||
|
||||
class StreamURL(Plugin):
|
||||
@ -36,13 +37,8 @@ class StreamURL(Plugin):
|
||||
rval[key] = strval
|
||||
else:
|
||||
try:
|
||||
val = float(val)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
try:
|
||||
val = int(val)
|
||||
except ValueError:
|
||||
val = ast.literal_eval(val)
|
||||
except:
|
||||
pass
|
||||
|
||||
rval[key] = val
|
||||
|
@ -44,6 +44,17 @@ class TestPluginStream(unittest.TestCase):
|
||||
self.assertEqual(stream.params["rtmp"], url)
|
||||
self.assertDictHas(params, stream.params)
|
||||
|
||||
def _test_http(self, surl, url, params):
|
||||
channel = self.session.resolve_url(surl)
|
||||
streams = channel.get_streams()
|
||||
|
||||
self.assertTrue("live" in streams)
|
||||
|
||||
stream = streams["live"]
|
||||
self.assertTrue(isinstance(stream, HTTPStream))
|
||||
self.assertEqual(stream.url, url)
|
||||
self.assertDictHas(params, stream.args)
|
||||
|
||||
def test_plugin(self):
|
||||
self._test_rtmp("rtmp://hostname.se/stream",
|
||||
"rtmp://hostname.se/stream", dict())
|
||||
@ -60,5 +71,10 @@ class TestPluginStream(unittest.TestCase):
|
||||
self._test_akamaihd("akamaihd://http://hostname.se/stream",
|
||||
"http://hostname.se/stream")
|
||||
|
||||
self._test_http("httpstream://http://hostname.se/auth.php auth=('test','test2')",
|
||||
"http://hostname.se/auth.php", dict(auth=("test", "test2")))
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user