def LibraryAlbum(libraryId, albumId): library = music.get_library(libraryId) album = music.get_album(albumId, library) if album.id[0:2] == "FB": return LibraryAlbumTracks(libraryId, albumId) oc = ObjectContainer(title2=album.name, content=ContainerContent.Mixed, art=url_or_default(album.thumb, R("album.png"))) oc.add( DirectoryObject( key=Callback(GetStation, libraryId=libraryId, type="album", objectId=album.id, name=Locale.LocalStringWithFormat( "library_album_station", album.name), art=url_or_default(album.art, R("album.png"))), title=Locale.LocalStringWithFormat("library_album_station", album.name), thumb=R("station.png"))) oc.add( DirectoryObject(key=Callback(LibraryAlbumTracks, libraryId=libraryId, albumId=album.id), title=Locale.LocalStringWithFormat( "library_album_tracks", album.name), thumb=url_or_default(album.thumb, R("album.png")))) return oc
def LibraryStation(libraryId, stationId, name, art): library = music.get_library(libraryId) oc = ObjectContainer(title2=name, content=ContainerContent.Tracks, view_group="track_list", art=url_or_default(art, R("station.png"))) for track in library.get_station_tracks(stationId, num_tracks=50): oc.add(track_object(library, track)) return oc
def LibrarySongs(libraryId): oc = ObjectContainer(title2=L("library_songs"), content=ContainerContent.Tracks, view_group="track_list", art=R("track.png")) library = music.get_library(libraryId) tracks = library.get_tracks() for track in tracks: oc.add(track_object(library, track)) return oc
def GenreTracks(libraryId, genreName): library = music.get_library(libraryId) genre = music.get_genre(genreName) oc = ObjectContainer(title2=genre.name, content=ContainerContent.Tracks, art=url_or_default(genre.thumb, R("genre.png"))) tracks = library.get_tracks_in_genre(genre) for track in tracks: oc.add(track_object(library, track)) return oc
def LibraryPlaylist(libraryId, playlistId): library = music.get_library(libraryId) playlist = library.get_playlist(playlistId) oc = ObjectContainer(title2=playlist.name, content=ContainerContent.Tracks, view_group="track_list", art=R("playlist.png")) for track in playlist.tracks: oc.add(track_object(library, track)) return oc
def LibraryAlbumTracks(libraryId, albumId): library = music.get_library(libraryId) album = music.get_album(albumId, library) oc = ObjectContainer(title2=album.name, content=ContainerContent.Tracks, view_group="track_list", art=url_or_default(album.thumb, R("album.png"))) for track in album.tracks: oc.add(track_object(library, track)) return oc
def LibraryGenres(libraryId): oc = ObjectContainer(title2=L("library_genres"), content=ContainerContent.Genres, art=R("genre.png")) library = music.get_library(libraryId) genres = library.get_genres() for genre in genres: oc.add( DirectoryObject(key=Callback(GenreTracks, libraryId=libraryId, genreName=genre.name), title=genre.name, thumb=url_or_default(genre.thumb, R("genre.png")))) return oc
def Situations(libraryId): library = music.get_library(0) oc = ObjectContainer(content=ContainerContent.Mixed, art=R("situations.png"), title2=L("situations")) situations = library.get_listen_situations() for situation in situations: oc.add( DirectoryObject(key=Callback( LibrarySituation, libraryId=library.id, situation=JSON.StringFromObject(situation)), title=situation["title"], thumb=situation["imageUrl"])) return oc
def LibraryPlaylists(libraryId): oc = ObjectContainer(title2=L("library_playlists"), content=ContainerContent.Playlists, view_group="album_list", art=R("playlist.png")) library = music.get_library(libraryId) playlists = library.get_playlists() for playlist in smart_sort(playlists): oc.add( PlaylistObject(key=Callback(LibraryPlaylist, libraryId=libraryId, playlistId=playlist.id), title=playlist.name, thumb=R("playlist.png"))) return oc
def LibraryAlbums(libraryId): oc = ObjectContainer(title2=L("library_albums"), content=ContainerContent.Playlists, view_group="album_list", art=R("album.png")) library = music.get_library(libraryId) albums = library.get_albums() for album in smart_sort(albums): oc.add( DirectoryObject(key=Callback(LibraryAlbum, libraryId=libraryId, albumId=album.id), title=album.name, thumb=url_or_default(album.thumb, R("album.png")))) return oc
def LibraryArtists(libraryId): oc = ObjectContainer(title2=L("library_artists"), content=ContainerContent.Artists, view_group="artist_list", art=R("artist.png")) library = music.get_library(libraryId) artists = library.get_artists() for artist in smart_sort(artists): oc.add( ArtistObject(key=Callback(LibraryArtist, libraryId=libraryId, artistId=artist.id), rating_key=artist.id, title=artist.name, thumb=url_or_default(artist.thumb, R("artist.png")))) return oc
def Main(): oc = ObjectContainer(content=ContainerContent.Mixed) library = music.get_library(0) if library is None: return oc oc.add( DirectoryObject(key=Callback(Library, libraryId=library.id), title=L("library"), thumb=R("library.png"))) oc.add( DirectoryObject(key=Callback(Situations, libraryId=library.id), title=L("situations"), thumb=R("situations.png"))) return oc
def LibraryArtistTracks(libraryId, artistId): library = music.get_library(libraryId) artist = music.get_artist(artistId, library) oc = ObjectContainer(title2=Locale.LocalStringWithFormat( "library_artist_tracks", artist.name), content=ContainerContent.Tracks, view_group="track_list", art=url_or_default(artist.thumb, R("artist.png"))) all_tracks = [] for album in artist.albums: for track in album.tracks: all_tracks.append(track) for track in smart_sort(all_tracks): oc.add(track_object(library, track)) return oc
def LibraryStations(libraryId): oc = ObjectContainer(title2=L("library_stations"), content=ContainerContent.Playlists, view_group="album_list", art=R("station.png")) library = music.get_library(libraryId) stations = library.get_stations() for station in smart_sort(stations): oc.add( PlaylistObject(key=Callback(LibraryStation, libraryId=libraryId, stationId=station.id, name=station.name, art=station.art), title=station.name, thumb=url_or_default(station.thumb, R("station.png")))) return oc
def LibraryArtistAlbums(libraryId, artistId): library = music.get_library(libraryId) artist = music.get_artist(artistId, library) oc = ObjectContainer(title2=Locale.LocalStringWithFormat( "library_artist_album", artist.name), content=ContainerContent.Albums, view_group="album_list", art=url_or_default(artist.thumb, R("artist.png"))) for album in smart_sort(artist.albums): oc.add( AlbumObject(key=Callback(LibraryAlbumTracks, libraryId=libraryId, albumId=album.id), rating_key=album.id, title=album.name, thumb=url_or_default(album.thumb, R("album.png")), artist=album.artist.name)) return oc
def LibraryArtist(libraryId, artistId): library = music.get_library(libraryId) artist = music.get_artist(artistId, library) oc = ObjectContainer(title2=artist.name, content=ContainerContent.Mixed, art=url_or_default(artist.thumb, R("artist.png"))) if artist.id[0:2] != "FA": oc.add( DirectoryObject(key=Callback(GetStation, libraryId=libraryId, type="artist", objectId=artist.id, name=Locale.LocalStringWithFormat( "library_artist_station", artist.name), art=artist.thumb), title=Locale.LocalStringWithFormat( "library_artist_station", artist.name), thumb=R("station.png"))) oc.add( DirectoryObject(key=Callback(LibraryArtistAlbums, libraryId=libraryId, artistId=artist.id), title=Locale.LocalStringWithFormat( "library_artist_album", artist.name), thumb=R("album.png"))) oc.add( DirectoryObject(key=Callback(LibraryArtistTracks, libraryId=libraryId, artistId=artist.id), title=Locale.LocalStringWithFormat( "library_artist_tracks", artist.name), thumb=R("track.png"))) return oc
def GetStation(libraryId, type, objectId, name, art): library = music.get_library(libraryId) kwargs = {} kwargs["%s_id" % type] = objectId stationId = library.get_station_id(name, **kwargs) return LibraryStation(libraryId, stationId, name, art)