From 8b8470439cc89eefdd2d16b1d6fcd9d3142e45c5 Mon Sep 17 00:00:00 2001 From: Krateng Date: Tue, 23 Apr 2019 17:55:59 +0200 Subject: [PATCH] Display latest scrobbles for artists as well as tracks --- website/artist.html | 3 +++ website/artist.py | 23 +++++++++++++++++------ website/track.html | 2 +- website/track.py | 16 ++++++++++++---- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/website/artist.html b/website/artist.html index 3d3c99e..d75c0c8 100644 --- a/website/artist.html +++ b/website/artist.html @@ -32,5 +32,8 @@

Pulse

KEY_PULSE +

Last Scrobbles

+ KEY_SCROBBLELIST + diff --git a/website/artist.py b/website/artist.py index aef0ec6..c6aed45 100644 --- a/website/artist.py +++ b/website/artist.py @@ -6,9 +6,10 @@ def instructions(keys): from utilities import getArtistImage from htmlgenerators import artistLink, artistLinks from urihandler import compose_querystring, uri_to_internal - from htmlmodules import module_pulse, module_trackcharts + from htmlmodules import module_pulse, module_trackcharts, module_scrobblelist filterkeys, _, _, _ = uri_to_internal(keys,forceArtist=True) + artist = filterkeys.get("artist") imgurl = getArtistImage(filterkeys["artist"],fast=True) pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else [] @@ -41,13 +42,23 @@ def instructions(keys): html_tracks, _ = module_trackcharts(**filterkeys,max_=15) + html_scrobbles, _, _ = module_scrobblelist(artist=artist,max_=10,earlystop=True) html_pulse = module_pulse(**filterkeys,step="year",stepn=1,trail=1) - replace = {"KEY_ARTISTNAME":keys["artist"],"KEY_ENC_ARTISTNAME":urllib.parse.quote(keys["artist"]), - "KEY_IMAGEURL":imgurl, "KEY_DESCRIPTION":"","KEY_MEDALS":html_medals, - "KEY_TRACKLIST":html_tracks,"KEY_PULSE":html_pulse, - "KEY_SCROBBLES":scrobbles,"KEY_POSITION":pos, - "KEY_ASSOCIATED":includestr} + replace = { + "KEY_ARTISTNAME":keys["artist"], + "KEY_ENC_ARTISTNAME":urllib.parse.quote(keys["artist"]), + "KEY_IMAGEURL":imgurl, + "KEY_DESCRIPTION":"", + "KEY_MEDALS":html_medals, + "KEY_TRACKLIST":html_tracks, + "KEY_PULSE":html_pulse, + "KEY_SCROBBLES":scrobbles, + "KEY_SCROBBLELIST":html_scrobbles, + "KEY_SCROBBLELINK":compose_querystring(keys), + "KEY_POSITION":pos, + "KEY_ASSOCIATED":includestr + } return (replace,pushresources) diff --git a/website/track.html b/website/track.html index 9f9a7cb..17685a7 100644 --- a/website/track.html +++ b/website/track.html @@ -28,7 +28,7 @@ KEY_PULSE -

Scrobbles

+

Last Scrobbles

KEY_SCROBBLELIST diff --git a/website/track.py b/website/track.py index c8e769f..18be6fd 100644 --- a/website/track.py +++ b/website/track.py @@ -35,13 +35,21 @@ def instructions(keys): - html_scrobbles, _, _ = module_scrobblelist(track=track,max_=100,earlystop=True) # we have the number already from the trackinfo + html_scrobbles, _, _ = module_scrobblelist(track=track,max_=10,earlystop=True) # we have the number already from the trackinfo html_pulse = module_pulse(track=track,step="year",stepn=1,trail=1) - replace = {"KEY_TRACKTITLE":track.get("title"),"KEY_ARTISTS":artistLinks(track.get("artists")),"KEY_SCROBBLES":scrobblesnum,"KEY_POSITION":pos,"KEY_IMAGEURL":imgurl, - "KEY_SCROBBLELINK":compose_querystring(keys),"KEY_MEDALS":html_medals, - "KEY_SCROBBLELIST":html_scrobbles,"KEY_PULSE":html_pulse} + replace = { + "KEY_TRACKTITLE":track.get("title"), + "KEY_ARTISTS":artistLinks(track.get("artists")), + "KEY_SCROBBLES":scrobblesnum, + "KEY_POSITION":pos, + "KEY_IMAGEURL":imgurl, + "KEY_SCROBBLELINK":compose_querystring(keys), + "KEY_MEDALS":html_medals, + "KEY_SCROBBLELIST":html_scrobbles, + "KEY_PULSE":html_pulse + } return (replace,pushresources)