def create_track(track): uri = track.uri rating_key = uri return TrackObject( items=[ MediaObject( parts=[PartObject(key=route_path('play/%s' % uri))], duration=int(track.length), container=Container.MP3, audio_codec=AudioCodec.MP3, audio_channels = 2 ) ], key = route_path('metadata', uri), rating_key = rating_key, title = track.title, album = track.album.name, #artist = metadata.artists, # TODO index = int(track.number), duration = int(track.length), source_title='Spotify', art=function_path('image.png', uri=track.album.cover_large), thumb=function_path('image.png', uri=track.album.cover_large) )
def create_artist(artist): image_url = artist.portrait.large if artist.portrait else None title = artist.name.decode("utf-8") return DirectoryObject(key=route_path('artist', artist.uri.decode("utf-8")), title=title, art=function_path('image.png', uri=image_url), thumb=function_path('image.png', uri=image_url))
def create_album(album): image_url = album.cover_large title = album.name.decode("utf-8") return DirectoryObject(key=route_path('album', album.uri.decode("utf-8")), title=title, art=function_path('image.png', uri=image_url), thumb=function_path('image.png', uri=image_url))
def create_album(album): image_url = album.cover_large title = album.name.decode("utf-8") return DirectoryObject( key=route_path('album', album.uri.decode("utf-8")), title=title, art=function_path('image.png', uri=image_url), thumb=function_path('image.png', uri=image_url) )
def create_artist(artist): image_url = artist.portrait.large if artist.portrait else None title = artist.name.decode("utf-8") return DirectoryObject( key=route_path('artist', artist.uri.decode("utf-8")), title=title, art=function_path('image.png', uri=image_url), thumb=function_path('image.png', uri=image_url) )
def create_genre_object(self, genre): uri = genre.getTemplateName() title = genre.getName().decode("utf-8") image_url = genre.getIconUrl() return DirectoryObject( key=route_path('genre', uri), title=title, art=function_path('image.png', uri=image_url) if image_url != None else R("placeholder-playlist.png"), thumb=function_path('image.png', uri=image_url) if image_url != None else R("placeholder-playlist.png"))
def create_genre_object(self, genre): uri = genre.getTemplateName() title = genre.getName().decode("utf-8") image_url = genre.getIconUrl() return DirectoryObject( key=route_path('genre', uri), title=title, art=function_path('image.png', uri=image_url) if image_url != None else R("placeholder-playlist.png"), thumb=function_path('image.png', uri=image_url) if image_url != None else R("placeholder-playlist.png") )
def create_artist_object(self, artist, custom_summary=None, custom_image_url=None): image_url = self.select_image(artist.getPortraits()) if custom_image_url == None else custom_image_url artist_name = artist.getName().decode("utf-8") summary = '' if custom_summary == None else custom_summary.decode('utf-8') return DirectoryObject( key=route_path('artist', artist.getURI()), title=artist_name, summary=summary, art=function_path('image.png', uri=image_url), thumb=function_path('image.png', uri=image_url) )
def create_artist_object(self, artist, custom_summary=None, custom_image_url=None): image_url = self.select_image(artist.getPortraits( )) if custom_image_url == None else custom_image_url artist_name = artist.getName().decode("utf-8") summary = '' if custom_summary == None else custom_summary.decode( 'utf-8') return DirectoryObject(key=route_path('artist', artist.getURI()), title=artist_name, summary=summary, art=function_path('image.png', uri=image_url), thumb=function_path('image.png', uri=image_url))
def create_track_object(self, uri, duration, title, album, artists, track_number, image_url, index=None): rating_key = uri if index is not None: rating_key = '%s::%s' % (uri, index) art_num = str(randint(1,40)).rjust(2, "0") track_obj = TrackObject( items=[ MediaObject( parts=[PartObject(key=route_path('play/%s' % uri))], duration=duration, container=Container.MP3, audio_codec=AudioCodec.MP3, audio_channels = 2 ) ], key = route_path('metadata', uri), rating_key = rating_key, title = title, album = album, artist = artists, index = index if index != None else track_number, duration = duration, source_title='Spotify', art = R('art-' + art_num + '.png'), thumb = function_path('image.png', uri=image_url) ) Log.Debug('New track object for metadata: --|%s|%s|%s|%s|%s|%s|--' % (image_url, uri, str(duration), str(track_number), album, artists)) return track_obj
def image(covers): if covers and covers[-1]: # TODO might want to sort by 'size' (to ensure this is correct in all cases) # Pick largest cover return function_path('image.png', uri=covers[-1].file_url) Log.Info('Unable to select image, available covers: %s' % covers) return None
def create_playlist_object(self, playlist): uri = playlist.getURI() image_url = self.select_image(playlist.getImages()) artist = playlist.getUsername().decode('utf8') title = playlist.getName().decode("utf-8") summary = '' if playlist.getDescription() != None and len( playlist.getDescription()) > 0: summary = playlist.getDescription().decode("utf-8") return DirectoryObject( key=route_path('playlist', uri), title=title + " - " + artist, tagline=artist, summary=summary, art=function_path('image.png', uri=image_url) if image_url != None else R("placeholder-playlist.png"), thumb=function_path('image.png', uri=image_url) if image_url != None else R("placeholder-playlist.png"))
def create_playlist_object(self, playlist): uri = playlist.getURI() image_url = self.select_image(playlist.getImages()) artist = playlist.getUsername().decode('utf8') title = playlist.getName().decode("utf-8") summary = '' if playlist.getDescription() != None and len(playlist.getDescription()) > 0: summary = playlist.getDescription().decode("utf-8") return DirectoryObject( key=route_path('playlist', uri), title=title + " - " + artist, tagline=artist, summary=summary, art=function_path('image.png', uri=image_url) if image_url != None else R("placeholder-playlist.png"), thumb=function_path('image.png', uri=image_url) if image_url != None else R("placeholder-playlist.png") )
def create_album_object(self, album, custom_summary=None, custom_image_url=None): """ Factory method for album objects """ title = album.getName().decode("utf-8") if Prefs["displayAlbumYear"] and album.getYear() != 0: title = "%s (%s)" % (title, album.getYear()) artist_name = album.getArtists(nameOnly=True).decode("utf-8") summary = '' if custom_summary == None else custom_summary.decode('utf-8') image_url = self.select_image(album.getCovers()) if custom_image_url == None else custom_image_url return DirectoryObject( key=route_path('album', album.getURI()), title=title + " - " + artist_name, tagline=artist_name, summary=summary, art=function_path('image.png', uri=image_url), thumb=function_path('image.png', uri=image_url), )
def radio_stations(self): Log('radio stations') Dict['radio_salt'] = False oc = ObjectContainer(title2=L("MENU_RADIO_STATIONS")) stations = self.client.get_radio_stations() for station in stations: oc.add(PopupDirectoryObject( key=route_path('radio/stations/' + station.getURI()), title=station.getTitle(), thumb=function_path('image.png', uri=self.select_image(station.getImages())) )) return oc
def create_album_object(self, album, custom_summary=None, custom_image_url=None): """ Factory method for album objects """ title = album.getName().decode("utf-8") if Prefs["displayAlbumYear"] and album.getYear() != 0: title = "%s (%s)" % (title, album.getYear()) artist_name = album.getArtists(nameOnly=True).decode("utf-8") summary = '' if custom_summary == None else custom_summary.decode( 'utf-8') image_url = self.select_image(album.getCovers( )) if custom_image_url == None else custom_image_url return DirectoryObject( key=route_path('album', album.getURI()), title=title + " - " + artist_name, tagline=artist_name, summary=summary, art=function_path('image.png', uri=image_url), thumb=function_path('image.png', uri=image_url), )
def radio_genres(self): Log('radio genres') Dict['radio_salt'] = False oc = ObjectContainer(title2=L("MENU_RADIO_GENRES")) genres = self.client.get_radio_genres() for genre in genres: oc.add(PopupDirectoryObject( key=route_path('radio/genres/' + genre.getURI()), title=genre.getTitle(), thumb=function_path('image.png', uri=self.select_image(genre.getImages())) )) return oc
def create_track(track): uri = track.uri rating_key = uri return TrackObject( items=[ MediaObject( parts=[PartObject(key=route_path('play/%s' % uri))], duration=int(track.length), container=Container.MP3, audio_codec=AudioCodec.MP3, audio_channels=2) ], key=route_path('metadata', uri), rating_key=rating_key, title=track.title, album=track.album.name, #artist = metadata.artists, # TODO index=int(track.number), duration=int(track.length), source_title='Spotify', art=function_path('image.png', uri=track.album.cover_large), thumb=function_path('image.png', uri=track.album.cover_large))
def radio_genres(self): Log('radio genres') Dict['radio_salt'] = False oc = ObjectContainer(title2=L("MENU_RADIO_GENRES")) genres = self.client.get_radio_genres() for genre in genres: oc.add( PopupDirectoryObject( key=route_path('radio/genres/' + genre.getURI()), title=genre.getTitle(), thumb=function_path('image.png', uri=self.select_image( genre.getImages())))) return oc
def radio_stations(self): Log('radio stations') Dict['radio_salt'] = False oc = ObjectContainer(title2=L("MENU_RADIO_STATIONS")) stations = self.client.get_radio_stations() for station in stations: oc.add( PopupDirectoryObject( key=route_path('radio/stations/' + station.getURI()), title=station.getTitle(), thumb=function_path('image.png', uri=self.select_image( station.getImages())))) return oc
def create_track_object(self, uri, duration, title, album, artists, track_number, image_url, index=None): rating_key = uri if index is not None: rating_key = '%s::%s' % (uri, index) art_num = str(randint(1, 40)).rjust(2, "0") track_obj = TrackObject(items=[ MediaObject(parts=[PartObject(key=route_path('play/%s' % uri))], duration=duration, container=Container.MP3, audio_codec=AudioCodec.MP3, audio_channels=2) ], key=route_path('metadata', uri), rating_key=rating_key, title=title, album=album, artist=artists, index=index if index != None else track_number, duration=duration, source_title='Spotify', art=R('art-' + art_num + '.png'), thumb=function_path('image.png', uri=image_url)) Log.Debug( 'New track object for metadata: --|%s|%s|%s|%s|%s|%s|--' % (image_url, uri, str(duration), str(track_number), album, artists)) return track_obj
def track_url(self, track): if self.host.proxy_tracks and self.server: return self.server.get_track_url(str(track.uri), hostname=self.host.hostname) return function_path('play', uri=str(track.uri), ext='mp3')