Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add optional base64 image parameter to newscrobble #324

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions maloja/apis/native_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ def post_scrobble(
length:int=None,
time:int=None,
nofix=None,
album_image=None,
track_image=None,
auth_result=None,
**extra_kwargs):
"""Submit a new scrobble.
Expand All @@ -609,6 +611,8 @@ def post_scrobble(
:param int length: Total length of the track in seconds. Optional.
:param int time: UNIX timestamp of the scrobble. Optional, not needed if scrobble is at time of request.
:param flag nofix: Skip server-side metadata parsing. Optional.
:param string album_image: Data URI base64 encoded album art. Optional.
:param string track_image: Data URI base64 encoded track art. Optional.

:return: status (String), track (Mapping)
:rtype: Dictionary
Expand Down Expand Up @@ -655,6 +659,19 @@ def post_scrobble(
{'type':'mixed_schema','value':['artist','artists'],
'desc':"These two fields are meant as alternative methods to submit information. Use of both is discouraged, but works at the moment."}
]
if album_image or track_image:
# Using the parameters supplied directly won't work because they aren't parsed
# for example, album artists will be all one big string instead of an array of strings
# so take details from `result`
artists = result['track']['artists']
title = result['track']['title']
if album_image:
if 'album' in result['track']:
albumartists = result['track']['album']['artists']
album = result['track']['album']['albumtitle']
images.set_image(album_image,artists=albumartists or artists,albumtitle=album)
if track_image:
images.set_image(track_image,artists=artists,title=title)

if len(responsedict['warnings']) == 0: del responsedict['warnings']

Expand Down