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 radio_track_num(self, uri): Log('radio track num') uri = urllib.quote(uri.encode("utf8")).replace("%3A", ":").decode("utf8") return ObjectContainer( title2=L("MENU_RADIO_TRACK_NUM"), objects=[ DirectoryObject(key=route_path('radio/play/' + uri + '/10'), title=localized_format("MENU_TRACK_NUM", "10"), thumb=R("icon-radio-item.png")), DirectoryObject(key=route_path('radio/play/' + uri + '/20'), title=localized_format("MENU_TRACK_NUM", "20"), thumb=R("icon-radio-item.png")), DirectoryObject(key=route_path('radio/play/' + uri + '/50'), title=localized_format("MENU_TRACK_NUM", "50"), thumb=R("icon-radio-item.png")), DirectoryObject(key=route_path('radio/play/' + uri + '/80'), title=localized_format("MENU_TRACK_NUM", "80"), thumb=R("icon-radio-item.png")), DirectoryObject(key=route_path('radio/play/' + uri + '/100'), title=localized_format("MENU_TRACK_NUM", "100"), thumb=R("icon-radio-item.png")) ], )
def your_music(self): """ Explore your music""" return ObjectContainer( title2=L('YOUR_MUSIC'), objects=[ DirectoryObject( key=route_path('your_music/playlists'), title=L('PLAYLISTS'), thumb=R('icon-playlists.png') ), DirectoryObject( key=route_path('your_music/starred'), title=L('STARRED'), thumb=R('icon-starred.png') ), DirectoryObject( key=route_path('your_music/albums'), title=L('ALBUMS'), thumb=R('icon-albums.png') ), DirectoryObject( key=route_path('your_music/artists'), title=L('ARTISTS'), thumb=R('icon-artists.png') ), ], )
def album(self, uri): Log("album") uri = urllib.quote(uri.encode("utf8")).replace("%3A", ":").decode("utf8") album = self.client.get(uri) oc = ObjectContainer( title2=album.getName().decode("utf-8"), content=ContainerContent.Artists ) oc.add(DirectoryObject( key = route_path('album/%s/tracks' % uri), title=L("MENU_ALBUM_TRACKS"), thumb=R("icon-album-tracks.png"))) artists = album.getArtists() for artist in artists: self.add_artist_to_directory(artist, oc) oc.add(DirectoryObject( key=route_path('radio/stations/' + uri), title =L("MENU_RADIO"), thumb =R("icon-radio-custom.png"))) return oc
def album(self, uri): Log("album") uri = urllib.quote(uri.encode("utf8")).replace("%3A", ":").decode("utf8") album = self.client.get(uri) oc = ObjectContainer(title2=album.getName().decode("utf-8"), content=ContainerContent.Artists) oc.add( DirectoryObject(key=route_path('album/%s/tracks' % uri), title=L("MENU_ALBUM_TRACKS"), thumb=R("icon-album-tracks.png"))) artists = album.getArtists() for artist in artists: self.add_artist_to_directory(artist, oc) oc.add( DirectoryObject(key=route_path('radio/stations/' + uri), title=L("MENU_RADIO"), thumb=R("icon-radio-custom.png"))) 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 artist(self, uri): Log("artist") uri = urllib.quote(uri.encode("utf8")).replace("%3A", ":").decode("utf8") artist = self.client.get(uri) return ObjectContainer( title2=artist.getName().decode("utf-8"), objects=[ DirectoryObject( key = route_path('artist/%s/top_tracks' % uri), title=L("MENU_TOP_TRACKS"), thumb=R("icon-artist-toptracks.png") ), DirectoryObject( key = route_path('artist/%s/albums' % uri), title =L("MENU_ALBUMS"), thumb =R("icon-albums.png") ), DirectoryObject( key = route_path('artist/%s/related' % uri), title =L("MENU_RELATED"), thumb =R("icon-artist-related.png") ), DirectoryObject( key=route_path('radio/stations/' + uri), title =L("MENU_RADIO"), thumb =R("icon-radio-custom.png") ) ], )
def radio_track_num(self, uri): Log('radio track num') uri = urllib.quote(uri.encode("utf8")).replace("%3A", ":").decode("utf8") return ObjectContainer( title2=L("MENU_RADIO_TRACK_NUM"), objects=[ DirectoryObject( key=route_path('radio/play/' + uri + '/10'), title=localized_format("MENU_TRACK_NUM", "10"), thumb=R("icon-radio-item.png") ), DirectoryObject( key=route_path('radio/play/' + uri + '/20'), title=localized_format("MENU_TRACK_NUM", "20"), thumb=R("icon-radio-item.png") ), DirectoryObject( key=route_path('radio/play/' + uri + '/50'), title=localized_format("MENU_TRACK_NUM", "50"), thumb=R("icon-radio-item.png") ), DirectoryObject( key=route_path('radio/play/' + uri + '/80'), title=localized_format("MENU_TRACK_NUM", "80"), thumb=R("icon-radio-item.png") ), DirectoryObject( key=route_path('radio/play/' + uri + '/100'), title=localized_format("MENU_TRACK_NUM", "100"), thumb=R("icon-radio-item.png") ) ], )
def your_music(self): Log("your_music") """ Explore your music """ return ObjectContainer( objects=[ DirectoryObject( key=route_path('your_music/playlists'), title=L("MENU_PLAYLISTS"), thumb=R("icon-playlists.png") ), DirectoryObject( key=route_path('your_music/starred'), title=L("MENU_STARRED"), thumb=R("icon-starred.png") ), DirectoryObject( key=route_path('your_music/albums'), title=L("MENU_ALBUMS"), thumb=R("icon-albums.png") ), DirectoryObject( key=route_path('your_music/artists'), title=L("MENU_ARTISTS"), thumb=R("icon-artists.png") ), ], )
def explore(self): Log("explore") """ Explore shared music """ return ObjectContainer( objects=[ DirectoryObject( key=route_path('explore/featured_playlists'), title=L("MENU_FEATURED_PLAYLISTS"), thumb=R("icon-explore-featuredplaylists.png") ), DirectoryObject( key=route_path('explore/top_playlists'), title=L("MENU_TOP_PLAYLISTS"), thumb=R("icon-explore-topplaylists.png") ), DirectoryObject( key=route_path('explore/new_releases'), title=L("MENU_NEW_RELEASES"), thumb=R("icon-explore-newreleases.png") ), DirectoryObject( key=route_path('explore/genres'), title=L("MENU_GENRES"), thumb=R("icon-explore-genres.png") ) ], )
def main_menu(self): objects = [] level, message = self.last_message() if level: objects.append(DirectoryObject( key=route_path('messages'), title='%s: %s' % (logging.getLevelName(level), message), thumb=R('icon-message-%s.png' % ( 'error' if level == logging.ERROR else 'warning' )) )) objects.extend([ InputDirectoryObject( key=route_path('search'), prompt=L('PROMPT_SEARCH'), title=L('SEARCH'), thumb=R('icon-search.png') ), DirectoryObject( key=route_path('explore'), title=L('EXPLORE'), thumb=R('icon-explore.png') ), #DirectoryObject( # key=route_path('discover'), # title=L("DISCOVER"), # thumb=R("icon-default.png") #), #DirectoryObject( # key=route_path('radio'), # title=L("RADIO"), # thumb=R("icon-default.png") #), DirectoryObject( key=route_path('your_music'), title=L('YOUR_MUSIC'), thumb=R('icon-your_music.png') ), DirectoryObject( key=route_path('about'), title=L('ABOUT'), thumb=R('icon-about.png') ), PrefsObject( title=L('PREFERENCES'), thumb=R('icon-preferences.png') ) ]) return ObjectContainer( objects=objects, no_cache=True )
def radio(self): Log("radio") """ Show radio options """ return ObjectContainer(objects=[ DirectoryObject(key=route_path('radio/stations'), title=L("MENU_RADIO_STATIONS"), thumb=R("icon-radio-stations.png")), DirectoryObject(key=route_path('radio/genres'), title=L("MENU_RADIO_GENRES"), thumb=R("icon-radio-genres.png")) ], )
def album(self, album): title = normalize(album.name) # TODO album years #if Prefs["displayAlbumYear"] and album.getYear() != 0: # title = "%s (%s)" % (title, album.getYear()) cover_url = self.image(album.covers) track_count = None if album.discs: track_count = len(album.discs[0].tracks) return DirectoryObject( key=route_path('album', album.uri), #rating_key=album.uri, title=title, tagline=', '.join([normalize(ar.name) for ar in album.artists]), #track_count=track_count, art=cover_url, thumb=cover_url, )
def track(self, track, index=None): rating_key = track.uri if index is not None: rating_key = '%s::%s' % (track.uri, index) cover_url = self.image(track.album.covers) return TrackObject( items=[ MediaObject( parts=[PartObject( key=self.client.track_url(track), duration=int(track.duration) )], duration=int(track.duration), container=Container.MP3, audio_codec=AudioCodec.MP3 ) ], key=route_path('metadata', str(track.uri)), rating_key=quote(rating_key), title=normalize(track.name), album=normalize(track.album.name), artist=', '.join([normalize(ar.name) for ar in track.artists]), index=int(track.number), duration=int(track.duration), art=cover_url, thumb=cover_url )
def media_append(title, func, type, key=None): if key is None: key = title items = list(getattr(result, 'get%s' % key)()) total = getattr(result, 'get%sTotal' % key)() if not items or not len(items): return if not plain: self.add_header( oc, '%s (%s)' % ( title, locale.format('%d', total, grouping=True) ), route_path('search', query=query, type=type, limit=50, plain=True) ) for x in range(limit): if x < len(items): func(oc, items[x]) elif not plain and self.use_placeholders(): # Add a placeholder to fix alignment on PHT self.add_header(oc, '')
def media_append(title, func, type, key=None): if key is None: key = title items = list(getattr(result, 'get%s' % key)()) total = getattr(result, 'get%sTotal' % key)() if not items or not len(items): return if not plain: self.add_header( oc, '%s (%s)' % (title, locale.format('%d', total, grouping=True)), route_path('search', query=query, type=type, limit=50, plain=True)) for x in range(limit): if x < len(items): func(oc, items[x]) elif not plain and self.use_placeholders(): # Add a placeholder to fix alignment on PHT self.add_header(oc, '')
def add_playlist(oc, playlist): oc.add( DirectoryObject( key=route_path('playlist', playlist.uri), title=playlist.name.decode("utf-8"), thumb=playlist.image ) )
def radio(self): Log("radio") """ Show radio options """ return ObjectContainer( objects=[ DirectoryObject( key=route_path('radio/stations'), title=L("MENU_RADIO_STATIONS"), thumb=R("icon-radio-stations.png") ), DirectoryObject( key=route_path('radio/genres'), title=L("MENU_RADIO_GENRES"), thumb=R("icon-radio-genres.png") ) ], )
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 explore(self): Log("explore") """ Explore shared music """ return ObjectContainer(objects=[ DirectoryObject(key=route_path('explore/featured_playlists'), title=L("MENU_FEATURED_PLAYLISTS"), thumb=R("icon-explore-featuredplaylists.png")), DirectoryObject(key=route_path('explore/top_playlists'), title=L("MENU_TOP_PLAYLISTS"), thumb=R("icon-explore-topplaylists.png")), DirectoryObject(key=route_path('explore/new_releases'), title=L("MENU_NEW_RELEASES"), thumb=R("icon-explore-newreleases.png")), DirectoryObject(key=route_path('explore/genres'), title=L("MENU_GENRES"), thumb=R("icon-explore-genres.png")) ], )
def your_music(self): Log("your_music") """ Explore your music """ return ObjectContainer(objects=[ DirectoryObject(key=route_path('your_music/playlists'), title=L("MENU_PLAYLISTS"), thumb=R("icon-playlists.png")), DirectoryObject(key=route_path('your_music/starred'), title=L("MENU_STARRED"), thumb=R("icon-starred.png")), DirectoryObject(key=route_path('your_music/albums'), title=L("MENU_ALBUMS"), thumb=R("icon-albums.png")), DirectoryObject(key=route_path('your_music/artists'), title=L("MENU_ARTISTS"), thumb=R("icon-artists.png")), ], )
def build(): # Check if we are ready to build the response yet if len(albums) != len(album_uris[:self.columns]): return if len(tracks) != len(track_uris[:self.columns]): return # Top Tracks self.append_header(oc, '%s (%s)' % (L('TOP_TRACKS'), len(track_uris)), route_path('artist', artist.uri, 'top_tracks')) self.append_items(oc, tracks) # Albums self.append_header(oc, '%s (%s)' % (L('ALBUMS'), len(album_uris)), route_path('artist', artist.uri, 'albums')) self.append_items(oc, albums) callback(oc)
def artist(self, artist): cover_url = self.image(artist.portraits) return DirectoryObject( key=route_path('artist', artist.uri), #rating_key=artist.uri, title=normalize(artist.name), art=cover_url, thumb=cover_url or R('placeholder-artist.png') )
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 artist(self, uri): Log("artist") artist = self.client.get(uri) return ObjectContainer( title2=artist.getName().decode("utf-8"), objects=[ DirectoryObject(key=route_path('artist/%s/top_tracks' % uri), title=L("MENU_TOP_TRACKS"), thumb=R("icon-artist-toptracks.png")), DirectoryObject(key=route_path('artist/%s/albums' % uri), title=L("MENU_ALBUMS"), thumb=R("icon-albums.png")), DirectoryObject(key=route_path('artist/%s/related' % uri), title=L("MENU_RELATED"), thumb=R("icon-artist-related.png")), DirectoryObject(key=route_path('radio/stations/' + uri), title=L("MENU_RADIO"), thumb=R("icon-radio-custom.png")) ], )
def playlist(cls, item): if item.uri and item.uri.type == 'group': # (Playlist Folder) return DirectoryObject( key=route_path('your_music/playlists', group=item.uri, title=normalize(item.name)), title=normalize(item.name), thumb=R("placeholder-playlist.png") ) cover_url = None if item.image and item.image.file_uri: # Ensure we don't use invalid image uris if len(item.image.file_uri.code) == 27: cover_url = cls.image([item.image]) return DirectoryObject( key=route_path('playlist', item.uri), title=normalize(item.name), thumb=cover_url or 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 get_header(cls, total, query, type): key = route_path('search', query=query, type=type, count=50, plain=True) title = '%s (%s)' % ( cls.get_title(type, True), locale.format('%d', total, grouping=True).replace('\xa0', ' ') ) return DirectoryObject( key=key, title=title, thumb=cls.get_thumb(type) )
def messages(self): oc = ObjectContainer( title2=L('MESSAGES'), no_cache=True ) for level, message in self.all_messages: oc.add(DirectoryObject( key=route_path('messages'), title='[%s] %s' % (logging.getLevelName(level), message) )) return oc
def main_menu(self): Log("main_menu") return ObjectContainer(objects=[ InputDirectoryObject(key=route_path('search'), prompt=L("PROMPT_SEARCH"), title=L("MENU_SEARCH"), thumb=R("icon-search.png")), DirectoryObject(key=route_path('explore'), title=L("MENU_EXPLORE"), thumb=R("icon-explore.png")), DirectoryObject(key=route_path('discover'), title=L("MENU_DISCOVER"), thumb=R("icon-discover.png")), DirectoryObject(key=route_path('radio'), title=L("MENU_RADIO"), thumb=R("icon-radio.png")), DirectoryObject(key=route_path('your_music'), title=L("MENU_YOUR_MUSIC"), thumb=R("icon-yourmusic.png")), PrefsObject(title=L("MENU_PREFS"), thumb=R("icon-preferences.png")) ], )
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 about(self): return ObjectContainer( objects=[ DirectoryObject( key='', title=LF('VERSION', VERSION) ), DirectoryObject( key=route_path('about/credits'), title=L('CREDITS') ) ] )
def explore(self): """ Explore shared music""" return ObjectContainer( title2=L('EXPLORE'), objects=[ DirectoryObject( key=route_path('explore/featured_playlists'), title=L('FEATURED_PLAYLISTS'), thumb=R("icon-featured_playlists.png") ), DirectoryObject( key=route_path('explore/top_playlists'), title=L('TOP_PLAYLISTS'), thumb=R("icon-top_playlists.png") ), DirectoryObject( key=route_path('explore/new_releases'), title=L('NEW_RELEASES'), thumb=R("icon-new_releases.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 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_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 build(): # Check if we are ready to build the response yet if len(albums) != len(album_uris[:self.columns]): return if len(tracks) != len(track_uris[:self.columns]): return # Top Tracks self.append_header( oc, '%s (%s)' % (L('TOP_TRACKS'), len(track_uris)), route_path('artist', artist.uri, 'top_tracks') ) self.append_items(oc, tracks) # Albums self.append_header( oc, '%s (%s)' % (L('ALBUMS'), len(album_uris)), route_path('artist', artist.uri, 'albums') ) self.append_items(oc, albums) callback(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 main_menu(self): Log("main_menu") return ObjectContainer( objects=[ InputDirectoryObject( key=route_path('search'), prompt=L("PROMPT_SEARCH"), title=L("MENU_SEARCH"), thumb=R("icon-search.png") ), DirectoryObject( key=route_path('explore'), title=L("MENU_EXPLORE"), thumb=R("icon-explore.png") ), DirectoryObject( key=route_path('discover'), title=L("MENU_DISCOVER"), thumb=R("icon-discover.png") ), DirectoryObject( key=route_path('radio'), title=L("MENU_RADIO"), thumb=R("icon-radio.png") ), DirectoryObject( key=route_path('your_music'), title=L("MENU_YOUR_MUSIC"), thumb=R("icon-yourmusic.png") ), PrefsObject( title=L("MENU_PREFS"), thumb=R("icon-preferences.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 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_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 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 add_playlist(oc, playlist): oc.add( DirectoryObject(key=route_path('playlist', playlist.uri), title=playlist.name.decode("utf-8"), thumb=playlist.image))