pimoroni / mopidy-pidi

Mopidy plugin host for pidi display plugins.
Apache License 2.0
11 stars 20 forks source link

Mopidy-PiDi displays Internet-retrieved album art instead of existing art #16

Closed TrollDecker closed 1 year ago

TrollDecker commented 3 years ago

Heyo,

I've noticed that in some cases, while playing local media, the album art shown on the Pirate-Audio screen doesn't always match the art embedded in the playing file or present in Mopidy's database.

For example, when listening to Trance Nation 2, I see the following on Iris:

Screenshot_20210205_235035_org mozilla firefox

But I see the following on the Pirate-Audio screen:

IMG_20210205_235106

Instead, I should be seeing something like this: IMG_20210205_235202

Gadgetoid commented 3 years ago

The musicbrainz album art lookup is a fallback in case Mopdiy's API doesn't return any album art, or returns files that are too small.

I guess we'd need to figure out what track.uri is being passed here, and what data the local library handler is returning:

https://github.com/pimoroni/mopidy-pidi/blob/03fc14f63965f4375059e8074470c839ff652f72/mopidy_pidi/frontend.py#L145

A little tweak to frontend.py will get this to spit out some basic info:

diff --git a/mopidy_pidi/frontend.py b/mopidy_pidi/frontend.py
index e7fb2a0..ff740ea 100644
--- a/mopidy_pidi/frontend.py
+++ b/mopidy_pidi/frontend.py
@@ -143,16 +143,20 @@ class PiDiFrontend(pykka.ThreadingActor, core.CoreListener):

         art = None
         track_images = self.core.library.get_images([track.uri]).get()
+        logger.info("{uri} returned {img} images".format(uri=track.uri, img=len(track_images)))
         if track.uri in track_images:
             track_images = track_images[track.uri]
             if len(track_images) == 1:
                 art = track_images[0].uri
+                logger.info("Using track_image uri: {uri}".format(uri=art))
             else:
                 for image in track_images:
+                    logger.info("Checking image {uri}, dimensions: {w}x{h}".format(uri=image.uri, w=image.width, h=image.height))
                     if image.width is None or image.height is None:
                         continue
                     if image.height >= 240 and image.width >= 240:
                         art = image.uri
+                        logger.info("Using >=240x240 track_image uri: {uri}".format(uri=art))

         self.display.update_album_art(art=art)

A quick not very comprehensive test (I don't really have curated offline music) with Mopidy Local suggests it's finding my cover.png files:

Sep 13 10:43:29 bullseye mopidy[2880]: INFO     [PiDiFrontend-10] mopidy_pidi.frontend local:track:TRUTHR%20-%20TRUTHR/TRUTHR%20-%20TRUTHR%20-%2003%20Paradise%20500.mp3 returned 1 images
Sep 13 10:43:29 bullseye mopidy[2880]: INFO     [PiDiFrontend-10] mopidy_pidi.frontend Checking image /local/a9a917137027121b19d53ce8430aaaa6-700x700.jpeg, dimensions: 700x700
Sep 13 10:43:29 bullseye mopidy[2880]: INFO     [PiDiFrontend-10] mopidy_pidi.frontend Using >=240x240 track_image uri: /local/a9a917137027121b19d53ce8430aaaa6-700x700.jpeg
Sep 13 10:43:29 bullseye mopidy[2880]: INFO     [PiDiFrontend-10] mopidy_pidi.frontend Checking image /local/fc1a6d449e628f644943734f0d5fdeca-1400x1400.png, dimensions: 1400x1400
Sep 13 10:43:29 bullseye mopidy[2880]: INFO     [PiDiFrontend-10] mopidy_pidi.frontend Using >=240x240 track_image uri: /local/fc1a6d449e628f644943734f0d5fdeca-1400x1400.png

You can either dig into the guts of Python and edit this debug waffle into frontend.py directly, or clone this repository and use sudo python3 setup.py develop. Maybe this will help track down what's going wrong and where.

joopdo commented 1 year ago

FYI: https://github.com/pimoroni/mopidy-pidi/pull/28