mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Made addpicture endpoint part of the external API, GH-169
This commit is contained in:
parent
a12253dc29
commit
ddc78c5756
@ -504,6 +504,32 @@ def post_scrobble(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@api.post("addpicture")
|
||||||
|
@authenticated_function(alternate=api_key_correct,api=True)
|
||||||
|
@catch_exceptions
|
||||||
|
def add_picture(b64,artist:Multi=[],title=None):
|
||||||
|
"""Uploads a new image for an artist or track.
|
||||||
|
|
||||||
|
param string b64: Base 64 representation of the image
|
||||||
|
param string artist: Artist name. Can be supplied multiple times for tracks with multiple artists.
|
||||||
|
param string title: Title of the track. Optional.
|
||||||
|
|
||||||
|
"""
|
||||||
|
keys = FormsDict()
|
||||||
|
for a in artist:
|
||||||
|
keys.append("artist",a)
|
||||||
|
if title is not None: keys.append("title",title)
|
||||||
|
k_filter, _, _, _, _ = uri_to_internal(keys)
|
||||||
|
if "track" in k_filter: k_filter = k_filter["track"]
|
||||||
|
url = images.set_image(b64,**k_filter)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'status': 'success',
|
||||||
|
'url': url
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@api.post("importrules")
|
@api.post("importrules")
|
||||||
@authenticated_function(api=True)
|
@authenticated_function(api=True)
|
||||||
@catch_exceptions
|
@catch_exceptions
|
||||||
@ -582,20 +608,6 @@ def search(**keys):
|
|||||||
return {"artists":artists_result[:max_],"tracks":tracks_result[:max_]}
|
return {"artists":artists_result[:max_],"tracks":tracks_result[:max_]}
|
||||||
|
|
||||||
|
|
||||||
@api.post("addpicture")
|
|
||||||
@authenticated_function(api=True)
|
|
||||||
@catch_exceptions
|
|
||||||
def add_picture(b64,artist:Multi=[],title=None):
|
|
||||||
"""Internal Use Only"""
|
|
||||||
keys = FormsDict()
|
|
||||||
for a in artist:
|
|
||||||
keys.append("artist",a)
|
|
||||||
if title is not None: keys.append("title",title)
|
|
||||||
k_filter, _, _, _, _ = uri_to_internal(keys)
|
|
||||||
if "track" in k_filter: k_filter = k_filter["track"]
|
|
||||||
images.set_image(b64,**k_filter)
|
|
||||||
|
|
||||||
|
|
||||||
@api.post("newrule")
|
@api.post("newrule")
|
||||||
@authenticated_function(api=True)
|
@authenticated_function(api=True)
|
||||||
@catch_exceptions
|
@catch_exceptions
|
||||||
|
@ -298,3 +298,5 @@ def set_image(b64,**keys):
|
|||||||
# set as current picture in rotation
|
# set as current picture in rotation
|
||||||
if track: set_image_in_cache(id,'tracks',os.path.join("/images",folder,filename))
|
if track: set_image_in_cache(id,'tracks',os.path.join("/images",folder,filename))
|
||||||
else: set_image_in_cache(id,'artists',os.path.join("/images",folder,filename))
|
else: set_image_in_cache(id,'artists',os.path.join("/images",folder,filename))
|
||||||
|
|
||||||
|
return os.path.join("/images",folder,filename)
|
||||||
|
Loading…
Reference in New Issue
Block a user