-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathtvtoya.py
More file actions
48 lines (41 loc) · 1.47 KB
/
Copy pathtvtoya.py
File metadata and controls
48 lines (41 loc) · 1.47 KB
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
"""
$description Polish live TV channel owned by Toya.
$url tvtoya.pl
$type live
"""
import re
from streamlink.plugin import Plugin, PluginError, pluginmatcher
from streamlink.plugin.api import validate
from streamlink.stream.hls import HLSStream
@pluginmatcher(
re.compile(r"https?://(?:www\.)?tvtoya\.pl/player/live"),
)
class TVToya(Plugin):
def _get_streams(self):
try:
hls = self.session.http.get(
self.url,
schema=validate.Schema(
validate.parse_html(),
validate.xml_xpath_string(".//script[@type='application/json'][@id='__NEXT_DATA__']/text()"),
str,
validate.parse_json(),
{
"props": {
"pageProps": {
"type": "live",
"url": validate.all(
str,
validate.transform(lambda url: url.replace("https:////", "https://")),
validate.url(path=validate.endswith(".m3u8")),
),
},
},
},
validate.get(("props", "pageProps", "url")),
),
)
except PluginError:
return
return HLSStream.parse_variant_playlist(self.session, hls)
__plugin__ = TVToya