Repository: streamlink/streamlink

Issue:
plugins.bigo: Unable to parse JSON
### 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

Latest release

### Description

Hello,

the bigo.py is not working at the moment.

It is giving a parse JSON error.

Debug log is following...

### Debug log

```text
error: Unable to parse JSON: Expecting value: line 1 column 1 (char 0) ('<!DOCTYPE html>\n<html lang="en" s ...)
```



Discussion:

Resolving patch:
diff --git a/src/streamlink/plugins/bigo.py b/src/streamlink/plugins/bigo.py
--- a/src/streamlink/plugins/bigo.py
+++ b/src/streamlink/plugins/bigo.py
@@ -1,41 +1,68 @@
 """
-$description Global live streaming platform for live video game broadcasts and individual live streams.
-$url live.bigo.tv
-$url bigoweb.co
+$description Global live-streaming platform for live video game broadcasts and individual live streams.
+$url bigo.tv
 $type live
+$metadata id
+$metadata author
+$metadata category
+$metadata title
 """
 
+import logging
 import re
 
 from streamlink.plugin import Plugin, pluginmatcher
-from streamlink.plugin.api import useragents, validate
+from streamlink.plugin.api import validate
 from streamlink.stream.hls import HLSStream
 
 
+log = logging.getLogger(__name__)
+
+
 @pluginmatcher(re.compile(
-    r"https?://(?:www\.)?bigo\.tv/([^/]+)$",
+    r"https?://(?:www\.)?bigo\.tv/(?P<site_id>[^/]+)$",
 ))
 class Bigo(Plugin):
-    _api_url = "https://www.bigo.tv/OInterface/getVideoParam?bigoId={0}"
-
-    _video_info_schema = validate.Schema({
-        "code": 0,
-        "msg": "success",
-        "data": {
-            "videoSrc": validate.any(None, "", validate.url()),
-        },
-    })
+    _URL_API = "https://ta.bigo.tv/official_website/studio/getInternalStudioInfo"
 
     def _get_streams(self):
-        res = self.session.http.get(
-            self._api_url.format(self.match.group(1)),
-            allow_redirects=True,
-            headers={"User-Agent": useragents.IPHONE_6},
+        self.id, self.author, self.category, self.title, hls_url = self.session.http.post(
+            self._URL_API,
+            params={
+                "siteId": self.match["site_id"],
+                "verify": "",
+            },
+            schema=validate.Schema(
+                validate.parse_json(),
+                {
+                    "code": 0,
+                    "msg": "success",
+                    "data": {
+                        "roomId": validate.any(None, str),
+                        "clientBigoId": validate.any(None, str),
+                        "gameTitle": str,
+                        "roomTopic": str,
+                        "hls_src": validate.any(None, "", validate.url()),
+                    },
+                },
+                validate.union_get(
+                    ("data", "roomId"),
+                    ("data", "clientBigoId"),
+                    ("data", "gameTitle"),
+                    ("data", "roomTopic"),
+                    ("data", "hls_src"),
+                ),
+            ),
         )
-        data = self.session.http.json(res, schema=self._video_info_schema)
-        videourl = data["data"]["videoSrc"]
-        if videourl:
-            yield "live", HLSStream(self.session, videourl)
+
+        if not self.id:
+            return
+
+        if not hls_url:
+            log.info("Channel is offline")
+            return
+
+        yield "live", HLSStream(self.session, hls_url)
 
 
 __plugin__ = Bigo


Test patch:
diff --git a/tests/plugins/test_bigo.py b/tests/plugins/test_bigo.py
--- a/tests/plugins/test_bigo.py
+++ b/tests/plugins/test_bigo.py
@@ -6,27 +6,5 @@ class TestPluginCanHandleUrlBigo(PluginCanHandleUrl):
     __plugin__ = Bigo
 
     should_match = [
-        "http://bigo.tv/00000000",
-        "https://bigo.tv/00000000",
-        "https://www.bigo.tv/00000000",
-        "http://www.bigo.tv/00000000",
-        "http://www.bigo.tv/fancy1234",
-        "http://www.bigo.tv/abc.123",
-        "http://www.bigo.tv/000000.00",
-    ]
-
-    should_not_match = [
-        # Old URLs don't work anymore
-        "http://live.bigo.tv/00000000",
-        "https://live.bigo.tv/00000000",
-        "http://www.bigoweb.co/show/00000000",
-        "https://www.bigoweb.co/show/00000000",
-        "http://bigoweb.co/show/00000000",
-        "https://bigoweb.co/show/00000000",
-
-        # Wrong URL structure
-        "https://www.bigo.tv/show/00000000",
-        "http://www.bigo.tv/show/00000000",
-        "http://bigo.tv/show/00000000",
-        "https://bigo.tv/show/00000000",
+        "https://www.bigo.tv/SITE_ID",
     ]