def get(self): sq = Song.all().filter("owner =", users.get_current_user()) songs = sq.fetch(100) songs_json = format_json(songs) self._print('{"songs":[%s]}' % songs_json)
def get(self, authorName): authorName = re.sub('_', ' ', authorName) #sq = Song.gql("WHERE author = '%s' ORDER BY date ASC" % authorName) sq = Song.all().filter("author =", authorName).order("date") songs = sq.fetch(100) songsJson = '' id = 0 for song in songs: songsJson += '{"name":"%s", "author":1, "album":1, "uri":"%s",' % (song.name, song.uri) if song.author: author = song.author else: author = 'VA' if song.album: album = song.album else: album = 'VA' songsJson += '"authorName":"%s", "albumName":"%s"}' % (author, album) id += 1 if id != len(songs): songsJson += ',' self.response.out.write('{"songs":[%s]}' % songsJson)
def get(self): songsQuery = Song.all().order('-date') songs = songsQuery.fetch(100) songs_json = format_json(songs) self._print('{"songs":[%s]}' % songs_json)
def get(self): songsQuery = Song.all().order("-date") songs = songsQuery.fetch(100) artists = [] artistsHtml = "" for song in songs: if song.author and song.author not in artists: artists.append(song.author) arUrl = re.sub(" ", "_", song.author) artistsHtml += "<li>" artistsHtml += '<a href="#artists/' + arUrl + '" ' artistsHtml += " onClick=\"Player.load('/api/songs/author/" + arUrl + ".json');\">" artistsHtml += song.author artistsHtml += "</a>" artistsHtml += "</li>" if users.get_current_user(): url = users.create_logout_url(self.request.uri) url_linktext = "Logout" else: url = users.create_login_url(self.request.uri) url_linktext = "Login" template_values = { "user": users.get_current_user(), "url": url, "url_linktext": url_linktext, "artists": artistsHtml, } path = os.path.join(os.path.dirname(__file__), "../templates/restyled/index.html") self.response.out.write(template.render(path, template_values))
def get(self): sq = Song.all().filter("uri =", self.request.params["uri"]) songs = sq.fetch(1) if len(songs) == 0: self.response.out.write("no song") return else: song = songs[0] pq = Playlist.all().filter("owner =", users.get_current_user()) playlists = pq.fetch(1) if len(playlists) == 0: pl = Playlist() pl.owner = users.get_current_user() pl.name = "My" pl.status = True pl.put() else: pl = playlists[0] ps = PlaylistSong() ps.playlist = pl ps.song = song ps.put() self.response.out.write("done")
def get(self, authorName): authorName = re.sub('_', ' ', authorName) #sq = Song.gql("WHERE author = '%s' ORDER BY date ASC" % authorName) sq = Song.all().filter("author =", authorName).order("date") songs = sq.fetch(100) songs_json = format_json(songs) self._print('{"songs":[%s]}' % songs_json)
def get(self): sq = Song.all().filter("owner =", users.get_current_user()) songs = sq.fetch(100) songsJson = '' id = 0 for song in songs: songsJson += '{"name":"%s", "author":1, "album":1, "uri":"%s",' % (song.name, song.uri) if song.author: author = song.author else: author = 'VA' if song.album: album = song.album else: album = 'VA' songsJson += '"authorName":"%s", "albumName":"%s"}' % (author, album) id += 1 if id != len(songs): songsJson += ',' self.response.out.write('{"songs":[%s]}' % songsJson)
def get(self): sq = Song.all().filter("uri =", self.request.params['uri']) songs = sq.fetch(1) if len(songs) == 0: self.response.out.write('no song') return else: song = songs[0] pq = Playlist.all().filter("owner =", users.get_current_user()) playlists = pq.fetch(1) if len(playlists) == 0: self.response.out.write('no playlist') return else: pl = playlists[0] ps = PlaylistSong.all().filter("playlist =", pl) for lst in ps: if lst.song.uri == song.uri: db.delete(lst) self._print('done')
def get(self): songsQuery = Song.all().order('-date') songs = songsQuery.fetch(100) songsJson = '' id = 0 for song in songs: songsJson += '{"name":"%s", "author":1, "album":1, "uri":"%s",' % (song.name, song.uri) if song.author: author = song.author else: author = 'VA' if song.album: album = song.album else: album = 'VA' songsJson += '"authorName":"%s", "albumName":"%s"}' % (author, album) id += 1 if id != len(songs): songsJson += ',' self.response.out.write('{"songs":[%s]}' % songsJson)
def get(self, author_name): author_name = re.sub('_', ' ', author_name) sq = Song.all().filter("author =", author_name).order("date") self._print('{"songs":[%s]}' % format_json(sq.fetch(100)))