Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle artist and album URIs in get_images() #13

Open
tkem opened this issue Jun 14, 2015 · 4 comments
Open

Handle artist and album URIs in get_images() #13

tkem opened this issue Jun 14, 2015 · 4 comments
Labels
C-enhancement Category: A PR with an enhancement or an issue with an enhancement proposal

Comments

@tkem
Copy link
Member

tkem commented Jun 14, 2015

Mopidy v1.0 Library.get_images() allows retrieving images for any URI, not just tracks. To facilitate this, a mapping of URIs to image paths should be kept, probably in an SQLite database.
Since the local scanner only provides a track URI in the model passed to local.Library.add(), the implementation needs too first call add() and then lookup on the delegate library to extract any album or artist URIs assigned by Mopidy-Local-SQLite, for example.

@tkem
Copy link
Member Author

tkem commented Jun 14, 2015

The database should also store image width and height, which are now encoded in the image path.

@tkem
Copy link
Member Author

tkem commented Jun 14, 2015

Since a mapping of URIs to images will be available, this can also be used to (optionally) add image URIs to album models on lookup`.

@tkem
Copy link
Member Author

tkem commented Jun 14, 2015

Cleanup should be handled using database triggers. For example, if the last track is removed for an image, all other model mappings for that image must be removed, too, and the file deleted from disk.

@tkem
Copy link
Member Author

tkem commented Jun 14, 2015

Looks like (at least) three tables are needed for this:

image (path, width, height, ...)
track_model (track_uri, model_uri, ...)
model_image (model_uri, image_path)

Deleting a track will delete the model_image and all track_model records for that track.
Deleting a track_model will delete all model_image records for that model, unless the model is referenced by another track.
Deleting a model_image will delete the image unless referenced otherwise.

This definitely needs some unit tests...

@tkem tkem transferred this issue from mopidy/mopidy-local-images Dec 9, 2019
@jodal jodal added the C-enhancement Category: A PR with an enhancement or an issue with an enhancement proposal label Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: A PR with an enhancement or an issue with an enhancement proposal
Projects
None yet
Development

No branches or pull requests

2 participants