Added proper logging to upgrade script

This commit is contained in:
krateng 2022-04-08 21:17:17 +02:00
parent 1207475e4d
commit fba21b7128
1 changed files with 4 additions and 3 deletions

View File

@ -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')