Exemplo n.º 1
0
    def add_track(self, prov_id, user_id, special):
        
        #make sure it's in the DB
        t = MusicLibrary.get_track(provider_id=prov_id)
        
        if not User.is_admin() and self._numTracksFromUser(user_id) > 1:
            return common.buildDialogResponse("You can only have 2 songs on the playlist at once :(", 409)

        if self.playlist().contains_track(t.id):
            return common.buildDialogResponse("Someone already added that one (but you can go vote it up).", 409)
        
        PlaylistItem(track_id=t.id, location_id=self.id, user_id=user_id, date_added=str(datetime.now()), special=special).save()
        self.update_subscribers()
        return common.buildDialogResponse("Song added!", 200)
Exemplo n.º 2
0
def getTrack(track_id):
    return MusicLibrary.get_track(id=track_id).to_json()
Exemplo n.º 3
0
def getSearch(query):
    return json.dumps(MusicLibrary.search(**{"term":query}))