mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Fixed more read-only id queries
This commit is contained in:
parent
2c44745abc
commit
0ba55d466d
@ -396,17 +396,21 @@ def get_track_id(trackdict,create_new=True,update_album=False,dbconn=None):
|
||||
#print("required artists",artist_ids,"this match",match_artist_ids)
|
||||
if set(artist_ids) == set(match_artist_ids):
|
||||
#print("ID for",trackdict['title'],"was",row[0])
|
||||
if trackdict.get('album'):
|
||||
if trackdict.get('album') and create_new:
|
||||
# if we don't supply create_new, it means we just want to get info about a track
|
||||
# which means no need to write album info, even if it was new
|
||||
add_track_to_album(row.id,get_album_id(trackdict['album'],dbconn=dbconn),replace=update_album,dbconn=dbconn)
|
||||
return row.id
|
||||
|
||||
if not create_new: return None
|
||||
|
||||
print("Creating new track")
|
||||
op = DB['tracks'].insert().values(
|
||||
**track_dict_to_db(trackdict,dbconn=dbconn)
|
||||
)
|
||||
result = dbconn.execute(op)
|
||||
track_id = result.inserted_primary_key[0]
|
||||
print(track_id)
|
||||
|
||||
for artist_id in artist_ids:
|
||||
op = DB['trackartists'].insert().values(
|
||||
|
@ -111,20 +111,20 @@ def dl_image(url):
|
||||
### even if we have already cached it, we will handle that on request
|
||||
def get_track_image(track=None,track_id=None):
|
||||
if track_id is None:
|
||||
track_id = database.sqldb.get_track_id(track)
|
||||
track_id = database.sqldb.get_track_id(track,create_new=False)
|
||||
|
||||
return f"/image?type=track&id={track_id}"
|
||||
|
||||
|
||||
def get_artist_image(artist=None,artist_id=None):
|
||||
if artist_id is None:
|
||||
artist_id = database.sqldb.get_artist_id(artist)
|
||||
artist_id = database.sqldb.get_artist_id(artist,create_new=False)
|
||||
|
||||
return f"/image?type=artist&id={artist_id}"
|
||||
|
||||
def get_album_image(album=None,album_id=None):
|
||||
if album_id is None:
|
||||
album_id = database.sqldb.get_album_id(album)
|
||||
album_id = database.sqldb.get_album_id(album,create_new=False)
|
||||
|
||||
return f"/image?type=album&id={album_id}"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user