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)
def getTrack(track_id): return MusicLibrary.get_track(id=track_id).to_json()
def getSearch(query): return json.dumps(MusicLibrary.search(**{"term":query}))