mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Change to time handling
This commit is contained in:
parent
752832db88
commit
e50b0d7194
@ -1,6 +1,7 @@
|
||||
import urllib
|
||||
from bottle import FormsDict
|
||||
import datetime
|
||||
from malojatime import time_fix, internal_to_uri
|
||||
|
||||
|
||||
def artistLink(name):
|
||||
@ -33,6 +34,9 @@ def scrobblesLink(timekeys,amount=None,percent=None,artist=None,track=None,assoc
|
||||
|
||||
# necessary because urllib.parse.urlencode doesnt handle multidicts
|
||||
def keysToUrl(*dicts,exclude=[]):
|
||||
for dict in dicts:
|
||||
for key in dict:
|
||||
dict[key] = internal_to_uri(dict[key])
|
||||
st = ""
|
||||
keys = removeIdentical(*dicts)
|
||||
for k in keys:
|
||||
@ -148,17 +152,17 @@ def KeySplit(keys,forceTrack=False,forceArtist=False):
|
||||
|
||||
# 2
|
||||
resultkeys2 = {}
|
||||
if "since" in keys: resultkeys2["since"] = keys.get("since")
|
||||
elif "from" in keys: resultkeys2["since"] = keys.get("from")
|
||||
elif "start" in keys: resultkeys2["since"] = keys.get("start")
|
||||
if "since" in keys: resultkeys2["since"] = time_fix(keys.get("since"))
|
||||
elif "from" in keys: resultkeys2["since"] = time_fix(keys.get("from"))
|
||||
elif "start" in keys: resultkeys2["since"] = time_fix(keys.get("start"))
|
||||
#
|
||||
if "to" in keys: resultkeys2["to"] = keys.get("to")
|
||||
elif "until" in keys: resultkeys2["to"] = keys.get("until")
|
||||
elif "end" in keys: resultkeys2["to"] = keys.get("end")
|
||||
if "to" in keys: resultkeys2["to"] = time_fix(keys.get("to"))
|
||||
elif "until" in keys: resultkeys2["to"] = time_fix(keys.get("until"))
|
||||
elif "end" in keys: resultkeys2["to"] = time_fix(keys.get("end"))
|
||||
#
|
||||
if "in" in keys: resultkeys2["within"] = keys.get("in")
|
||||
elif "within" in keys: resultkeys2["within"] = keys.get("within")
|
||||
elif "during" in keys: resultkeys2["within"] = keys.get("during")
|
||||
if "in" in keys: resultkeys2["within"] = time_fix(keys.get("in"))
|
||||
elif "within" in keys: resultkeys2["within"] = time_fix(keys.get("within"))
|
||||
elif "during" in keys: resultkeys2["within"] = time_fix(keys.get("during"))
|
||||
|
||||
|
||||
#3
|
||||
|
@ -22,6 +22,16 @@ def end_of_scrobbling():
|
||||
|
||||
|
||||
|
||||
def uri_to_internal(t):
|
||||
return time_fix(t)
|
||||
|
||||
def internal_to_uri(t):
|
||||
if isinstance(t,list) or isinstance(t,tuple):
|
||||
return "/".join(str(t))
|
||||
|
||||
return str(t)
|
||||
|
||||
|
||||
# converts strings and stuff to lists
|
||||
def time_fix(t):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user