mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Added time selector to scrobbles and fixed bug with multiartist tracks
This commit is contained in:
parent
aa56e11d85
commit
c96103ad28
@ -32,15 +32,17 @@ def scrobblesLink(timekeys,amount=None,percent=None,artist=None,track=None,assoc
|
|||||||
return "<a href='/scrobbles?" + keysToUrl(timekeys) + "'>" + inner + "</a>"
|
return "<a href='/scrobbles?" + keysToUrl(timekeys) + "'>" + inner + "</a>"
|
||||||
|
|
||||||
# necessary because urllib.parse.urlencode doesnt handle multidicts
|
# necessary because urllib.parse.urlencode doesnt handle multidicts
|
||||||
def keysToUrl(*dicts):
|
def keysToUrl(*dicts,exclude=[]):
|
||||||
st = ""
|
st = ""
|
||||||
keys = removeIdentical(*dicts)
|
keys = removeIdentical(*dicts)
|
||||||
for k in keys:
|
for k in keys:
|
||||||
|
if k in exclude: continue
|
||||||
values = keys.getall(k)
|
values = keys.getall(k)
|
||||||
st += "&".join([urllib.parse.urlencode({k:v},safe="/") for v in values])
|
st += "&".join([urllib.parse.urlencode({k:v},safe="/") for v in values])
|
||||||
st += "&"
|
st += "&"
|
||||||
return st
|
return st
|
||||||
|
|
||||||
|
|
||||||
def removeIdentical(*dicts):
|
def removeIdentical(*dicts):
|
||||||
#combine multiple dicts
|
#combine multiple dicts
|
||||||
keys = FormsDict()
|
keys = FormsDict()
|
||||||
|
@ -283,10 +283,10 @@ def module_filterselection(keys,time=True,delimit=False):
|
|||||||
|
|
||||||
html = ""
|
html = ""
|
||||||
|
|
||||||
|
|
||||||
if time:
|
if time:
|
||||||
|
|
||||||
retainkeys = {k:keys[k] for k in keys if k not in ["since","to","in"]}
|
keystr = "?" + keysToUrl(keys,exclude=["since","to","in"])
|
||||||
keystr = "?" + urllib.parse.urlencode(retainkeys)
|
|
||||||
|
|
||||||
|
|
||||||
# wonky selector for precise date range
|
# wonky selector for precise date range
|
||||||
@ -343,8 +343,7 @@ def module_filterselection(keys,time=True,delimit=False):
|
|||||||
|
|
||||||
if delimit:
|
if delimit:
|
||||||
|
|
||||||
retainkeys = {k:keys[k] for k in keys if k not in ["step","stepn"]}
|
keystr = "?" + keysToUrl(keys,exclude=["step","stepn"])
|
||||||
keystr = "?" + urllib.parse.urlencode(retainkeys)
|
|
||||||
|
|
||||||
html += "<div>"
|
html += "<div>"
|
||||||
if keys.get("step") == "day":
|
if keys.get("step") == "day":
|
||||||
@ -367,8 +366,8 @@ def module_filterselection(keys,time=True,delimit=False):
|
|||||||
html += "</div>"
|
html += "</div>"
|
||||||
|
|
||||||
|
|
||||||
retainkeys = {k:keys[k] for k in keys if k not in ["trail"]}
|
|
||||||
keystr = "?" + urllib.parse.urlencode(retainkeys)
|
keystr = "?" + keysToUrl(keys,exclude=["trail"])
|
||||||
|
|
||||||
html += "<div>"
|
html += "<div>"
|
||||||
if keys.get("trail") == "1" or keys.get("trail") is None:
|
if keys.get("trail") == "1" or keys.get("trail") is None:
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
<h1>Scrobbles</h1><br/>
|
<h1>Scrobbles</h1><br/>
|
||||||
<span>KEY_LIMITS</span>
|
<span>KEY_LIMITS</span>
|
||||||
<p class="stats">KEY_SCROBBLES Scrobbles</p>
|
<p class="stats">KEY_SCROBBLES Scrobbles</p>
|
||||||
|
<br/>
|
||||||
|
KEY_FILTERSELECTOR
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -5,7 +5,7 @@ import database
|
|||||||
def instructions(keys):
|
def instructions(keys):
|
||||||
from utilities import getArtistImage, getTrackImage
|
from utilities import getArtistImage, getTrackImage
|
||||||
from htmlgenerators import artistLink, artistLinks, trackLink, KeySplit
|
from htmlgenerators import artistLink, artistLinks, trackLink, KeySplit
|
||||||
from htmlmodules import module_scrobblelist
|
from htmlmodules import module_scrobblelist, module_filterselection
|
||||||
from malojatime import range_desc
|
from malojatime import range_desc
|
||||||
|
|
||||||
|
|
||||||
@ -27,6 +27,8 @@ def instructions(keys):
|
|||||||
|
|
||||||
limitstring += " " + range_desc(**timekeys)
|
limitstring += " " + range_desc(**timekeys)
|
||||||
|
|
||||||
|
html_filterselector = module_filterselection(keys)
|
||||||
|
|
||||||
|
|
||||||
html, amount, rep = module_scrobblelist(**filterkeys,**timekeys,**amountkeys)
|
html, amount, rep = module_scrobblelist(**filterkeys,**timekeys,**amountkeys)
|
||||||
|
|
||||||
@ -44,6 +46,10 @@ def instructions(keys):
|
|||||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||||
|
|
||||||
|
|
||||||
replace = {"KEY_SCROBBLELIST":html,"KEY_SCROBBLES":str(amount),"KEY_IMAGEURL":imgurl,"KEY_LIMITS":limitstring}
|
replace = {"KEY_SCROBBLELIST":html,
|
||||||
|
"KEY_SCROBBLES":str(amount),
|
||||||
|
"KEY_IMAGEURL":imgurl,
|
||||||
|
"KEY_LIMITS":limitstring,
|
||||||
|
"KEY_FILTERSELECTOR":html_filterselector}
|
||||||
|
|
||||||
return (replace,pushresources)
|
return (replace,pushresources)
|
||||||
|
Loading…
Reference in New Issue
Block a user