Added image support

This commit is contained in:
Eric van Blokland
2021-09-09 20:27:41 +02:00
parent cb2c4f07b5
commit 424173da27
2 changed files with 29 additions and 4 deletions

View File

@@ -4,7 +4,7 @@ import logging
import re
from mopidy import backend
from mopidy.models import Album, Artist, Ref, SearchResult, Track
from mopidy.models import Album, Artist, Ref, SearchResult, Track, Image
logger = logging.getLogger(__name__)
@@ -72,6 +72,23 @@ class RadioNetLibraryProvider(backend.LibraryProvider):
logger.debug("Unknown URI: %s", uri)
return []
def get_images(self, uris):
images = {}
for uri in uris:
variant, identifier, sorting, page = self.parse_uri(uri)
station = self.backend.radionet.get_station_by_id(identifier)
if station:
images[uri] = []
if station.image_tiny:
images[uri].append(Image(uri=station.image_tiny, height=44, width=44))
if station.image_small:
images[uri].append(Image(uri=station.image_small, height=100, width=100))
if station.image_medium:
images[uri].append(Image(uri=station.image_medium, height=175, width=175))
if station.image_large:
images[uri].append(Image(uri=station.image_large, height=300, width=300))
return images
def _browse_root(self):
directories = [
self.ref_directory("radionet:topstations", "Top stations"),

View File

@@ -20,7 +20,10 @@ class Station(object):
genres = None
name = None
stream_url = None
image = None
image_tiny = None
image_small = None
image_medium = None
image_large = None
description = None
playable = False
@@ -155,7 +158,10 @@ class RadioNetClient(object):
station.name = json["name"]
station.slug = json["subdomain"]
station.stream_url = self._get_stream_url(json["streamUrls"], self.min_bitrate)
station.image = json["logo100x100"]
station.image_tiny = json["logo44x44"]
station.image_small = json["logo100x100"]
station.image_medium= json["logo175x175"]
station.image_large = json["logo300x300"]
station.description = json["shortDescription"]
if json["playable"] == "PLAYABLE":
station.playable = True
@@ -205,7 +211,9 @@ class RadioNetClient(object):
else:
station.description = ""
station.image = result["logo100x100"]
station.image_tiny = result["logo44x44"]
station.image_small = result["logo100x100"]
station.image_medium = result["logo175x175"]
self.stations_by_id[station.id] = station
self.stations_by_slug[station.slug] = station