From ba4d94ebb224ead8a9b8bbaa884dd9f07654ba48 Mon Sep 17 00:00:00 2001 From: Nick Steel Date: Mon, 11 Jan 2021 23:43:06 +0000 Subject: [PATCH] Setting live mode for playable streams that we cannot seek. This is by no means perfect but I think it'll be better than not using is_live at all. --- mopidy_tunein/actor.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mopidy_tunein/actor.py b/mopidy_tunein/actor.py index dcce580..66134e9 100644 --- a/mopidy_tunein/actor.py +++ b/mopidy_tunein/actor.py @@ -139,6 +139,10 @@ def search(self, query=None, uris=None, exact=False): class TuneInPlayback(backend.PlaybackProvider): + def __init__(self, audio, backend): + super().__init__(audio, backend) + self._stream_info = None + def translate_uri(self, uri): variant, identifier = translator.parse_uri(uri) station = self.backend.tunein.station(identifier) @@ -162,7 +166,7 @@ def translate_uri(self, uri): return None def unwrap_stream(self, uri): - unwrapped_uri, _ = _unwrap_stream( + unwrapped_uri, self._stream_info = _unwrap_stream( uri, timeout=self.backend._timeout, scanner=self.backend._scanner, @@ -170,6 +174,14 @@ def unwrap_stream(self, uri): ) return unwrapped_uri + def is_live(self, uri): + return ( + self._stream_info is not None + and self._stream_info.uri == uri + and self._stream_info.playable + and not self._stream_info.seekable + ) + # Shamelessly taken from mopidy.stream.actor def _unwrap_stream(uri, timeout, scanner, requests_session):