Repository: streamlink/streamlink

Issue:
plugins.tv8: doesn't work
<!--
Thanks for reporting a plugin issue!
USE THE TEMPLATE. Otherwise your plugin issue may be rejected.

First, see the contribution guidelines:
https://github.com/streamlink/streamlink/blob/master/CONTRIBUTING.md#contributing-to-streamlink

Plugin issues describe broken functionality within a plugin's code base, eg. the streaming site has made breaking changes, streams don't get resolved correctly, or authentication has stopped working, etc.

Also check the list of open and closed plugin issues:
https://github.com/streamlink/streamlink/issues?q=is%3Aissue+label%3A%22plugin+issue%22

Please see the text preview to avoid unnecessary formatting errors.
-->


## Plugin Issue

<!-- Replace the space character between the square brackets with an x in order to check the boxes -->
- [x] This is a plugin issue and I have read the contribution guidelines.
- [x] I am using the latest development version from the master branch.


### Description

<!-- Explain the plugin issue as thoroughly as you can. -->


### Reproduction steps / Explicit stream URLs to test

<!-- How can we reproduce this? Please note the exact steps below using the list format supplied. If you need more steps please add them. -->

https://www.tv8.com.tr/canli-yayin


### Log output

<!--
DEBUG LOG OUTPUT IS REQUIRED for a plugin issue!
INCLUDE THE ENTIRE COMMAND LINE and make sure to **remove usernames and passwords**

Use the `--loglevel debug` parameter and avoid using parameters which suppress log output.
Debug log includes important details about your platform. Don't remove it.
https://streamlink.github.io/latest/cli.html#cmdoption-loglevel

You can copy the output to https://gist.github.com/ or paste it below.

Don't post screenshots of the log output and instead copy the text from your terminal application.
-->

```
[cli][debug] OS:         Windows
[cli][debug] Python:     3.8.10
[cli][debug] Streamlink: 2.2.0
[cli][debug] Requests(2.25.1), Socks(1.7.1), Websocket(1.1.0)
[cli][debug] Arguments:
[cli][debug]  url=https://www.tv8.com.tr/canli-yayin
[cli][debug]  stream=['best']
[cli][debug]  --loglevel=debug
[cli][debug]  --player=mpv.exe
[cli][debug]  --rtmpdump=rtmpdump.exe
[cli][debug]  --ffmpeg-ffmpeg=ffmpeg.exe
[cli][info] Found matching plugin tv8 for URL https://www.tv8.com.tr/canli-yayin
[plugins.tv8][debug] {'manifest': 'https://tv8.personamedia.tv/tv8', 'hlsmanifest': 'https://tv8.personamedia.tv/tv8hls?fmt=hls'}
[utils.l10n][debug] Language code: tr_TR
error: Unable to open URL: https://tv8.personamedia.tv/tv8hls?fmt=hls (503 Server Error: Service Temporarily Unavailable for url: https://tv8.personamedia.tv/tv8hls?fmt=hls)
```


### Additional comments, etc.
While watching from browser, seeing "https://tv8-tb-live.ercdn.net/tv8-geo/playlist.m3u8" on Network inspector


[Love Streamlink? Please consider supporting our collective. Thanks!](https://opencollective.com/streamlink/donate)



Discussion:

Resolving patch:
diff --git a/src/streamlink/plugins/tv8.py b/src/streamlink/plugins/tv8.py
--- a/src/streamlink/plugins/tv8.py
+++ b/src/streamlink/plugins/tv8.py
@@ -12,23 +12,18 @@
     r'https?://www\.tv8\.com\.tr/canli-yayin'
 ))
 class TV8(Plugin):
-    _player_schema = validate.Schema(validate.all({
-        'servers': {
-            validate.optional('manifest'): validate.url(),
-            'hlsmanifest': validate.url(),
-        }},
-        validate.get('servers')))
-
-    API_URL = 'https://static.personamedia.tv/player/config/tv8.json'
+    _re_hls = re.compile(r"""file\s*:\s*(["'])(?P<hls_url>https?://.*?\.m3u8.*?)\1""")
 
     def get_title(self):
         return 'TV8'
 
     def _get_streams(self):
-        res = self.session.http.get(self.API_URL)
-        data = self.session.http.json(res, schema=self._player_schema)
-        log.debug('{0!r}'.format(data))
-        return HLSStream.parse_variant_playlist(self.session, data['hlsmanifest'])
+        hls_url = self.session.http.get(self.url, schema=validate.Schema(
+            validate.transform(self._re_hls.search),
+            validate.any(None, validate.get("hls_url"))
+        ))
+        if hls_url is not None:
+            return HLSStream.parse_variant_playlist(self.session, hls_url)
 
 
 __plugin__ = TV8


Test patch: