From 8ed3923851a1c3e6c28d110eccdd8b6096a8a639 Mon Sep 17 00:00:00 2001 From: krateng Date: Wed, 30 Mar 2022 21:37:43 +0200 Subject: [PATCH] Fixed timestamp parsing for Spotify import, GH-104 --- maloja/proccontrol/tasks/importer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/maloja/proccontrol/tasks/importer.py b/maloja/proccontrol/tasks/importer.py index 190b0c6..ee5f66d 100644 --- a/maloja/proccontrol/tasks/importer.py +++ b/maloja/proccontrol/tasks/importer.py @@ -35,6 +35,7 @@ def import_scrobbles(inputf): print(f"Parsing {col['yellow'](inputf)} as {col['cyan'](type)} export") + if os.path.exists(outputf): while True: action = prompt(f"Already imported {type} data. [O]verwrite, [A]ppend or [C]ancel?",default='c').lower()[0] @@ -48,7 +49,10 @@ def import_scrobbles(inputf): break else: print("Could not understand response.") + else: + mode = 'w' + with open(outputf,mode) as outputfd: success = 0 failed = 0 @@ -114,7 +118,7 @@ def parse_spotify(inputf): try: sec = int(entry['ms_played'] / 1000) - timestamp = entry['offline_timestamp'] + timestamp = int(entry['offline_timestamp'] / 1000) artist = entry['master_metadata_album_artist_name'] title = entry['master_metadata_track_name'] album = entry['master_metadata_album_album_name']