From 6c2c89c20594d0c769d54ec9d78c9baf87439091 Mon Sep 17 00:00:00 2001 From: krateng Date: Mon, 30 Oct 2023 12:21:14 +0100 Subject: [PATCH] Fix file comparison for Spotify import, fix GH-261 --- dev/releases/3.2.yml | 4 ++++ maloja/proccontrol/tasks/import_scrobbles.py | 21 ++++++++++++++------ maloja/web/jinja/admin_setup.jinja | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/dev/releases/3.2.yml b/dev/releases/3.2.yml index 5478adf..bcd0d53 100644 --- a/dev/releases/3.2.yml +++ b/dev/releases/3.2.yml @@ -18,3 +18,7 @@ minor_release_name: "Nicole" - "[Bugfix] Disabled DB maintenance while not running main server" - "[Bugfix] Removed some nonsensical ephemereal database entry creations" - "[Bugfix] Fixed API endpoint for track charts with no artist provided" + - "[Technical] Bumped Python and SQLAlchemy versions" + - "[Distribution] Removed build of arm/v7 image" +3.2.1: + notes: [] \ No newline at end of file diff --git a/maloja/proccontrol/tasks/import_scrobbles.py b/maloja/proccontrol/tasks/import_scrobbles.py index 3d06ad3..245a49b 100644 --- a/maloja/proccontrol/tasks/import_scrobbles.py +++ b/maloja/proccontrol/tasks/import_scrobbles.py @@ -133,7 +133,9 @@ def import_scrobbles(inputf): def parse_spotify_lite_legacy(inputf): pth = os.path - inputfolder = pth.relpath(pth.dirname(pth.abspath(inputf))) + # use absolute paths internally for peace of mind. just change representation for console output + inputf = pth.abspath(inputf) + inputfolder = pth.dirname(inputf) filenames = re.compile(r'StreamingHistory[0-9]+\.json') inputfiles = [os.path.join(inputfolder,f) for f in os.listdir(inputfolder) if filenames.match(f)] @@ -143,8 +145,9 @@ def parse_spotify_lite_legacy(inputf): if inputfiles != [inputf]: print("Spotify files should all be imported together to identify duplicates across the whole dataset.") - if not ask("Import " + ", ".join(col['yellow'](i) for i in inputfiles) + "?",default=True): + if not ask("Import " + ", ".join(col['yellow'](pth.basename(i)) for i in inputfiles) + "?",default=True): inputfiles = [inputf] + print("Only importing", col['yellow'](pth.basename(inputf))) for inputf in inputfiles: @@ -183,7 +186,9 @@ def parse_spotify_lite_legacy(inputf): def parse_spotify_lite(inputf): pth = os.path - inputfolder = pth.relpath(pth.dirname(pth.abspath(inputf))) + # use absolute paths internally for peace of mind. just change representation for console output + inputf = pth.abspath(inputf) + inputfolder = pth.dirname(inputf) filenames = re.compile(r'Streaming_History_Audio.+\.json') inputfiles = [os.path.join(inputfolder,f) for f in os.listdir(inputfolder) if filenames.match(f)] @@ -193,8 +198,9 @@ def parse_spotify_lite(inputf): if inputfiles != [inputf]: print("Spotify files should all be imported together to identify duplicates across the whole dataset.") - if not ask("Import " + ", ".join(col['yellow'](i) for i in inputfiles) + "?",default=True): + if not ask("Import " + ", ".join(col['yellow'](pth.basename(i)) for i in inputfiles) + "?",default=True): inputfiles = [inputf] + print("Only importing", col['yellow'](pth.basename(inputf))) for inputf in inputfiles: @@ -239,7 +245,9 @@ def parse_spotify_lite(inputf): def parse_spotify(inputf): pth = os.path - inputfolder = pth.relpath(pth.dirname(pth.abspath(inputf))) + # use absolute paths internally for peace of mind. just change representation for console output + inputf = pth.abspath(inputf) + inputfolder = pth.dirname(inputf) filenames = re.compile(r'endsong_[0-9]+\.json') inputfiles = [os.path.join(inputfolder,f) for f in os.listdir(inputfolder) if filenames.match(f)] @@ -249,8 +257,9 @@ def parse_spotify(inputf): if inputfiles != [inputf]: print("Spotify files should all be imported together to identify duplicates across the whole dataset.") - if not ask("Import " + ", ".join(col['yellow'](i) for i in inputfiles) + "?",default=True): + if not ask("Import " + ", ".join(col['yellow'](pth.basename(i)) for i in inputfiles) + "?",default=True): inputfiles = [inputf] + print("Only importing", col['yellow'](pth.basename(inputf))) # we keep timestamps here as well to remove duplicates because spotify's export # is messy - this is specific to this import type and should not be mixed with diff --git a/maloja/web/jinja/admin_setup.jinja b/maloja/web/jinja/admin_setup.jinja index b2713d6..9f1f008 100644 --- a/maloja/web/jinja/admin_setup.jinja +++ b/maloja/web/jinja/admin_setup.jinja @@ -123,7 +123,7 @@

Say thanks

Donations are never required, but always appreciated. If you really like Maloja, you can fund my next Buttergipfel via - PayPal, Bitcoin or Flattr. + PayPal or Bitcoin.