-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathmrtmk.py
More file actions
53 lines (42 loc) · 1.52 KB
/
Copy pathmrtmk.py
File metadata and controls
53 lines (42 loc) · 1.52 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
49
50
51
52
53
"""
$description Live TV channels and video on-demand service from MRT, a North Macedonian public, state-owned broadcaster.
$url play.mrt.com.mk
$type live, vod
$region North Macedonia
"""
import re
from streamlink.logger import getLogger
from streamlink.plugin import Plugin, pluginmatcher
from streamlink.plugin.api import validate
from streamlink.stream.hls import HLSStream
log = getLogger(__name__)
@pluginmatcher(
re.compile(r"https?://play\.mrt\.com\.mk/(live|play)/"),
)
class MRTmk(Plugin):
file_re = re.compile(r"""(?P<url>https?://vod-[\d\w]+\.interspace\.com[^"',]+\.m3u8[^"',]*)""")
stream_schema = validate.Schema(
validate.all(
validate.transform(file_re.finditer),
validate.transform(list),
[validate.get("url")],
# remove duplicates
validate.transform(set),
validate.transform(list),
),
)
def _get_streams(self):
res = self.session.http.get(self.url)
stream_urls = self.stream_schema.validate(res.text)
log.debug(f"Found streams: {len(stream_urls)}")
if not stream_urls:
return
for stream_url in stream_urls:
try:
yield from HLSStream.parse_variant_playlist(self.session, stream_url).items()
except OSError as err:
if "403 Client Error" in str(err):
log.error("Failed to access stream, may be due to geo-restriction")
else:
raise err
__plugin__ = MRTmk