From 0b8c62a442b7617c6151084d86e90e4ba2e6abb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Marqui=CC=81nez=20Ferra=CC=81ndiz?= Date: Mon, 25 Aug 2014 15:35:48 +0200 Subject: [PATCH] Add plugin for rtve.es live streams --- docs/plugin_matrix.rst | 1 + src/livestreamer/plugins/rtve.py | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/livestreamer/plugins/rtve.py diff --git a/docs/plugin_matrix.rst b/docs/plugin_matrix.rst index 5f9a79d6..58d10b28 100644 --- a/docs/plugin_matrix.rst +++ b/docs/plugin_matrix.rst @@ -48,6 +48,7 @@ nrk - tv.nrk.no Yes Yes Streams may be geo-restrict - radio.nrk.no oldlivestream livestream.com Yes No Only mobile streams are supported. picarto picarto.tv Yes -- +rtve rtve.es Yes No speedrunslive speedrunslive.com Yes -- URL forwarder to Twitch channels. streamingvi... [1]_ streamingvid... [2]_ Yes -- RTMP streams requires rtmpdump with K-S-V patches. diff --git a/src/livestreamer/plugins/rtve.py b/src/livestreamer/plugins/rtve.py new file mode 100644 index 00000000..d0c3f606 --- /dev/null +++ b/src/livestreamer/plugins/rtve.py @@ -0,0 +1,40 @@ +import re + +from livestreamer.plugin import Plugin +from livestreamer.stream import HLSStream + +_url_re = re.compile(r""" + https?://www\.rtve\.es/ + (?P + noticias/directo-la-1| + television/la-2-directo| + deportes/directo/teledeporte| + noticias/directo/canal-24h + ) + /? +""", re.VERBOSE) + +_id_map = { + "noticias/directo-la-1": "LA1", + "television/la-2-directo": "LA2", + "deportes/directo/teledeporte": "TDP", + "noticias/directo/canal-24h": "24H", +} + + +class Rtve(Plugin): + @classmethod + def can_handle_url(cls, url): + return _url_re.match(url) + + def __init__(self, url): + Plugin.__init__(self, url) + match = _url_re.match(url).groupdict() + self.channel_path = match["channel_path"] + + def _get_streams(self): + stream_id = _id_map[self.channel_path] + hls_url = "http://iphonelive.rtve.es/{0}_LV3_IPH/{0}_LV3_IPH.m3u8".format(stream_id) + return HLSStream.parse_variant_playlist(self.session, hls_url) + +__plugin__ = Rtve