Repository: streamlink/streamlink

Issue:
plugins.hiplayer: Could not find base64 encoded JSON data
### Checklist

- [X] This is a [plugin issue](https://streamlink.github.io/plugins.html) 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 issues](https://github.com/streamlink/streamlink/issues?q=is%3Aissue+label%3A%22plugin+issue%22)
- [X] [I have checked the commit log of the master branch](https://github.com/streamlink/streamlink/commits/master)

### Streamlink version

streamlink 6.1.0

### Description

Hi team. I was able to get stream url from following page successfully for past weeks. Two days ago, I found streamlink isn't able to retrieve the steam url:

web page: https://www.media.gov.kw/LiveTV.aspx?PanChannel=KTV1
This is the official website of Kuwait for their national channels.

I tried 3 different machines on different operating systems where streamlink was working successfully and retrieving the stream url for this website. All recently failed with same message (No playable streams...etc.)

### Debug log

```text
Desktop:~$ streamlink https://www.media.gov.kw/LiveTV.aspx?PanChannel=KTV1 --loglevel=debug
[cli][debug] OS: Linux-5.15.90.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
[cli][debug] Python: 3.10.12
[cli][debug] Streamlink: 6.1.0
[cli][debug] Dependencies:
[cli][debug] certifi: 2023.7.22
[cli][debug] isodate: 0.6.1
[cli][debug] lxml: 4.9.3
[cli][debug] pycountry: 22.3.5
[cli][debug] pycryptodome: 3.18.0
[cli][debug] PySocks: 1.7.1
[cli][debug] requests: 2.31.0
[cli][debug] trio: 0.22.2
[cli][debug] trio-websocket: 0.10.3
[cli][debug] typing-extensions: 4.7.1
[cli][debug] urllib3: 2.0.4
[cli][debug] websocket-client: 1.6.2
[cli][debug] Arguments:
[cli][debug] url=https://www.media.gov.kw/LiveTV.aspx?PanChannel=KTV1
[cli][debug] --loglevel=debug
[cli][info] Found matching plugin hiplayer for URL https://www.media.gov.kw/LiveTV.aspx?PanChannel=KTV1
[plugins.hiplayer][debug] JS URL=https://hiplayer.hibridcdn.net/l/kwmedia-kwtv1
[plugins.hiplayer][error] Could not find base64 encoded JSON data
error: No playable streams found on this URL: https://www.media.gov.kw/LiveTV.aspx?PanChannel=KTV1
```



Discussion:

Resolving patch:
diff --git a/src/streamlink/plugins/hiplayer.py b/src/streamlink/plugins/hiplayer.py
--- a/src/streamlink/plugins/hiplayer.py
+++ b/src/streamlink/plugins/hiplayer.py
@@ -2,7 +2,6 @@
 $description United Arab Emirates CDN hosting live content for various websites in The Middle East.
 $url alwasat.ly
 $url media.gov.kw
-$url rotana.net
 $type live
 $region various
 """
@@ -19,16 +18,8 @@
 log = logging.getLogger(__name__)
 
 
-@pluginmatcher(re.compile(r"""
-    https?://(?:www\.)?
-    (
-        alwasat\.ly
-    |
-        media\.gov\.kw
-    |
-        rotana\.net
-    )
-""", re.VERBOSE))
+@pluginmatcher(name="alwasatly", pattern=re.compile(r"https?://(?:www\.)?alwasat\.ly"))
+@pluginmatcher(name="mediagovkw", pattern=re.compile(r"https?://(?:www\.)?media\.gov\.kw"))
 class HiPlayer(Plugin):
     DAI_URL = "https://pubads.g.doubleclick.net/ssai/event/{0}/streams"
 
@@ -56,7 +47,7 @@ def _get_streams(self):
         data = self.session.http.get(
             js_url,
             schema=validate.Schema(
-                re.compile(r"var \w+\s*=\s*\[(?P<data>.+)]\.join\([\"']{2}\)"),
+                re.compile(r"\[(?P<data>[^]]+)]\.join\([\"']{2}\)"),
                 validate.none_or_all(
                     validate.get("data"),
                     validate.transform(lambda s: re.sub(r"['\", ]", "", s)),


Test patch:
diff --git a/tests/plugins/test_hiplayer.py b/tests/plugins/test_hiplayer.py
--- a/tests/plugins/test_hiplayer.py
+++ b/tests/plugins/test_hiplayer.py
@@ -6,10 +6,7 @@ class TestPluginCanHandleUrlHiPlayer(PluginCanHandleUrl):
     __plugin__ = HiPlayer
 
     should_match = [
-        "https://www.alwasat.ly/any",
-        "https://www.alwasat.ly/any/path",
-        "https://www.media.gov.kw/any",
-        "https://www.media.gov.kw/any/path",
-        "https://rotana.net/any",
-        "https://rotana.net/any/path",
+        ("alwasatly", "https://alwasat.ly/live"),
+        ("mediagovkw", "https://www.media.gov.kw/LiveTV.aspx?PanChannel=KTV1"),
+        ("mediagovkw", "https://www.media.gov.kw/LiveTV.aspx?PanChannel=KTVSports"),
     ]