Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Philipp Wolfer
funkwhale
Commits
1d36df3f
Commit
1d36df3f
authored
Aug 26, 2020
by
Agate
💬
Browse files
[plugin/scrobbler] Fixed scrobbling issues due to invalid payload
parent
dbe69eeb
Changes
1
Hide whitespace changes
Inline
Side-by-side
api/funkwhale_api/contrib/scrobbler/scrobbler.py
View file @
1d36df3f
...
...
@@ -104,17 +104,21 @@ def get_scrobble2_payload(track, date, suffix="[0]"):
"""
upload
=
track
.
uploads
.
filter
(
duration__gte
=
0
).
first
()
data
=
{
"artist{}"
.
format
(
suffix
):
track
.
artist
.
name
,
"track{}"
.
format
(
suffix
):
track
.
title
,
"duration{}"
.
format
(
suffix
):
upload
.
duration
if
upload
else
0
,
"album{}"
.
format
(
suffix
):
(
track
.
album
.
title
if
track
.
album
else
""
)
or
""
,
"trackNumber{}"
.
format
(
suffix
):
track
.
position
or
""
,
"mbid{}"
.
format
(
suffix
):
str
(
track
.
mbid
)
or
""
,
"chosenByUser{}"
.
format
(
suffix
):
"P"
,
# Source: P = chosen by user
"artist"
:
track
.
artist
.
name
,
"track"
:
track
.
title
,
"chosenByUser"
:
1
,
}
if
upload
:
data
[
"duration"
]
=
upload
.
duration
if
track
.
album
:
data
[
"album"
]
=
track
.
album
.
title
if
track
.
position
:
data
[
"trackNumber"
]
=
track
.
position
if
track
.
mbid
:
data
[
"mbid"
]
=
str
(
track
.
mbid
)
if
date
:
offset
=
upload
.
duration
/
2
if
upload
.
duration
else
0
data
[
"timestamp
{}"
.
format
(
suffix
)]
=
int
(
date
.
timestamp
())
-
offset
data
[
"timestamp
"
]
=
int
(
int
(
date
.
timestamp
())
-
offset
)
return
data
...
...
@@ -142,7 +146,9 @@ def submit_scrobble_v2(
"api_key"
:
api_key
,
"sk"
:
session_key
,
}
params
.
update
(
get_scrobble2_payload
(
track
,
scrobble_time
))
scrobble
=
get_scrobble2_payload
(
track
,
scrobble_time
)
PLUGIN
[
"logger"
].
debug
(
"Scrobble payload: %s"
,
scrobble
)
params
.
update
(
scrobble
)
params
[
"api_sig"
]
=
hash_request
(
params
,
api_secret
)
response
=
session
.
post
(
scrobble_url
,
params
)
if
'status="ok"'
not
in
response
.
text
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment