mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Added proper logging to upgrade script
This commit is contained in:
parent
1207475e4d
commit
fba21b7128
@ -35,7 +35,7 @@ def upgrade_db(callback_add_scrobbles):
|
||||
if os.path.exists(oldfolder):
|
||||
scrobblefiles = [f for f in os.listdir(oldfolder) if f.endswith(".tsv")]
|
||||
if len(scrobblefiles) > 0:
|
||||
print(col['yellow']("Upgrading v2 Database to v3 Database. This could take a while..."))
|
||||
log("Upgrading v2 Database to v3 Database. This could take a while...",color='yellow')
|
||||
idx = 0
|
||||
for sf in scrobblefiles:
|
||||
idx += 1
|
||||
@ -48,10 +48,11 @@ def upgrade_db(callback_add_scrobbles):
|
||||
else:
|
||||
origin = 'unknown'
|
||||
|
||||
# TODO still tsv module here!
|
||||
from doreah import tsv
|
||||
scrobbles = tsv.parse(os.path.join(oldfolder,sf),"int","string","string","string","string",comments=False)
|
||||
scrobblelist = []
|
||||
print(f"\tImporting from {sf} ({idx}/{len(scrobblefiles)}) - {len(scrobbles)} Scrobbles")
|
||||
log(f"\tImporting from {sf} ({idx}/{len(scrobblefiles)}) - {len(scrobbles)} Scrobbles")
|
||||
for scrobble in scrobbles:
|
||||
timestamp, artists, title, album, duration = scrobble
|
||||
if album in ('-',''): album = None
|
||||
@ -73,4 +74,4 @@ def upgrade_db(callback_add_scrobbles):
|
||||
})
|
||||
callback_add_scrobbles(scrobblelist)
|
||||
os.rename(os.path.join(oldfolder,sf),os.path.join(newfolder,sf))
|
||||
print(col['yellow']("Done!"))
|
||||
log("Done!",color='yellow')
|
||||
|
Loading…
Reference in New Issue
Block a user