diff --git a/database.py b/database.py
index cd3b359..56f7617 100644
--- a/database.py
+++ b/database.py
@@ -33,6 +33,7 @@ TRACKS = [] # Format: tuple(frozenset(artist_ref,...),title)
SCROBBLESDICT = {} # timestamps to scrobble mapping
STAMPS = [] # sorted
#STAMPS_SET = set() # as set for easier check if exists
+MEDALS = {} #literally only changes once per year, no need to calculate that on the fly
cla = CleanerAgent()
coa = CollectorAgent()
@@ -461,7 +462,7 @@ def artistInfo(artist):
others = coa.getAllAssociated(artist)
position = charts.index(c)
while position != 0 and c["scrobbles"] == charts[position-1]["scrobbles"]: position -= 1
- return {"scrobbles":scrobbles,"position":position + 1,"associated":others}
+ return {"scrobbles":scrobbles,"position":position + 1,"associated":others,"medals":MEDALS.get(artist)}
except:
# if the artist isnt in the charts, they are not being credited and we need to show information about the credited one
artist = coa.getCredited(artist)
@@ -787,6 +788,32 @@ def build_db():
# load cached images
#loadCache()
+ #medals
+ global MEDALS
+ firstyear = datetime.datetime.utcfromtimestamp(STAMPS[0]).year
+ currentyear = datetime.datetime.utcnow().year
+ for year in range(firstyear,currentyear):
+
+ charts = get_charts_artists(within=[year])
+ scr = -1
+ rank = 0
+ for a in charts:
+ if a["scrobbles"] != scr: rank = charts.index(a) + 1
+ if rank > 3: break
+
+ artist = a["artist"]
+ if rank == 1: MEDALS.setdefault(artist,{}).setdefault("gold",[]).append(year)
+ if rank == 2: MEDALS.setdefault(artist,{}).setdefault("silver",[]).append(year)
+ if rank == 3: MEDALS.setdefault(artist,{}).setdefault("bronze",[]).append(year)
+
+
+ scr = a["scrobbles"]
+
+
+
+
+ print(MEDALS)
+
log("Database fully built!")
diff --git a/website/artist.html b/website/artist.html
index 8626ea9..23cc701 100644
--- a/website/artist.html
+++ b/website/artist.html
@@ -13,7 +13,10 @@
- KEY_ARTISTNAME KEY_POSITION
+ KEY_ARTISTNAME
+ KEY_POSITION
+ KEY_MEDALS
+
KEY_ASSOCIATED
KEY_SCROBBLES Scrobbles
diff --git a/website/artist.py b/website/artist.py
index 3dd5994..55ee2ed 100644
--- a/website/artist.py
+++ b/website/artist.py
@@ -15,6 +15,18 @@ def instructions(keys):
scrobbles = str(data["scrobbles"])
pos = "#" + str(data["position"])
+ html_medals = ""
+ if "medals" in data and data["medals"] is not None:
+ if "gold" in data["medals"]:
+ for y in data["medals"]["gold"]:
+ html_medals += "" + str(y) + ""
+ if "silver" in data["medals"]:
+ for y in data["medals"]["silver"]:
+ html_medals += "" + str(y) + ""
+ if "bronze" in data["medals"]:
+ for y in data["medals"]["bronze"]:
+ html_medals += "" + str(y) + ""
+
credited = data.get("replace")
includestr = " "
if credited is not None:
@@ -27,12 +39,12 @@ def instructions(keys):
html_tracks, _ = module_trackcharts(**filterkeys,max_=15)
-
+
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_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}
diff --git a/website/css/maloja.css b/website/css/maloja.css
index 9632f35..bab778d 100644
--- a/website/css/maloja.css
+++ b/website/css/maloja.css
@@ -248,6 +248,31 @@ span.stat_selector_pulse,span.stat_selector_topartists,span.stat_selector_toptra
+.gold,.silver,.bronze {
+ font-size:80%;
+ padding:3px;
+ margin:2px;
+ border-radius:2px;
+}
+.gold a:hover,.silver a:hover,.bronze a:hover {
+ text-decoration:none;
+
+}
+
+.gold {
+ background-color:gold;
+ color:black;
+}
+.silver {
+ background-color:silver;
+ color:black;
+}
+.bronze {
+ background-color:darkred;
+ color:black;
+}
+
+
/*
**
|