From 0e0df625439a61ca872ee82a00095ff0d46ad2b8 Mon Sep 17 00:00:00 2001 From: back-to Date: Sun, 12 Apr 2020 08:33:04 +0200 Subject: [PATCH] plugins.zeenews: new plugin for https://zeenews.india.com/live-tv --- docs/plugin_matrix.rst | 1 + src/streamlink/plugins/zeenews.py | 31 +++++++++++++++++++++++++++++++ tests/plugins/test_zeenews.py | 20 ++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 src/streamlink/plugins/zeenews.py create mode 100644 tests/plugins/test_zeenews.py diff --git a/docs/plugin_matrix.rst b/docs/plugin_matrix.rst index 53f543bd..e33c51bc 100644 --- a/docs/plugin_matrix.rst +++ b/docs/plugin_matrix.rst @@ -299,6 +299,7 @@ zattoo - zattoo.com Yes Yes - www.vtxtv.ch - www.1und1.tv zdf_mediathek zdf.de Yes Yes Streams may be geo-restricted to Germany. +zeenews zeenews.india.com Yes No zengatv zengatv.com Yes No zhanqi zhanqi.tv Yes No ======================= ==================== ===== ===== =========================== diff --git a/src/streamlink/plugins/zeenews.py b/src/streamlink/plugins/zeenews.py new file mode 100644 index 00000000..30acd425 --- /dev/null +++ b/src/streamlink/plugins/zeenews.py @@ -0,0 +1,31 @@ +import logging +import re + +from streamlink.plugin import Plugin +from streamlink.stream import HLSStream + +log = logging.getLogger(__name__) + + +class ZeeNews(Plugin): + _url_re = re.compile(r'https?://zeenews\.india\.com/live-tv') + + HLS_URL = 'https://z5ams.akamaized.net/zeenews/index.m3u8{0}' + TOKEN_URL = 'https://useraction.zee5.com/token/live.php' + + @classmethod + def can_handle_url(cls, url): + return cls._url_re.match(url) is not None + + def get_title(self): + return 'Zee News' + + def _get_streams(self): + res = self.session.http.get(self.TOKEN_URL) + token = self.session.http.json(res)['video_token'] + log.debug('video_token: {0}'.format(token)) + for s in HLSStream.parse_variant_playlist(self.session, self.HLS_URL.format(token)).items(): + yield s + + +__plugin__ = ZeeNews diff --git a/tests/plugins/test_zeenews.py b/tests/plugins/test_zeenews.py new file mode 100644 index 00000000..66c411bd --- /dev/null +++ b/tests/plugins/test_zeenews.py @@ -0,0 +1,20 @@ +import unittest + +from streamlink.plugins.zeenews import ZeeNews + + +class TestPluginZeeNews(unittest.TestCase): + def test_can_handle_url(self): + should_match = [ + 'https://zeenews.india.com/live-tv', + 'https://zeenews.india.com/live-tv/embed', + ] + for url in should_match: + self.assertTrue(ZeeNews.can_handle_url(url), url) + + def test_can_handle_url_negative(self): + should_not_match = [ + 'https://example.com/index.html', + ] + for url in should_not_match: + self.assertFalse(ZeeNews.can_handle_url(url), url)