Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def addSongToLibrary(to_add, db):
idreturn = db.insert('library',
song=to_add['song'],
artist=to_add['artist'],
album=to_add['album'],
hostId=to_add['host_lib_song_id'])
toReturn = db.select(
'library',
where=web.db.sqlwhere({'id' : idreturn})
)
row = toReturn[0]
return LibraryEntry(row.id, row.hostId, row.song, row.artist, row.album, row.isDeleted)
def default(self, obj):
if isinstance(obj, LibraryEntry):
return {
LibraryEntry.SERVER_ID_PARAM : obj.getServerId(),
LibraryEntry.HOST_ID_PARAM : obj.getHostId(),
LibraryEntry.SONG_PARAM : obj.getSong(),
LibraryEntry.ARTIST_PARAM : obj.getArtist(),
LibraryEntry.ALBUM_PARAM : obj.getAlbum(),
LibraryEntry.IS_DELETED_PARAM : obj.getDeleteStatusString(),
}
else:
return json.JSONEncoder.default(self, obj)
def default(self, obj):
if isinstance(obj, LibraryEntry):
return {
LibraryEntry.SERVER_ID_PARAM : obj.getServerId(),
LibraryEntry.HOST_ID_PARAM : obj.getHostId(),
LibraryEntry.SONG_PARAM : obj.getSong(),
LibraryEntry.ARTIST_PARAM : obj.getArtist(),
LibraryEntry.ALBUM_PARAM : obj.getAlbum(),
LibraryEntry.IS_DELETED_PARAM : obj.getDeleteStatusString(),
}
else:
return json.JSONEncoder.default(self, obj)
def default(self, obj):
if isinstance(obj, LibraryEntry):
return {
LibraryEntry.SERVER_ID_PARAM : obj.getServerId(),
LibraryEntry.HOST_ID_PARAM : obj.getHostId(),
LibraryEntry.SONG_PARAM : obj.getSong(),
LibraryEntry.ARTIST_PARAM : obj.getArtist(),
LibraryEntry.ALBUM_PARAM : obj.getAlbum(),
LibraryEntry.IS_DELETED_PARAM : obj.getDeleteStatusString(),
}
else:
return json.JSONEncoder.default(self, obj)
def default(self, obj):
if isinstance(obj, LibraryEntry):
return {
LibraryEntry.SERVER_ID_PARAM : obj.getServerId(),
LibraryEntry.HOST_ID_PARAM : obj.getHostId(),
LibraryEntry.SONG_PARAM : obj.getSong(),
LibraryEntry.ARTIST_PARAM : obj.getArtist(),
LibraryEntry.ALBUM_PARAM : obj.getAlbum(),
LibraryEntry.IS_DELETED_PARAM : obj.getDeleteStatusString(),
}
else:
return json.JSONEncoder.default(self, obj)
def default(self, obj):
if isinstance(obj, LibraryEntry):
return {
LibraryEntry.SERVER_ID_PARAM : obj.getServerId(),
LibraryEntry.HOST_ID_PARAM : obj.getHostId(),
LibraryEntry.SONG_PARAM : obj.getSong(),
LibraryEntry.ARTIST_PARAM : obj.getArtist(),
LibraryEntry.ALBUM_PARAM : obj.getAlbum(),
LibraryEntry.IS_DELETED_PARAM : obj.getDeleteStatusString(),
}
else:
return json.JSONEncoder.default(self, obj)
def getJSONObject(dbrow):
return LibraryEntry(
dbrow.id,
dbrow.hostId,
dbrow.song,
dbrow.artist,
dbrow.album,
dbrow.isDeleted)
def addSongToLibrary(to_add, db):
idreturn = db.insert('library',
song=to_add['song'],
artist=to_add['artist'],
album=to_add['album'],
hostId=to_add['host_lib_song_id'])
toReturn = db.select(
'library',
where=web.db.sqlwhere({'id' : idreturn})
)
row = toReturn[0]
return LibraryEntry(row.id, row.hostId, row.song, row.artist, row.album, row.isDeleted)
def default(self, obj):
if isinstance(obj, LibraryEntry):
return {
LibraryEntry.SERVER_ID_PARAM : obj.getServerId(),
LibraryEntry.HOST_ID_PARAM : obj.getHostId(),
LibraryEntry.SONG_PARAM : obj.getSong(),
LibraryEntry.ARTIST_PARAM : obj.getArtist(),
LibraryEntry.ALBUM_PARAM : obj.getAlbum(),
LibraryEntry.IS_DELETED_PARAM : obj.getDeleteStatusString(),
}
else:
return json.JSONEncoder.default(self, obj)