Skip to content

Commit 1b9ce00

Browse files
authored
plugins.telemadrid: new plugin (#5212)
1 parent 49988a0 commit 1b9ce00

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/streamlink/plugins/telemadrid.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
$description Spanish live TV channel for Telemadrid, a public regional television station.
3+
$url telemadrid.es
4+
$type live, vod
5+
$region Spain
6+
"""
7+
8+
import re
9+
10+
from streamlink.plugin import Plugin, pluginmatcher
11+
from streamlink.plugin.api import validate
12+
from streamlink.plugins.brightcove import BrightcovePlayer
13+
14+
15+
@pluginmatcher(re.compile(
16+
r"https?://(?:www\.)?telemadrid\.es/",
17+
))
18+
class Telemadrid(Plugin):
19+
20+
def _get_streams(self):
21+
data = self.session.http.get(self.url, schema=validate.Schema(
22+
validate.parse_html(),
23+
validate.xml_find(".//video[@class='video-js'][@data-video-id][@data-account][@data-player][1]"),
24+
validate.union_get("data-video-id", "data-account", "data-player"),
25+
))
26+
data_video_id, data_account, data_player = data
27+
player = BrightcovePlayer(self.session, data_account, f"{data_player}_default")
28+
return player.get_streams(data_video_id)
29+
30+
31+
__plugin__ = Telemadrid

tests/plugins/test_telemadrid.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from streamlink.plugins.telemadrid import Telemadrid
2+
from tests.plugins import PluginCanHandleUrl
3+
4+
5+
class TestPluginCanHandleUrlTelemadrid(PluginCanHandleUrl):
6+
__plugin__ = Telemadrid
7+
8+
should_match = [
9+
"https://www.telemadrid.es/",
10+
"https://www.telemadrid.es/emision-en-directo/",
11+
"https://www.telemadrid.es/programas/telenoticias-1/Telenoticias-1-02032023-2-2538066218--20230302042202.html",
12+
]

0 commit comments

Comments
 (0)