Skip to content

Commit

Permalink
Merge pull request #48 from kingosticks/feature/use-is-live
Browse files Browse the repository at this point in the history
Setting live mode for playable streams that we cannot seek.
  • Loading branch information
kingosticks authored Jan 12, 2021
2 parents 98dc2dc + ba4d94e commit c5ea350
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion mopidy_tunein/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -162,14 +166,22 @@ 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,
requests_session=self.backend._session,
)
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):
Expand Down

0 comments on commit c5ea350

Please sign in to comment.