From 0a4ac23dfa39d20f1d596adec189e988e5f505c0 Mon Sep 17 00:00:00 2001 From: krateng Date: Sun, 7 May 2023 22:49:50 +0200 Subject: [PATCH] Fixed manual scrobbling of compilation albums --- maloja/apis/native_v1.py | 4 ++-- maloja/web/jinja/admin_manual.jinja | 15 ++++++++++++++- maloja/web/static/js/manualscrobble.js | 21 ++++++++++++++++++--- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/maloja/apis/native_v1.py b/maloja/apis/native_v1.py index e7d2ff4..0975bf3 100644 --- a/maloja/apis/native_v1.py +++ b/maloja/apis/native_v1.py @@ -444,7 +444,7 @@ def post_scrobble( artists:list=[], title:str="", album:str=None, - albumartists:list=[], + albumartists:list=None, duration:int=None, length:int=None, time:int=None, @@ -478,7 +478,7 @@ def post_scrobble( } # for logging purposes, don't pass values that we didn't actually supply - rawscrobble = {k:rawscrobble[k] for k in rawscrobble if rawscrobble[k]} + rawscrobble = {k:rawscrobble[k] for k in rawscrobble if rawscrobble[k] is not None} # [] should be passed result = database.incoming_scrobble( diff --git a/maloja/web/jinja/admin_manual.jinja b/maloja/web/jinja/admin_manual.jinja index 3ed2ea5..fc3e778 100644 --- a/maloja/web/jinja/admin_manual.jinja +++ b/maloja/web/jinja/admin_manual.jinja @@ -4,6 +4,14 @@ {% block scripts %} + {% endblock %} @@ -45,10 +53,15 @@
+ + Use track artists as album artists fallback + +

+ -
+ diff --git a/maloja/web/static/js/manualscrobble.js b/maloja/web/static/js/manualscrobble.js index 6b7502a..e64f342 100644 --- a/maloja/web/static/js/manualscrobble.js +++ b/maloja/web/static/js/manualscrobble.js @@ -1,5 +1,7 @@ -var lastArtists = [] -var lastTrack = "" +var lastArtists = []; +var lastTrack = ""; +var lastAlbumartists = []; +var lastAlbum = ""; function addArtist(artist) { @@ -96,8 +98,17 @@ function scrobbleNew() { albumartists.push(node.textContent); } + if (albumartists.length == 0) { + var use_track_artists = document.getElementById('use_track_artists_for_album').checked; + if (use_track_artists) { + albumartists = null; + } + } + var title = document.getElementById("title").value; var album = document.getElementById("album").value; + + scrobble(artists,title,albumartists,album); } @@ -111,9 +122,13 @@ function scrobble(artists,title,albumartists,album) { var payload = { "artists":artists, "title":title, - "albumartists": albumartists, "album": album } + if (albumartists != null) { + payload['albumartists'] = albumartists + } + + console.log(payload); if (title != "" && artists.length > 0) {