mirror of
https://github.com/streamlink/streamlink
synced 2024-11-01 01:19:33 +01:00
parent
790bdf26a6
commit
2986b2a512
@ -267,6 +267,7 @@ zattoo - zattoo.com Yes Yes
|
||||
- nettv.net... [10]_
|
||||
- tvonline.ewe.de
|
||||
zdf_mediathek zdf.de Yes Yes Streams may be geo-restricted to Germany.
|
||||
zengatv zengatv.com Yes No
|
||||
zhanqitv zhanqi.tv Yes No
|
||||
=================== ==================== ===== ===== ===========================
|
||||
|
||||
|
48
src/streamlink/plugins/zengatv.py
Normal file
48
src/streamlink/plugins/zengatv.py
Normal file
@ -0,0 +1,48 @@
|
||||
import re
|
||||
|
||||
from streamlink.plugin import Plugin
|
||||
from streamlink.plugin.api import http
|
||||
from streamlink.plugin.api import useragents
|
||||
from streamlink.stream import HLSStream
|
||||
|
||||
|
||||
class ZengaTV(Plugin):
|
||||
"""Streamlink Plugin for livestreams on zengatv.com"""
|
||||
|
||||
_url_re = re.compile(r"https?://(www\.)?zengatv\.com/\w+")
|
||||
_id_re = re.compile(r"""id=(?P<q>["'])dvrid(?P=q)\svalue=(?P=q)(?P<id>[^"']+)(?P=q)""")
|
||||
_id_2_re = re.compile(r"""LivePlayer\(.+["'](?P<id>D\d+)["']""")
|
||||
|
||||
api_url = "http://www.zengatv.com/changeResulation/"
|
||||
|
||||
@classmethod
|
||||
def can_handle_url(cls, url):
|
||||
return cls._url_re.match(url) is not None
|
||||
|
||||
def _get_streams(self):
|
||||
headers = {
|
||||
"User-Agent": useragents.FIREFOX,
|
||||
"Referer": self.url,
|
||||
}
|
||||
|
||||
res = http.get(self.url, headers=headers)
|
||||
for id_re in (self._id_re, self._id_2_re):
|
||||
m = id_re.search(res.text)
|
||||
if not m:
|
||||
continue
|
||||
break
|
||||
|
||||
if not m:
|
||||
self.logger.error("No video id found")
|
||||
return
|
||||
|
||||
dvr_id = m.group("id")
|
||||
self.logger.debug("Found video id: {0}".format(dvr_id))
|
||||
data = {"feed": "hd", "dvrId": dvr_id}
|
||||
res = http.post(self.api_url, headers=headers, data=data)
|
||||
if res.status_code == 200:
|
||||
for s in HLSStream.parse_variant_playlist(self.session, res.text, headers=headers).items():
|
||||
yield s
|
||||
|
||||
|
||||
__plugin__ = ZengaTV
|
22
tests/test_plugin_zengatv.py
Normal file
22
tests/test_plugin_zengatv.py
Normal file
@ -0,0 +1,22 @@
|
||||
import unittest
|
||||
|
||||
from streamlink.plugins.zengatv import ZengaTV
|
||||
|
||||
|
||||
class TestPluginZengaTV(unittest.TestCase):
|
||||
def test_can_handle_url(self):
|
||||
should_match = [
|
||||
"http://www.zengatv.com/indiatoday.html",
|
||||
"http://www.zengatv.com/live/87021a6d-411e-11e2-b4c6-7071bccc85ac.html",
|
||||
"http://zengatv.com/indiatoday.html",
|
||||
"http://zengatv.com/live/87021a6d-411e-11e2-b4c6-7071bccc85ac.html",
|
||||
]
|
||||
for url in should_match:
|
||||
self.assertTrue(ZengaTV.can_handle_url(url))
|
||||
|
||||
should_not_match = [
|
||||
"http://www.zengatv.com",
|
||||
"http://www.zengatv.com/"
|
||||
]
|
||||
for url in should_not_match:
|
||||
self.assertFalse(ZengaTV.can_handle_url(url))
|
Loading…
Reference in New Issue
Block a user