Open Apeiros-46B opened 2 years ago
Another thing I wanted to point out: on some systems the /tmp
dir is cleared on boot; maybe it would be better to store album art in ~/.cache
instead? Or make the dir configurable
Consider that some clients cache there own artwork and generate a temporary filename, with this implementation every time you play a youtube video (even if its the same video!) for example from firefox a new file is created, which, with this solution, will never be deleted. I think a task to clean old files is outside of the scope, but this new behavior should be considered with this change
Edit: Since those files are local (they begin with a file:// uri) maybe they could be filtered and set directly cause there is no need to run curl for them anyways. (And according to freedesktop spec this should be always the case - "URIs should be sent as (UTF-8) strings. Local files should use the "file://" schema.")
Example metadata from firefox:
{
["mpris:artUrl"] = "file:///home/nawuko/.mozilla/firefox/firefox-mpris/4688_6.png",
["xesam:album"] = "",
["xesam:artist"] = { "Practical Engineering" },
["xesam:title"] = "What Happens When a Reservoir Goes Dry?"
}
Don't know much about the playerctl module. @Kasper24 is the contact person for that. Nawuko seems to have valid concerns too
Would checking if the art url starts with file://
and then use that path instead of downloading it work for this? Or are there also other clients that don't report the file path correctly
@Kasper24
@JavaCafe01 The issue with storing it in cache is it won't get deleted, that's why I saved it to tmp instead. It also uses a blocking function to query if the file exists or not, so that would need to be converted to async. Another issue I saw mentioned in the discord is that when no network connection is available, trying to download the artwork will cause the metadata signal to not be emitted, so it might be worth to split them into 2 signals ("metadata" and "artwork") while we're at it
Summary
This PR
os.tmpname()
with a URL-based path in the playerctl module and prevents album art from being downloaded multiple times, andhttps://
andhttp://
are first removed from the URL, then/tmp/bling_album_art .. trimmed_url
is used as the pathsave_image_async_curl
function inhelpers/filesystem.lua
(required for 1.):redownload
: if this isfalse
and the file already exists,curl
isn't calledcreate_dirs
: if this istrue
the--create-dirs
flag is added to thecurl
callThis means that
Notes
Haven't tested if this works when passing some other values for
redownload
andcreate_dirs
to the save image function, but it theoretically should still work just fine