Repository: streamlink/streamlink

Issue:
 media.gov.kw / mangomolo.com plugin request
### Checklist

- [X] This is a plugin request and not [a different kind of issue](https://github.com/streamlink/streamlink/issues/new/choose)
- [X] [I have read the contribution guidelines](https://github.com/streamlink/streamlink/blob/master/CONTRIBUTING.md#contributing-to-streamlink)
- [X] [I have checked the list of open and recently closed plugin requests](https://github.com/streamlink/streamlink/issues?q=is%3Aissue+label%3A%22plugin+request%22)

### Description

Request to open new issue ticket from bastimeyer : 
> https://media.gov.kw is now using a different stream host, namely https://mangomolo.com.
> 
> This requires a separate plugin implementation and the hiplayer plugin needs to be updated accordingly with a removal of the unsupported matcher.

Initial issue : 
https://github.com/streamlink/streamlink/issues/5846

### Input URLs

https://player.mangomolo.com/v1/live?id=xxxxxx
https://kwtktv1ta.cdn.mangomolo.com/ktv1/smil:ktv1.stream.smil/playlist.m3u8?xxx


Discussion:

Resolving patch:
diff --git a/src/streamlink/plugins/mangomolo.py b/src/streamlink/plugins/mangomolo.py
new file mode 100644
--- /dev/null
+++ b/src/streamlink/plugins/mangomolo.py
@@ -0,0 +1,52 @@
+"""
+$description OTT video platform owned by Alpha Technology Group
+$url media.gov.kw
+$type live
+"""
+
+import logging
+import re
+
+from streamlink.exceptions import NoStreamsError
+from streamlink.plugin import Plugin, pluginmatcher
+from streamlink.plugin.api import validate
+from streamlink.stream import HLSStream
+from streamlink.utils.url import update_scheme
+
+
+log = logging.getLogger(__name__)
+
+
+@pluginmatcher(
+    name="mangomoloplayer",
+    pattern=re.compile(r"https?://player\.mangomolo\.com/v1/"),
+)
+@pluginmatcher(
+    name="mediagovkw",
+    pattern=re.compile(r"https?://media\.gov\.kw/"),
+)
+class Mangomolo(Plugin):
+    def _get_player_url(self):
+        player_url = self.session.http.get(self.url, schema=validate.Schema(
+            validate.parse_html(),
+            validate.xml_xpath_string(".//iframe[contains(@src,'//player.mangomolo.com/v1/')][1]/@src"),
+        ))
+        if not player_url:
+            log.error("Could not find embedded player")
+            raise NoStreamsError
+
+        self.url = update_scheme("https://", player_url)
+
+    def _get_streams(self):
+        if not self.matches["mangomoloplayer"]:
+            self._get_player_url()
+
+        hls_url = self.session.http.get(self.url, schema=validate.Schema(
+            re.compile(r"src\s*:\s*(?P<q>[\"'])(?P<url>https?://\S+?\.m3u8\S*?)(?P=q)"),
+            validate.none_or_all(validate.get("url")),
+        ))
+        if hls_url:
+            return HLSStream.parse_variant_playlist(self.session, hls_url)
+
+
+__plugin__ = Mangomolo


Test patch:
diff --git a/tests/plugins/test_mangomolo.py b/tests/plugins/test_mangomolo.py
new file mode 100644
--- /dev/null
+++ b/tests/plugins/test_mangomolo.py
@@ -0,0 +1,22 @@
+from streamlink.plugins.mangomolo import Mangomolo
+from tests.plugins import PluginCanHandleUrl
+
+
+class TestPluginCanHandleUrlMangomolo(PluginCanHandleUrl):
+    __plugin__ = Mangomolo
+
+    should_match = [
+        (
+            "mangomoloplayer",
+            "https://player.mangomolo.com/v1/live?id=MTk1&channelid=MzU1&countries=bnVsbA==&w=100%25&h=100%25"
+            + "&autoplay=true&filter=none&signature=9ea6c8ed03b8de6e339d6df2b0685f25&app_id=43",
+        ),
+        (
+            "mediagovkw",
+            "https://media.gov.kw/LiveTV.aspx?PanChannel=KTV1",
+        ),
+        (
+            "mediagovkw",
+            "https://media.gov.kw/LiveTV.aspx?PanChannel=KTVSports",
+        ),
+    ]