mirror of https://github.com/streamlink/streamlink
plugins.zeenews: new plugin for https://zeenews.india.com/live-tv
This commit is contained in:
parent
5378c4f5ea
commit
0e0df62543
|
@ -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
|
||||
======================= ==================== ===== ===== ===========================
|
||||
|
|
|
@ -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
|
|
@ -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)
|
Loading…
Reference in New Issue