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 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 search_finished(results, userdata): Log("Search completed: %s" % params) result = ObjectContainer(title2 = "Results") for artist in results.artists() if artists else (): self.add_artist_to_directory(artist, result) for album in results.albums() if albums else (): self.add_album_to_directory(album, result) if not len(result): if len(results.did_you_mean()): message = localized_format( "MSG_FMT_DID_YOU_MEAN", results.did_you_mean()) else: message = localized_format("MSG_FMT_NO_RESULTS", query) result = MessageContainer( header = L("MSG_TITLE_NO_RESULTS"), message = message) completion(result)
def search_finished(results, userdata): Log("Search completed: %s" % params) result = ObjectContainer(title2="Results") for artist in results.artists() if artists else (): self.add_artist_to_directory(artist, result) for album in results.albums() if albums else (): self.add_album_to_directory(album, result) if not len(result): if len(results.did_you_mean()): message = localized_format("MSG_FMT_DID_YOU_MEAN", results.did_you_mean()) else: message = localized_format("MSG_FMT_NO_RESULTS", query) result = MessageContainer(header=L("MSG_TITLE_NO_RESULTS"), message=message) completion(result)
def run(self, query, type='all', limit=7, plain=False): query = urllib.unquote(query) limit = int(limit) Log('Search query: "%s", type: %s, limit: %s, plain: %s' % (query, type, limit, plain)) result = self.client.search(query, type, max_results=limit) oc = ObjectContainer( title2=self.get_title(type), content=self.get_content(type) ) 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, '') media_append('Artists', self.add_artist, 'artists') media_append('Albums', self.add_album, 'albums') media_append('Tracks', self.add_track, 'tracks') media_append('Playlists', self.add_playlist, 'playlists') if not len(oc): oc = MessageContainer( header=L("MSG_TITLE_NO_RESULTS"), message=localized_format("MSG_FMT_NO_RESULTS", query) ) return oc
def artist_related(self, uri): Log("artist_related") artist = self.client.get(uri) oc = ObjectContainer( title2=localized_format("MSG_RELATED_TO", artist.getName().decode("utf-8")), content=ContainerContent.Artists ) for artist in artist.getRelatedArtists(): self.add_artist_to_directory(artist, oc) return oc
def artist_related(self, uri): Log("artist_related") artist = self.client.get(uri) oc = ObjectContainer(title2=localized_format( "MSG_RELATED_TO", artist.getName().decode("utf-8")), content=ContainerContent.Artists) for artist in artist.getRelatedArtists(): self.add_artist_to_directory(artist, oc) return oc
def run(self, query, type='all', limit=7, plain=False): query = urllib.unquote(query) limit = int(limit) Log('Search query: "%s", type: %s, limit: %s, plain: %s' % (query, type, limit, plain)) result = self.client.search(query, type, max_results=limit) oc = ObjectContainer(title2=self.get_title(type), content=self.get_content(type)) 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, '') media_append('Artists', self.add_artist, 'artists') media_append('Albums', self.add_album, 'albums') media_append('Tracks', self.add_track, 'tracks') media_append('Playlists', self.add_playlist, 'playlists') if not len(oc): oc = MessageContainer(header=L("MSG_TITLE_NO_RESULTS"), message=localized_format( "MSG_FMT_NO_RESULTS", query)) return oc
def artist_top_tracks(self, uri): Log("artist_top_tracks") oc = None artist = self.client.get(uri) top_tracks = artist.getTracks() if top_tracks: oc = ObjectContainer(title2=artist.getName().decode("utf-8"), content=ContainerContent.Tracks, view_group=ViewMode.Tracks) for track in artist.getTracks(): self.add_track_to_directory(track, oc) else: oc = MessageContainer(header=L("MSG_TITLE_NO_RESULTS"), message=localized_format( "MSG_FMT_NO_RESULTS", artist.getName().decode("utf-8"))) return oc
def artist_top_tracks(self, uri): Log("artist_top_tracks") oc = None artist = self.client.get(uri) top_tracks = artist.getTracks() if top_tracks: oc = ObjectContainer( title2=artist.getName().decode("utf-8"), content=ContainerContent.Tracks, view_group=ViewMode.Tracks ) for track in artist.getTracks(): self.add_track_to_directory(track, oc) else: oc = MessageContainer( header=L("MSG_TITLE_NO_RESULTS"), message=localized_format("MSG_FMT_NO_RESULTS", artist.getName().decode("utf-8")) ) return oc