Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins.galatasaraytv: Add support for GALATASARAY SK TV live streams #2760

Merged
merged 9 commits into from
Feb 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/plugin_matrix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ filmon filmon.com Yes Yes Only SD quality streams
foxtr fox.com.tr Yes No
funimationnow - funimation.com -- Yes :ref:`Requires session cookies <cli-funimationnow>`
- funimationnow.uk
galatasaraytv galatasaray.com Yes No
gardenersworld gardenersworld.com -- Yes
garena garena.live Yes --
goltelevision goltelevision.com Yes No Streams may be geo-restricted to Spain.
Expand Down
30 changes: 30 additions & 0 deletions src/streamlink/plugins/galatasaraytv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import logging
import re

from streamlink.plugin import Plugin
from streamlink.stream import HLSStream

log = logging.getLogger(__name__)


class GalatasarayTV(Plugin):
url_re = re.compile(r"https?://(?:www.)?galatasaray\.com")
playervars_re = re.compile(r"sources\s*:\s*\[\s*\{\s*type\s*:\s*\"(.*?)\",\s*src\s*:\s*\"(.*?)\"", re.DOTALL)

@classmethod
def can_handle_url(cls, url):
return cls.url_re.match(url) is not None

def get_title(self):
return "Galatasaray TV"

def _get_streams(self):
res = self.session.http.get(self.url)
match = self.playervars_re.search(res.text)
if match:
stream_url = match.group(2)
log.debug("URL={0}".format(stream_url))
return HLSStream.parse_variant_playlist(self.session, stream_url)


__plugin__ = GalatasarayTV
22 changes: 22 additions & 0 deletions tests/plugins/test_galatasaraytv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import unittest

from streamlink.plugins.galatasaraytv import GalatasarayTV


class TestPluginGalatasarayTV(unittest.TestCase):
def test_can_handle_url(self):
should_match = [
'http://galatasaray.com/',
'https://galatasaray.com',
'https://galatasaray.com/',
'https://www.galatasaray.com/',
]
for url in should_match:
self.assertTrue(GalatasarayTV.can_handle_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(GalatasarayTV.can_handle_url(url))