Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
funkwhale
mopidy
Commits
d9cd25b5
Verified
Commit
d9cd25b5
authored
Sep 25, 2020
by
David Sn
Browse files
Support caching for cover art images
Signed-off-by:
David Sn
<
divad.nnamtdeis@gmail.com
>
parent
70c5319a
Changes
1
Hide whitespace changes
Inline
Side-by-side
mopidy_funkwhale/library.py
View file @
d9cd25b5
...
@@ -259,11 +259,16 @@ class FunkwhaleLibraryProvider(backend.LibraryProvider):
...
@@ -259,11 +259,16 @@ class FunkwhaleLibraryProvider(backend.LibraryProvider):
logger
.
debug
(
"Handling get images: %s"
,
uris
)
logger
.
debug
(
"Handling get images: %s"
,
uris
)
result
=
{}
result
=
{}
# TODO Add cache
for
uri
in
uris
:
for
uri
in
uris
:
track_id
=
uri
.
split
(
":"
)[
-
1
]
track_id
=
uri
.
split
(
":"
)[
-
1
]
payload
=
self
.
backend
.
client
.
get_track
(
track_id
)
cache_key
=
"funkwhale:images:%s"
%
track_id
from_cache
=
self
.
cache
.
get
(
cache_key
)
if
from_cache
:
result
[
uri
]
=
from_cache
continue
payload
=
self
.
backend
.
client
.
get_track
(
track_id
)
if
not
payload
[
"album"
][
"cover"
]:
if
not
payload
[
"album"
][
"cover"
]:
continue
continue
...
@@ -282,6 +287,8 @@ class FunkwhaleLibraryProvider(backend.LibraryProvider):
...
@@ -282,6 +287,8 @@ class FunkwhaleLibraryProvider(backend.LibraryProvider):
result
[
uri
].
append
(
image
)
result
[
uri
].
append
(
image
)
self
.
cache
.
set
(
cache_key
,
result
[
uri
])
return
result
return
result
def
search
(
self
,
query
=
None
,
uris
=
None
,
exact
=
False
):
def
search
(
self
,
query
=
None
,
uris
=
None
,
exact
=
False
):
...
...
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