Added image support
This commit is contained in:
@@ -4,7 +4,7 @@ import logging
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from mopidy import backend
|
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__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -72,6 +72,23 @@ class RadioNetLibraryProvider(backend.LibraryProvider):
|
|||||||
logger.debug("Unknown URI: %s", uri)
|
logger.debug("Unknown URI: %s", uri)
|
||||||
return []
|
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):
|
def _browse_root(self):
|
||||||
directories = [
|
directories = [
|
||||||
self.ref_directory("radionet:topstations", "Top stations"),
|
self.ref_directory("radionet:topstations", "Top stations"),
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ class Station(object):
|
|||||||
genres = None
|
genres = None
|
||||||
name = None
|
name = None
|
||||||
stream_url = None
|
stream_url = None
|
||||||
image = None
|
image_tiny = None
|
||||||
|
image_small = None
|
||||||
|
image_medium = None
|
||||||
|
image_large = None
|
||||||
description = None
|
description = None
|
||||||
playable = False
|
playable = False
|
||||||
|
|
||||||
@@ -155,7 +158,10 @@ class RadioNetClient(object):
|
|||||||
station.name = json["name"]
|
station.name = json["name"]
|
||||||
station.slug = json["subdomain"]
|
station.slug = json["subdomain"]
|
||||||
station.stream_url = self._get_stream_url(json["streamUrls"], self.min_bitrate)
|
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"]
|
station.description = json["shortDescription"]
|
||||||
if json["playable"] == "PLAYABLE":
|
if json["playable"] == "PLAYABLE":
|
||||||
station.playable = True
|
station.playable = True
|
||||||
@@ -205,7 +211,9 @@ class RadioNetClient(object):
|
|||||||
else:
|
else:
|
||||||
station.description = ""
|
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_id[station.id] = station
|
||||||
self.stations_by_slug[station.slug] = station
|
self.stations_by_slug[station.slug] = station
|
||||||
|
|||||||
Reference in New Issue
Block a user