1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
import unittest
from streamlink.plugins.welt import Welt
class TestPluginWelt(unittest.TestCase):
def test_can_handle_url(self):
# should match
self.assertTrue(Welt.can_handle_url("http://welt.de"))
self.assertTrue(Welt.can_handle_url("http://welt.de/"))
self.assertTrue(Welt.can_handle_url("http://welt.de/tv-programm-live-stream/"))
self.assertTrue(Welt.can_handle_url("http://www.welt.de"))
self.assertTrue(Welt.can_handle_url("http://www.welt.de/"))
self.assertTrue(Welt.can_handle_url("http://www.welt.de/tv-programm-live-stream/"))
self.assertTrue(Welt.can_handle_url("https://welt.de"))
self.assertTrue(Welt.can_handle_url("https://welt.de/"))
self.assertTrue(Welt.can_handle_url("https://welt.de/tv-programm-live-stream/"))
self.assertTrue(Welt.can_handle_url("https://www.welt.de"))
self.assertTrue(Welt.can_handle_url("https://www.welt.de/"))
self.assertTrue(Welt.can_handle_url("https://www.welt.de/tv-programm-live-stream/"))
# shouldn't match
self.assertFalse(Welt.can_handle_url("http://www.youtube.com/"))
self.assertFalse(Welt.can_handle_url("http://youtube.com/"))
def test_validate_live(self):
hls_url = Welt._schema.validate("""
foo
<script>
var funkotron = { config: {
"page": {
"content": {
"media": [
{
"sources": [
{
"file": "https://foo.bar/baz.mp4?qux"
},
{
"file": "https://foo.bar/baz.m3u8?qux"
}
]
},
{
"sources": [
{
"file": "https://qux.baz/bar.mp4?foo"
},
{
"file": "https://qux.baz/bar.m3u8?foo"
}
]
}
]
}
}
}}
</script>
bar
""")
self.assertEqual(hls_url, "https://foo.bar/baz.m3u8?qux", "Finds the correct HLS live URL")
def test_validate_vod(self):
hls_url = Welt._schema_vod.validate("""
{
"urlWithToken": "https://foo.bar/baz.m3u8?qux"
}
""")
self.assertEqual(hls_url, "https://foo.bar/baz.m3u8?qux", "Finds the correct HLS VOD URL")
|