forked from streamlink/streamlink
/
piczel.py
60 lines (50 loc) · 1.6 KB
/
piczel.py
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
"""
$description Global live-streaming platform for the creative community.
$url piczel.tv
$type live
"""
import re
from streamlink.plugin import Plugin, pluginmatcher
from streamlink.plugin.api import validate
from streamlink.stream.hls import HLSStream
@pluginmatcher(re.compile(
r"https?://piczel\.tv/watch/(?P<channel>\w+)"
))
class Piczel(Plugin):
_URL_STREAMS = "https://piczel.tv/api/streams"
_URL_HLS = "https://piczel.tv/hls/{id}/index.m3u8"
def _get_streams(self):
channel = self.match.group("channel")
data = self.session.http.get(
self._URL_STREAMS,
params={
"followedStreams": "false",
"live_only": "false",
"sfw": "false",
},
schema=validate.Schema(
validate.parse_json(),
[{
"slug": validate.text,
"live": bool,
"id": int,
"username": validate.text,
"title": validate.text,
}],
validate.filter(lambda item: item["slug"] == channel),
validate.get(0),
validate.any(None, validate.union_get(
"id",
"username",
"title",
"live",
)),
),
)
if not data:
return
self.id, self.author, self.title, is_live = data
if not is_live:
return
return {"live": HLSStream(self.session, self._URL_HLS.format(id=self.id))}
__plugin__ = Piczel