Mopidy Discourse

Backend - Image model - uri pointing to file in cache_dir?

If a backend extension saves an image in the cache_dir, can it then point to that file in a mopidy Image model, like this:

{uri: [Image(uri=f"file://{os.path.join(cache_dir, filename)}")]}

No, They need to be accessible over the network for clients to use.

Thanks @kingosticks

Cheers,
Nik

Also, as a related note (but it doesn’t matter for what you are trying to do), you can’t rely on anything in cache_dir to be there. It might be cleared on reboot or other times. cache_dir is for caching. We have data_dir for stuff you want to persist.

Yeah, it is for cache - if the file is there, return an Image object that points to the file; if it’s not there point to the url and save the image in the cache the first time it is accessed. But it sounds like there’s no way to do that.

Someone requested caching: caching the audio and the metadata is pretty straightforward, but caching the image, it seems, isn’t.

Cheers
Nik

Well, Mopidy does have a built-in HTTP server. So you could leverage that, just like GitHub - mopidy/mopidy-local-images: DEPRECATED (Mopidy local library proxy extension for handling embedded album art)

But if the user has disabled (or misconfigured) their HTTP extension then it won’t work.

Yes, I actually had exactly the same thought, overnight!

Ta