def _handlesearchview(self, data): manager = PyMusicManager.get_instance() res = writehtmlheader() + writehtmlhead( 'Search results') + '<h2>Search results</h2>' res += writetableheader(['Title', 'Artist', 'Name']) ss = manager.searchsong(data) for s in ss: res += writetablerow([ s.title, s.artist, '<a href=\"/getsong?id=%d\">%s</a>' % (s.oid, s.name) ]) res += writetableheader(['Name']) ss = manager.searchfolder(data) for s in ss: res += writetablerow( ['<a href=\"?type=folder&id=%d\">%s</a>' % (s.oid, s.name)]) res += writetableheader(['Name']) ss = manager.searchplaylist(data) for s in ss: res += writetablerow( ['<a href=\"?type=playlist&name=%s\">%s</a>' % (s, s)]) res += writetableend() + writehtmlend() self._response = res
def _handleFolderView(self, folderid, public=False): manager = PyMusicManager.get_instance() folder = manager.getfolder(folderid) res = writehtmlheader() + writehtmlhead('Folder View') if not public: res += writehostnamefolderfunction(folderid) res += writehostnamefolderfunction(folderid, True) res += '<h2>Folder: ' + (str(folder.name) if folder.parentId != 0 else 'Root') + '</h2>' if folder is not None: (s, f) = manager.listfolder(folderid) # Write folders if not public: res += writetableheader(['Name']) # Switch to parent if folder.parentId != 0: res += (writetablerow([ '<a href=\"?type=folder&id=%d\">..</a>' % (folder.parentId) ])) if f != []: for fid in f: res += (writetablerow([ '<a href=\"?type=folder&id=%d\">%s</a>' % (fid.oid, fid.name) ])) res += (writetableend()) # Write songs if s != []: # res += u'<h3>Songs</h3>' res += writetableheader(['Title', 'Artist', 'Name']) for song in s: res += (writetablerow([ song.title, song.artist, '<a href=\"/getsong?id=%d\">%s</a>' % (song.oid, song.name) ])) res += (writetableend()) if not public: res += writePublicUrlFunction(folder.getPublicUrl()) res += '<a href="javascript:void(0)" onClick="moveToPublic();">Public link</a><br>' if not public: res += '<a href="javascript:void(0)" onClick="getFol();">Get m3u file</a><br>' res += '<a href="javascript:void(0)" onClick="getFolR();">Get m3u file for all songs!</a>' res += writehtmlend() self._response = res
def _handlePlaylistView(self, playlistName): """ Shows a playlist """ manager = PyMusicManager.get_instance() playlist = manager.getPlaylists().get(playlistName) res = writehtmlheader() if playlist is None: res += writehtmlhead( 'Playlist not found' ) + '<h3>Playlist not found</h3>' + writehtmlend() else: res += writehtmlhead('Playlist view') res += writehostnameplaylistfunction(playlistName) res += '<h2>' + playlist.name + '</h2>' + writetableheader(['P']) for sid in playlist.songs: song = manager.getsong(sid) if song is not None: res += (writetablerow([ '<a href=\"/getsong?id=%d\">%s</a>' % (song.oid, song.name) ])) res += (writetableend()) res += '<a href="javascript:void(0)" onClick="getPl();">Get m3u file</a>' res += writehtmlend() self._response = res
def _handlePlaylistsView(self): """ Shows playlists """ manager = PyMusicManager.get_instance() res = writehtmlheader() + writehtmlhead( 'Playlists') + '<h2>Playlists</h2>' + writetableheader( ['Playlist']) for n in manager.listplaylists(): res += writetablerow( ['<a href=\"?type=playlist&name=%s\">%s</a>' % (n, n)]) res += writetableend() res += writehtmlend() self._response = res
def _handleSongsView(self): manager = PyMusicManager.get_instance() songs = manager.listsongsorderedbyname() res = writehtmlheader() + writehtmlhead( 'Song View') + '<h2>Songs</h2>' + writetableheader( ['Title', 'Artist', 'Name']) for sid in songs: res += (writetablerow([ sid.title, sid.artist, '<a href=\"/getsong?id=%d\">%s</a>' % (sid.oid, sid.name) ])) res += (writetableend()) res += writehtmlend() self._response = res