We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[plugin issue] plugin.vidio.com / can't handle stream URLs anymore
- [x] This is a bug report.
- [ ] This is a feature request.
- [ ] This is a plugin (improvement) request.
- [ ] I have read the contribution guidelines.

### Description
plugin handling of https://www.vidio.com/live  URls not working anymore due to changes at provided stream structure

### Expected / Actual behavior
streamlink -l debug www.vidio.com/live/665-rcti-tv-stream
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.5.2
[cli][debug] Streamlink: 0.12.1
[cli][debug] Requests(2.18.4), Socks(1.6.7), Websocket(0.47.0)
[cli][info] Found matching plugin vidio for URL www.vidio.com/live/665-rcti-tv-stream
[plugin.vidio][debug] HLS URL: https://kmklive-lh.akamaihd.net/i/rcti_ta_regular@94478/master.m3u8
error: Unable to open URL: https://kmklive-lh.akamaihd.net/i/rcti_ta_regular@94478/master.m3u8 (403 Client Error: Forbidden for url: https://kmklive-lh.akamaihd.net/i/rcti_ta_regular@94478/master.m3u8)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/streamlink/plugins/vidio.py`
Content:
```
1 '''
2 Plugin for vidio.com
3 - https://www.vidio.com/live/5075-dw-tv-stream
4 - https://www.vidio.com/watch/766861-5-rekor-fantastis-zidane-bersama-real-madrid
5 '''
6 import re
7 
8 from streamlink.plugin import Plugin
9 from streamlink.plugin.api import http
10 from streamlink.stream import HLSStream
11 
12 _url_re = re.compile(r"https?://(?:www\.)?vidio\.com/(?:en/)?(?P<type>live|watch)/(?P<id>\d+)-(?P<name>[^/?#&]+)")
13 _playlist_re = re.compile(r'''hls-url=["'](?P<url>[^"']+)["']''')
14 
15 
16 class Vidio(Plugin):
17     @classmethod
18     def can_handle_url(cls, url):
19         return _url_re.match(url)
20 
21     def _get_streams(self):
22         res = http.get(self.url)
23 
24         match = _playlist_re.search(res.text)
25         if match is None:
26             return
27 
28         url = match.group('url')
29 
30         if url:
31             self.logger.debug('HLS URL: {0}'.format(url))
32             for s in HLSStream.parse_variant_playlist(self.session, url).items():
33                 yield s
34 
35 
36 __plugin__ = Vidio
37
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/streamlink/plugins/vidio.py b/src/streamlink/plugins/vidio.py
--- a/src/streamlink/plugins/vidio.py
+++ b/src/streamlink/plugins/vidio.py
@@ -1,36 +1,61 @@
-'''
+"""
 Plugin for vidio.com
 - https://www.vidio.com/live/5075-dw-tv-stream
 - https://www.vidio.com/watch/766861-5-rekor-fantastis-zidane-bersama-real-madrid
-'''
+"""
 import re
 
 from streamlink.plugin import Plugin
-from streamlink.plugin.api import http
+from streamlink.plugin.api import http, useragents, validate
 from streamlink.stream import HLSStream
-
-_url_re = re.compile(r"https?://(?:www\.)?vidio\.com/(?:en/)?(?P<type>live|watch)/(?P<id>\d+)-(?P<name>[^/?#&]+)")
-_playlist_re = re.compile(r'''hls-url=["'](?P<url>[^"']+)["']''')
+from streamlink.utils import parse_json
 
 
 class Vidio(Plugin):
+    _url_re = re.compile(r"https?://(?:www\.)?vidio\.com/(?:en/)?(?P<type>live|watch)/(?P<id>\d+)-(?P<name>[^/?#&]+)")
+    _playlist_re = re.compile(r'''hls-url=["'](?P<url>[^"']+)["']''')
+    _data_id_re = re.compile(r'''meta\s+data-id=["'](?P<id>[^"']+)["']''')
+
+    csrf_tokens_url = "https://www.vidio.com/csrf_tokens"
+    tokens_url = "https://www.vidio.com/live/{id}/tokens"
+    token_schema = validate.Schema(validate.transform(parse_json),
+                                   {"token": str},
+                                   validate.get("token"))
+
     @classmethod
     def can_handle_url(cls, url):
-        return _url_re.match(url)
+        return cls._url_re.match(url)
+
+    def get_csrf_tokens(self):
+        return http.get(self.csrf_tokens_url,
+                        schema=self.token_schema)
+
+    def get_url_tokens(self, stream_id):
+        self.logger.debug("Getting stream tokens")
+        csrf_token = self.get_csrf_tokens()
+        return http.post(self.tokens_url.format(id=stream_id),
+                         files={"authenticity_token": (None, csrf_token)},
+                         headers={"User-Agent": useragents.CHROME,
+                                  "Referer": self.url},
+                         schema=self.token_schema)
 
     def _get_streams(self):
         res = http.get(self.url)
 
-        match = _playlist_re.search(res.text)
-        if match is None:
-            return
+        plmatch = self._playlist_re.search(res.text)
+        idmatch = self._data_id_re.search(res.text)
+
+        hls_url = plmatch and plmatch.group("url")
+        stream_id = idmatch and idmatch.group("id")
 
-        url = match.group('url')
+        tokens = self.get_url_tokens(stream_id)
 
-        if url:
-            self.logger.debug('HLS URL: {0}'.format(url))
-            for s in HLSStream.parse_variant_playlist(self.session, url).items():
-                yield s
+        if hls_url:
+            self.logger.debug("HLS URL: {0}".format(hls_url))
+            self.logger.debug("Tokens: {0}".format(tokens))
+            return HLSStream.parse_variant_playlist(self.session, hls_url+"?"+tokens,
+                                                    headers={"User-Agent": useragents.CHROME,
+                                                             "Referer": self.url})
 
 
 __plugin__ = Vidio

{"golden_diff": "diff --git a/src/streamlink/plugins/vidio.py b/src/streamlink/plugins/vidio.py\n--- a/src/streamlink/plugins/vidio.py\n+++ b/src/streamlink/plugins/vidio.py\n@@ -1,36 +1,61 @@\n-'''\n+\"\"\"\n Plugin for vidio.com\n - https://www.vidio.com/live/5075-dw-tv-stream\n - https://www.vidio.com/watch/766861-5-rekor-fantastis-zidane-bersama-real-madrid\n-'''\n+\"\"\"\n import re\n \n from streamlink.plugin import Plugin\n-from streamlink.plugin.api import http\n+from streamlink.plugin.api import http, useragents, validate\n from streamlink.stream import HLSStream\n-\n-_url_re = re.compile(r\"https?://(?:www\\.)?vidio\\.com/(?:en/)?(?P<type>live|watch)/(?P<id>\\d+)-(?P<name>[^/?#&]+)\")\n-_playlist_re = re.compile(r'''hls-url=[\"'](?P<url>[^\"']+)[\"']''')\n+from streamlink.utils import parse_json\n \n \n class Vidio(Plugin):\n+    _url_re = re.compile(r\"https?://(?:www\\.)?vidio\\.com/(?:en/)?(?P<type>live|watch)/(?P<id>\\d+)-(?P<name>[^/?#&]+)\")\n+    _playlist_re = re.compile(r'''hls-url=[\"'](?P<url>[^\"']+)[\"']''')\n+    _data_id_re = re.compile(r'''meta\\s+data-id=[\"'](?P<id>[^\"']+)[\"']''')\n+\n+    csrf_tokens_url = \"https://www.vidio.com/csrf_tokens\"\n+    tokens_url = \"https://www.vidio.com/live/{id}/tokens\"\n+    token_schema = validate.Schema(validate.transform(parse_json),\n+                                   {\"token\": str},\n+                                   validate.get(\"token\"))\n+\n     @classmethod\n     def can_handle_url(cls, url):\n-        return _url_re.match(url)\n+        return cls._url_re.match(url)\n+\n+    def get_csrf_tokens(self):\n+        return http.get(self.csrf_tokens_url,\n+                        schema=self.token_schema)\n+\n+    def get_url_tokens(self, stream_id):\n+        self.logger.debug(\"Getting stream tokens\")\n+        csrf_token = self.get_csrf_tokens()\n+        return http.post(self.tokens_url.format(id=stream_id),\n+                         files={\"authenticity_token\": (None, csrf_token)},\n+                         headers={\"User-Agent\": useragents.CHROME,\n+                                  \"Referer\": self.url},\n+                         schema=self.token_schema)\n \n     def _get_streams(self):\n         res = http.get(self.url)\n \n-        match = _playlist_re.search(res.text)\n-        if match is None:\n-            return\n+        plmatch = self._playlist_re.search(res.text)\n+        idmatch = self._data_id_re.search(res.text)\n+\n+        hls_url = plmatch and plmatch.group(\"url\")\n+        stream_id = idmatch and idmatch.group(\"id\")\n \n-        url = match.group('url')\n+        tokens = self.get_url_tokens(stream_id)\n \n-        if url:\n-            self.logger.debug('HLS URL: {0}'.format(url))\n-            for s in HLSStream.parse_variant_playlist(self.session, url).items():\n-                yield s\n+        if hls_url:\n+            self.logger.debug(\"HLS URL: {0}\".format(hls_url))\n+            self.logger.debug(\"Tokens: {0}\".format(tokens))\n+            return HLSStream.parse_variant_playlist(self.session, hls_url+\"?\"+tokens,\n+                                                    headers={\"User-Agent\": useragents.CHROME,\n+                                                             \"Referer\": self.url})\n \n \n __plugin__ = Vidio\n", "issue": "[plugin issue] plugin.vidio.com / can't handle stream URLs anymore\n- [x] This is a bug report.\r\n- [ ] This is a feature request.\r\n- [ ] This is a plugin (improvement) request.\r\n- [ ] I have read the contribution guidelines.\r\n\r\n### Description\r\nplugin handling of https://www.vidio.com/live  URls not working anymore due to changes at provided stream structure\r\n\r\n### Expected / Actual behavior\r\nstreamlink -l debug www.vidio.com/live/665-rcti-tv-stream\r\n[cli][debug] OS:         Windows 10\r\n[cli][debug] Python:     3.5.2\r\n[cli][debug] Streamlink: 0.12.1\r\n[cli][debug] Requests(2.18.4), Socks(1.6.7), Websocket(0.47.0)\r\n[cli][info] Found matching plugin vidio for URL www.vidio.com/live/665-rcti-tv-stream\r\n[plugin.vidio][debug] HLS URL: https://kmklive-lh.akamaihd.net/i/rcti_ta_regular@94478/master.m3u8\r\nerror: Unable to open URL: https://kmklive-lh.akamaihd.net/i/rcti_ta_regular@94478/master.m3u8 (403 Client Error: Forbidden for url: https://kmklive-lh.akamaihd.net/i/rcti_ta_regular@94478/master.m3u8)\r\n\n", "before_files": [{"content": "'''\nPlugin for vidio.com\n- https://www.vidio.com/live/5075-dw-tv-stream\n- https://www.vidio.com/watch/766861-5-rekor-fantastis-zidane-bersama-real-madrid\n'''\nimport re\n\nfrom streamlink.plugin import Plugin\nfrom streamlink.plugin.api import http\nfrom streamlink.stream import HLSStream\n\n_url_re = re.compile(r\"https?://(?:www\\.)?vidio\\.com/(?:en/)?(?P<type>live|watch)/(?P<id>\\d+)-(?P<name>[^/?#&]+)\")\n_playlist_re = re.compile(r'''hls-url=[\"'](?P<url>[^\"']+)[\"']''')\n\n\nclass Vidio(Plugin):\n    @classmethod\n    def can_handle_url(cls, url):\n        return _url_re.match(url)\n\n    def _get_streams(self):\n        res = http.get(self.url)\n\n        match = _playlist_re.search(res.text)\n        if match is None:\n            return\n\n        url = match.group('url')\n\n        if url:\n            self.logger.debug('HLS URL: {0}'.format(url))\n            for s in HLSStream.parse_variant_playlist(self.session, url).items():\n                yield s\n\n\n__plugin__ = Vidio\n", "path": "src/streamlink/plugins/vidio.py"}], "after_files": [{"content": "\"\"\"\nPlugin for vidio.com\n- https://www.vidio.com/live/5075-dw-tv-stream\n- https://www.vidio.com/watch/766861-5-rekor-fantastis-zidane-bersama-real-madrid\n\"\"\"\nimport re\n\nfrom streamlink.plugin import Plugin\nfrom streamlink.plugin.api import http, useragents, validate\nfrom streamlink.stream import HLSStream\nfrom streamlink.utils import parse_json\n\n\nclass Vidio(Plugin):\n    _url_re = re.compile(r\"https?://(?:www\\.)?vidio\\.com/(?:en/)?(?P<type>live|watch)/(?P<id>\\d+)-(?P<name>[^/?#&]+)\")\n    _playlist_re = re.compile(r'''hls-url=[\"'](?P<url>[^\"']+)[\"']''')\n    _data_id_re = re.compile(r'''meta\\s+data-id=[\"'](?P<id>[^\"']+)[\"']''')\n\n    csrf_tokens_url = \"https://www.vidio.com/csrf_tokens\"\n    tokens_url = \"https://www.vidio.com/live/{id}/tokens\"\n    token_schema = validate.Schema(validate.transform(parse_json),\n                                   {\"token\": str},\n                                   validate.get(\"token\"))\n\n    @classmethod\n    def can_handle_url(cls, url):\n        return cls._url_re.match(url)\n\n    def get_csrf_tokens(self):\n        return http.get(self.csrf_tokens_url,\n                        schema=self.token_schema)\n\n    def get_url_tokens(self, stream_id):\n        self.logger.debug(\"Getting stream tokens\")\n        csrf_token = self.get_csrf_tokens()\n        return http.post(self.tokens_url.format(id=stream_id),\n                         files={\"authenticity_token\": (None, csrf_token)},\n                         headers={\"User-Agent\": useragents.CHROME,\n                                  \"Referer\": self.url},\n                         schema=self.token_schema)\n\n    def _get_streams(self):\n        res = http.get(self.url)\n\n        plmatch = self._playlist_re.search(res.text)\n        idmatch = self._data_id_re.search(res.text)\n\n        hls_url = plmatch and plmatch.group(\"url\")\n        stream_id = idmatch and idmatch.group(\"id\")\n\n        tokens = self.get_url_tokens(stream_id)\n\n        if hls_url:\n            self.logger.debug(\"HLS URL: {0}\".format(hls_url))\n            self.logger.debug(\"Tokens: {0}\".format(tokens))\n            return HLSStream.parse_variant_playlist(self.session, hls_url+\"?\"+tokens,\n                                                    headers={\"User-Agent\": useragents.CHROME,\n                                                             \"Referer\": self.url})\n\n\n__plugin__ = Vidio\n", "path": "src/streamlink/plugins/vidio.py"}]}