def lookup(self, uri): variant, identifier = translator.parse_uri(uri) if variant != 'station': return [] station = self.backend.tunein.station(identifier) if not station: return [] track = translator.station_to_track(station) return [track]
def lookup(self, uri): variant, identifier = translator.parse_uri(uri) if variant != "station": return [] station = self.backend.tunein.station(identifier) if not station: return [] track = translator.station_to_track(station) return [track]
def get_images(self, uris): results = {} for uri in uris: variant, identifier = translator.parse_uri(uri) if variant != "station": continue station = self.backend.tunein.station(identifier) image = translator.station_to_image(station) if image is not None: results[uri] = [image] return results
def browse(self, uri): result = [] variant, identifier = translator.parse_uri(uri) logger.debug('Browsing %s' % uri) if variant == 'root': for category in self.backend.tunein.categories(): result.append(translator.category_to_ref(category)) elif variant == "category" and identifier: for section in self.backend.tunein.categories(identifier): result.append(translator.section_to_ref(section, identifier)) elif variant == "location" and identifier: for location in self.backend.tunein.locations(identifier): result.append(translator.section_to_ref(location, 'local')) for station in self.backend.tunein.stations(identifier): result.append(translator.station_to_ref(station)) elif variant == "section" and identifier: if (self.backend.tunein.related(identifier)): result.append( Ref.directory(uri='tunein:related:%s' % identifier, name='Related')) if (self.backend.tunein.shows(identifier)): result.append( Ref.directory(uri='tunein:shows:%s' % identifier, name='Shows')) for station in self.backend.tunein.featured(identifier): result.append(translator.section_to_ref(station)) for station in self.backend.tunein.local(identifier): result.append(translator.station_to_ref(station)) for station in self.backend.tunein.stations(identifier): result.append(translator.station_to_ref(station)) elif variant == "related" and identifier: for section in self.backend.tunein.related(identifier): result.append(translator.section_to_ref(section)) elif variant == "shows" and identifier: for show in self.backend.tunein.shows(identifier): result.append(translator.show_to_ref(show)) elif variant == "episodes" and identifier: for episode in self.backend.tunein.episodes(identifier): result.append(translator.station_to_ref(episode)) else: logger.debug('Unknown URI: %s', uri) return result
def browse(self, uri): result = [] variant, identifier = translator.parse_uri(uri) logger.debug(f"Browsing {uri!r}") if variant == "root": for category in self.backend.tunein.categories(): result.append(translator.category_to_ref(category)) elif variant == "category" and identifier: for section in self.backend.tunein.categories(identifier): result.append(translator.section_to_ref(section, identifier)) elif variant == "location" and identifier: for location in self.backend.tunein.locations(identifier): result.append(translator.section_to_ref(location, "local")) for station in self.backend.tunein.stations(identifier): result.append(translator.station_to_ref(station)) elif variant == "section" and identifier: if self.backend.tunein.related(identifier): result.append( Ref.directory(uri=f"tunein:related:{identifier}", name="Related")) if self.backend.tunein.shows(identifier): result.append( Ref.directory(uri=f"tunein:shows:{identifier}", name="Shows")) for station in self.backend.tunein.featured(identifier): result.append(translator.section_to_ref(station)) for station in self.backend.tunein.local(identifier): result.append(translator.station_to_ref(station)) for station in self.backend.tunein.stations(identifier): result.append(translator.station_to_ref(station)) elif variant == "related" and identifier: for section in self.backend.tunein.related(identifier): result.append(translator.section_to_ref(section)) elif variant == "shows" and identifier: for show in self.backend.tunein.shows(identifier): result.append(translator.show_to_ref(show)) elif variant == "episodes" and identifier: for episode in self.backend.tunein.episodes(identifier): result.append(translator.station_to_ref(episode)) else: logger.debug(f"Unknown URI: {uri!r}") return result
def browse(self, uri): result = [] variant, identifier = translator.parse_uri(uri) logger.debug('Browsing %s' % uri) if variant == 'root': for category in self.backend.tunein.categories(): result.append(translator.category_to_ref(category)) elif variant == "category" and identifier: for section in self.backend.tunein.categories(identifier): result.append(translator.section_to_ref(section, identifier)) elif variant == "location" and identifier: for location in self.backend.tunein.locations(identifier): result.append(translator.section_to_ref(location, 'local')) for station in self.backend.tunein.stations(identifier): result.append(translator.station_to_ref(station)) elif variant == "section" and identifier: if (self.backend.tunein.related(identifier)): result.append(Ref.directory( uri='tunein:related:%s' % identifier, name='Related')) if (self.backend.tunein.shows(identifier)): result.append(Ref.directory( uri='tunein:shows:%s' % identifier, name='Shows')) for station in self.backend.tunein.featured(identifier): result.append(translator.section_to_ref(station)) for station in self.backend.tunein.local(identifier): result.append(translator.station_to_ref(station)) for station in self.backend.tunein.stations(identifier): result.append(translator.station_to_ref(station)) elif variant == "related" and identifier: for section in self.backend.tunein.related(identifier): result.append(translator.section_to_ref(section)) elif variant == "shows" and identifier: for show in self.backend.tunein.shows(identifier): result.append(translator.show_to_ref(show)) elif variant == "episodes" and identifier: for episode in self.backend.tunein.episodes(identifier): result.append(translator.station_to_ref(episode)) else: logger.debug('Unknown URI: %s', uri) return result
def translate_uri(self, uri): variant, identifier = translator.parse_uri(uri) station = self.backend.tunein.station(identifier) if not station: return None stream_uris = self.backend.tunein.tune(station) while stream_uris: uri = stream_uris.pop(0) logger.debug("Looking up URI: %s." % uri) new_uri = self.unwrap_stream(uri) if new_uri: return new_uri else: logger.debug("Mopidy translate_uri failed.") new_uris = self.backend.tunein.parse_stream_url(uri) if new_uris == [uri]: logger.debug("Last attempt, play stream anyway: %s." % uri) return uri stream_uris.extend(new_uris) logger.debug("TuneIn lookup failed.") return None
def translate_uri(self, uri): variant, identifier = translator.parse_uri(uri) station = self.backend.tunein.station(identifier) if not station: return None stream_uris = self.backend.tunein.tune(station) while stream_uris: uri = stream_uris.pop(0) logger.debug('Looking up URI: %s.' % uri) new_uri = self.unwrap_stream(uri) if new_uri: return new_uri else: logger.debug('Mopidy translate_uri failed.') new_uris = self.backend.tunein.parse_stream_url(uri) if new_uris == [uri]: logger.debug('Last attempt, play stream anyway: %s.' % uri) return uri stream_uris.extend(new_uris) logger.debug('TuneIn lookup failed.') return None
def translate_uri(self, uri): variant, identifier = translator.parse_uri(uri) station = self.backend.tunein.station(identifier) if not station: return None stream_uris = self.backend.tunein.tune(station) while stream_uris: uri = stream_uris.pop(0) logger.debug('Looking up URI: %s.' % uri) try: # TODO: Somehow update metadata using station. return self._scanner.scan(uri).uri except exceptions.ScannerError as se: logger.debug('Mopidy scan failed: %s.' % se) new_uris = self.backend.tunein.parse_stream_url(uri) if new_uris == [uri]: logger.debug('Last attempt, play stream anyway: %s.' % uri) return uri stream_uris.extend(new_uris) logger.debug('TuneIn lookup failed.') return None
def translate_uri(self, uri): variant, identifier = translator.parse_uri(uri) station = self.backend.tunein.station(identifier) if not station: return None stream_uris = self.backend.tunein.tune(station) while stream_uris: uri = stream_uris.pop(0) logger.debug('Looking up URI: %s.' % uri) try: # TODO: Somehow update metadata using station. return self._scanner.scan(uri).uri except exceptions.ScannerError as se: logger.debug('Mopidy scan failed: %s.' % se) new_uris = self.backend.tunein.parse_stream_url(uri) if new_uris == [uri]: logger.debug( 'Last attempt, play stream anyway: %s.' % uri) return uri stream_uris.extend(new_uris) logger.debug('TuneIn lookup failed.') return None
def translate_uri(self, uri): variant, identifier = translator.parse_uri(uri) station = self.backend.tunein.station(identifier) if not station: return None uris = self.backend.tunein.tune(station) while uris: uri = uris.pop(0) logger.debug('Looking up URI: %s.' % uri) try: # TODO: Somehow update metadata using station. return self._scanner.scan(uri).uri except exceptions.ScannerError as se: try: logger.debug('Mopidy scan failed: %s.' % se) next_uris = self.backend.tunein.parse_stream_url(uri) if next_uris == uri and len(uris) == 0: logger.debug('Attempt to play stream anyway %s.' % uri) return uri uris.extend(next_uris) except tunein.PlaylistError as pe: break logger.debug('TuneIn lookup failed: %s.' % pe) return None