Repository: streamlink/streamlink

Issue:
plugins.nimotv: live stream stops after couple of seconds
### Checklist

- [X] This is a plugin issue and not a different kind of issue
- [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 stable release

### Description

try any live streams of nimo.tv, the live stream will stop in couple of seconds.

### Debug log

```text
c:\temp>streamlink --loglevel debug https://www.nimo.tv/live/97747608 best
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.7.8
[cli][debug] Streamlink: 5.1.2
[cli][debug] Dependencies:
[cli][debug]  certifi: 2018.11.29
[cli][debug]  isodate: 0.6.0
[cli][debug]  lxml: 4.6.4
[cli][debug]  pycountry: 20.7.3
[cli][debug]  pycryptodome: 3.7.3
[cli][debug]  PySocks: 1.6.8
[cli][debug]  requests: 2.26.0
[cli][debug]  urllib3: 1.26.12
[cli][debug]  websocket-client: 1.2.1
[cli][debug]  importlib-metadata: 3.10.0
[cli][debug] Arguments:
[cli][debug]  url=https://www.nimo.tv/live/97747608
[cli][debug]  stream=['best']
[cli][debug]  --loglevel=debug
[cli][info] Found matching plugin nimotv for URL https://www.nimo.tv/live/97747608
[plugins.nimotv][debug] URL=http://tx.hls.nimo.tv/live/su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7.m3u8
[cli][info] Available streams: 240p (worst), 360p, 480p, 720p, 1080p (best)
[cli][info] Opening stream: 1080p (hls)
[cli][info] Starting player: "C:\Program Files\VideoLAN\VLC\vlc.exe"
[stream.hls][debug] Reloading playlist
[cli][debug] Pre-buffering 8192 bytes
[stream.hls][debug] First Sequence: 1674443953; Last Sequence: 1674443955
[stream.hls][debug] Start offset: 0; Duration: None; Start Sequence: 1674443953; End Sequence: None
[stream.hls][debug] Adding segment 1674443953 to queue
[stream.hls][debug] Adding segment 1674443954 to queue
[stream.hls][debug] Adding segment 1674443955 to queue
[stream.hls][debug] Writing segment 1674443953 to output
[stream.hls][debug] Segment 1674443953 complete
[cli.output][debug] Opening subprocess: "C:\Program Files\VideoLAN\VLC\vlc.exe" --input-title-format https://www.nimo.tv/live/97747608 -
[cli][debug] Writing stream to output
[stream.hls][debug] Writing segment 1674443954 to output
[stream.hls][debug] Segment 1674443954 complete
[stream.hls][debug] Writing segment 1674443955 to output
[stream.hls][debug] Segment 1674443955 complete
[stream.hls][debug] Reloading playlist
[stream.hls][warning] Failed to reload playlist: Unable to open URL: http://tx.hls.nimo.tv/live/su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7.m3u8?appid=81&id=su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7&tp=1674443951824&u=0&t=100&needwm=0&ratio=6000 (403 Client Error: Forbidden for url: http://tx.hls.nimo.tv/live/su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7.m3u8?appid=81&id=su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7&tp=1674443951824&u=0&t=100&needwm=0&ratio=6000&appid=81&id=su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7&tp=1674443951824&u=0&t=100&needwm=0&ratio=6000)
[stream.hls][debug] Reloading playlist
[stream.hls][warning] Failed to reload playlist: Unable to open URL: http://tx.hls.nimo.tv/live/su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7.m3u8?appid=81&id=su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7&tp=1674443951824&u=0&t=100&needwm=0&ratio=6000 (403 Client Error: Forbidden for url: http://tx.hls.nimo.tv/live/su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7.m3u8?appid=81&id=su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7&tp=1674443951824&u=0&t=100&needwm=0&ratio=6000&appid=81&id=su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7&tp=1674443951824&u=0&t=100&needwm=0&ratio=6000)
[stream.hls][debug] Reloading playlist
[stream.hls][warning] Failed to reload playlist: Unable to open URL: http://tx.hls.nimo.tv/live/su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7.m3u8?appid=81&id=su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7&tp=1674443951824&u=0&t=100&needwm=0&ratio=6000 (403 Client Error: Forbidden for url: http://tx.hls.nimo.tv/live/su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7.m3u8?appid=81&id=su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7&tp=1674443951824&u=0&t=100&needwm=0&ratio=6000&appid=81&id=su1629530778249rea7ea30592d8ab7ce78a1a13e3037be7&tp=1674443951824&u=0&t=100&needwm=0&ratio=6000)
```



Discussion:

Resolving patch:
diff --git a/src/streamlink/plugins/nimotv.py b/src/streamlink/plugins/nimotv.py
--- a/src/streamlink/plugins/nimotv.py
+++ b/src/streamlink/plugins/nimotv.py
@@ -9,7 +9,7 @@
 
 from streamlink.plugin import Plugin, pluginmatcher
 from streamlink.plugin.api import useragents, validate
-from streamlink.stream.hls import HLSStream
+from streamlink.stream.http import HTTPStream
 
 log = logging.getLogger(__name__)
 
@@ -32,6 +32,8 @@ class NimoTV(Plugin):
     _re_domain = re.compile(br'(https?:\/\/[A-Za-z]{2,3}.hls[A-Za-z\.\/]+)(?:V|&)')
     _re_id = re.compile(br'id=([^|\\]+)')
     _re_tp = re.compile(br'tp=(\d+)')
+    _re_wsSecret = re.compile(br'wsSecret=(\w+)')
+    _re_wsTime = re.compile(br'wsTime=(\w+)')
 
     def _get_streams(self):
         username = self.match.group('username')
@@ -74,6 +76,8 @@ def _get_streams(self):
             _domain = self._re_domain.search(mStreamPkg).group(1).decode('utf-8')
             _id = self._re_id.search(mStreamPkg).group(1).decode('utf-8')
             _tp = self._re_tp.search(mStreamPkg).group(1).decode('utf-8')
+            _wsSecret = self._re_wsSecret.search(mStreamPkg).group(1).decode('utf-8')
+            _wsTime = self._re_wsTime.search(mStreamPkg).group(1).decode('utf-8')
         except AttributeError:
             log.error('invalid mStreamPkg')
             return
@@ -82,11 +86,14 @@ def _get_streams(self):
             'appid': _appid,
             'id': _id,
             'tp': _tp,
+            'wsSecret': _wsSecret,
+            'wsTime': _wsTime,
             'u': '0',
             't': '100',
             'needwm': 1,
         }
-        url = f'{_domain}{_id}.m3u8'
+        url = f'{_domain}{_id}.flv'
+        url = url.replace('hls.nimo.tv', 'flv.nimo.tv')
         log.debug(f'URL={url}')
         for k, v in self.video_qualities.items():
             _params = params.copy()
@@ -98,7 +105,7 @@ def _get_streams(self):
 
             log.trace(f'{v} params={_params!r}')
             # some qualities might not exist, but it will select a different lower quality
-            yield v, HLSStream(self.session, url, params=_params)
+            yield v, HTTPStream(self.session, url, params=_params)
 
         self.author = data['nickname']
         self.category = data['game']


Test patch: