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
122529f4
Commit
122529f4
authored
Aug 26, 2020
by
Agate
💬
Browse files
[plugin/scrobbler] Fixed wrong caching of session key
parent
84981df5
Changes
1
Hide whitespace changes
Inline
Side-by-side
api/funkwhale_api/contrib/scrobbler/funkwhale_ready.py
View file @
122529f4
from
config
import
plugins
import
hashlib
from
config
import
plugins
from
.funkwhale_startup
import
PLUGIN
from
.
import
scrobbler
...
...
@@ -24,10 +25,14 @@ def forward_to_scrobblers(listening, conf, **kwargs):
and
PLUGIN
[
"settings"
][
"lastfm_api_secret"
]
and
url
==
DEFAULT_SCROBBLER_URL
):
PLUGIN
[
"logger"
].
info
(
"Forwarding scrobble to %s"
,
LASTFM_SCROBBLER_URL
)
session_key
=
PLUGIN
[
"cache"
].
get
(
"lastfm:sessionkey:{}"
.
format
(
listening
.
user
.
pk
)
hashed_auth
=
hashlib
.
md5
(
(
username
+
" "
+
password
).
encode
(
"utf-8"
)
).
hexdigest
()
cache_key
=
"lastfm:sessionkey:{}"
.
format
(
":"
.
join
([
str
(
listening
.
user
.
pk
),
hashed_auth
])
)
PLUGIN
[
"logger"
].
info
(
"Forwarding scrobble to %s"
,
LASTFM_SCROBBLER_URL
)
session_key
=
PLUGIN
[
"cache"
].
get
(
cache_key
)
if
not
session_key
:
PLUGIN
[
"logger"
].
debug
(
"Authenticating…"
)
session_key
=
scrobbler
.
handshake_v2
(
...
...
@@ -38,9 +43,7 @@ def forward_to_scrobblers(listening, conf, **kwargs):
api_key
=
PLUGIN
[
"settings"
][
"lastfm_api_key"
],
api_secret
=
PLUGIN
[
"settings"
][
"lastfm_api_secret"
],
)
PLUGIN
[
"cache"
].
set
(
"lastfm:sessionkey:{}"
.
format
(
listening
.
user
.
pk
),
session_key
)
PLUGIN
[
"cache"
].
set
(
cache_key
,
session_key
)
scrobbler
.
submit_scrobble_v2
(
session
=
session
,
track
=
listening
.
track
,
...
...
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