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):
     song = Song.get_by_id(int(self.request.params['id']))
     if not song:
         self.response.out.write('no song')
         return
     
     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._print('done')