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

artUrl metadata missing #1111

Closed
shad-lp opened this issue Feb 18, 2023 · 10 comments
Closed

artUrl metadata missing #1111

shad-lp opened this issue Feb 18, 2023 · 10 comments

Comments

@shad-lp
Copy link

shad-lp commented Feb 18, 2023

Describe the bug
artUrl is not sent back to Iris when playing file through Snapcast.

Steps to Reproduce

  1. Use a docker-compose file to run Iris instances and snapserver :
version: "2.1"
services:

   iris-snapserver:
      container_name: iris-snapserver
      hostname: iris-snapserver
      image: jaedb/snapserver
      networks:
         - net-proxy
      ports:
         # stream
         - 1704:1704
      volumes:
         - /tmp/snapserver:/tmp
         - /opt/iris-snapserver/snapserver.conf:/etc/snapserver.conf
         - /opt/iris-snapserver/meta_mopidy.py:/usr/share/snapserver/plug-ins/meta_mopidy.py
      restart: unless-stopped
     
   iris-mopidy-jack:
      image: jaedb/iris
      container_name: iris-mopidy-jack
      hostname: iris-mopidy-jack
      networks:
         - net-proxy
      environment:
         - PIP_PACKAGES=Mopidy-Local Mopidy-YTMusic
      depends_on:
         - iris-snapserver
      volumes:
         # iris-specific storage
         - /opt/iris-mopidy-jack/data:/var/lib/mopidy/iris
         # playlists
         - /opt/iris-mopidy-jack/m3u:/var/lib/mopidy/m3u
         # config
         - /opt/iris-mopidy-jack/config/mopidy.conf:/config/mopidy.conf:ro
         # local
         - /opt/iris-mopidy-jack/local:/var/lib/mopidy/local
         # music files
         - /mnt/nas/music:/var/lib/mopidy/media:ro
         - /tmp/snapserver:/tmp
      restart: unless-stopped

   iris-mopidy-thane:
      image: jaedb/iris
      container_name: iris-mopidy-thane
      hostname: iris-mopidy-thane
      networks:
         - net-proxy
      environment:
         - PIP_PACKAGES=Mopidy-Local
      depends_on:
         - iris-snapserver
      volumes:
         # iris-specific storage
         - /opt/iris-mopidy-thane/data:/var/lib/mopidy/iris
         # playlists
         - /opt/iris-mopidy-thane/m3u:/var/lib/mopidy/m3u
         # config
         - /opt/iris-mopidy-thane/config/mopidy.conf:/config/mopidy.conf:ro
         # local
         - /opt/iris-mopidy-thane/local:/var/lib/mopidy/local
         # music files
         - /mnt/nas/music:/var/lib/mopidy/media:ro
         - /tmp/snapserver:/tmp
      restart: unless-stopped
     
networks:

   net-proxy:
      external: true
  1. Use latest meta_mopidy.py file
  2. Configure snapserver's streams for each instance :
source = pipe:///tmp/jack_fifo?name=JACK&controlscript=meta_mopidy.py&controlscriptparams=--mopidy-host=iris-mopidy-jack
source = pipe:///tmp/thane_fifo?name=THANE&controlscript=meta_mopidy.py&controlscriptparams=--mopidy-host=iris-mopidy-thane
  1. Play a file through Iris interface :

image

I can control the stream and metadata is sent back to Iris, but no thumbnail.
(Attached) logs show that snapserver seems to fetch thumbnail from Mopidy-Local thumbnail database.
I tried to wget the same image from inside the container, and the download is functional.

Environment details

  • OS: Docker
  • Snapcast version 0.27.0
  • Installed from a package, self compiled, ... : jaedb's image

Attach logfile if applicable

2023-02-18 12-25-52.266 [Info] (PcmStream) Stream: JACK, message: 2023-02-18 12:25:52,266 meta_mopidy INFO: New properties: {'playbackStatus': 'playing', 'shuffle': False, 'volume': 60, 'mute': False, 'position': 0.277, 'loopStatus': 'none', 'canGoNext': True, 'canGoPrevious': True, 'canPlay': True, 'canPause': True, 'canSeek': True, 'canControl': True, 'metadata': {'url': 'local:track:bibliotheque/albums%20et%20various/Puggy%20-%20Dubois%20died%20today/01%20-%20Dubois.flac', 'title': 'Dubois', 'musicbrainzArtistId': '5049ba10-e082-480b-b5da-0b89a1869e84', 'artist': ['Puggy'], 'genre': ['Indie'], 'trackNumber': 1, 'trackId': '1', 'discNumber': 1, 'contentCreated': '2007', 'duration': 212.693, 'musicbrainzTrackId': 'fe0d5d53-3d7c-49ee-a6d2-ffc161bcbd46'}}
2023-02-18 12-25-52.277 [Info] (PcmStream) Stream: JACK, message: 2023-02-18 12:25:52,277 meta_mopidy INFO: New properties: {'playbackStatus': 'playing', 'shuffle': False, 'volume': 60, 'mute': False, 'position': 0.277, 'loopStatus': 'none', 'canGoNext': True, 'canGoPrevious': True, 'canPlay': True, 'canPause': True, 'canSeek': True, 'canControl': True, 'metadata': {'url': 'local:track:bibliotheque/albums%20et%20various/Puggy%20-%20Dubois%20died%20today/01%20-%20Dubois.flac', 'title': 'Dubois', 'musicbrainzArtistId': '5049ba10-e082-480b-b5da-0b89a1869e84', 'artist': ['Puggy'], 'genre': ['Indie'], 'trackNumber': 1, 'trackId': '1', 'discNumber': 1, 'contentCreated': '2007', 'duration': 212.693, 'musicbrainzTrackId': 'fe0d5d53-3d7c-49ee-a6d2-ffc161bcbd46', 'artUrl': 'http://iris-mopidy-jack:6680/local/5e305d8a01a28b7ce1213054c3410da0-640x640.jpeg'}}
@shad-lp
Copy link
Author

shad-lp commented Feb 24, 2023

Any idea ?

@badaix
Copy link
Owner

badaix commented Mar 10, 2023

this looks like it contains an artUrl:

2023-02-18 12-25-52.277 [Info] (PcmStream) Stream: JACK, message: 2023-02-18 12:25:52,277 meta_mopidy INFO: New properties: {'playbackStatus': 'playing', 'shuffle': False, 'volume': 60, 'mute': False, 'position': 0.277, 'loopStatus': 'none', 'canGoNext': True, 'canGoPrevious': True, 'canPlay': True, 'canPause': True, 'canSeek': True, 'canControl': True, 'metadata': {'url': 'local:track:bibliotheque/albums%20et%20various/Puggy%20-%20Dubois%20died%20today/01%20-%20Dubois.flac', 'title': 'Dubois', 'musicbrainzArtistId': '5049ba10-e082-480b-b5da-0b89a1869e84', 'artist': ['Puggy'], 'genre': ['Indie'], 'trackNumber': 1, 'trackId': '1', 'discNumber': 1, 'contentCreated': '2007', 'duration': 212.693, 'musicbrainzTrackId': 'fe0d5d53-3d7c-49ee-a6d2-ffc161bcbd46', 'artUrl': 'http://iris-mopidy-jack:6680/local/5e305d8a01a28b7ce1213054c3410da0-640x640.jpeg'}}

@shad-lp
Copy link
Author

shad-lp commented Mar 16, 2023

Hello,

Yes as I said previously it seems I can load a thumbnail from the mopidy instance.
Fmi, how does Snapcast send back the artUrl back to Iris ? I guess that the problem is located between snapserver and Iris, but can't figure out where, mainly because I can't find any error.

I'll ask the same question on Iris issues page.
If I can make it work, I'll warn people here.

@badaix
Copy link
Owner

badaix commented Mar 17, 2023

I don't know how Iris is working, but I assume that it acts as Snapcast control client and is connected via a websocket to the Snapserver and should receive notifications like this:

{
    "jsonrpc": "2.0",
    "method": "Stream.OnProperties",
    "params": {
        "id": "Pipe",
        "properties": {
            "canControl": true,
            "canGoNext": true,
            "canGoPrevious": true,
            "canPause": true,
            "canPlay": true,
            "canSeek": true,
            "loopStatus": "none",
            "metadata": {
                "artUrl": "http://192.168.0.38:6680/local/c5e93946c6fca5207b1bf40a1f2f3dc5-500x500.jpeg",
                "artist": [
                    "Billie Eilish"
                ],
                "contentCreated": "2021-07-30",
                "discNumber": 1,
                "duration": 214.05799865722656,
                "musicbrainzArtistId": "f4abc0b5-3f7a-4eff-8f78-ac078dbce533",
                "musicbrainzTrackId": "c4b333df-1f31-4435-b256-8c497ec09eff",
                "title": "OverHeated",
                "trackId": "10",
                "trackNumber": 10,
                "url": "local:track:B/Billie%20Eilish/Billie%20Eilish%20-%20Happier%20Than%20Ever%20%282021%29/10%20-%20OverHeated.ogg"
            },
            "mute": false,
            "playbackStatus": "playing",
            "position": 0.33799999952316284,
            "shuffle": false,
            "volume": 100
        }
    }
}

There was also a discussion with @jaedb, while I've developed the meta_mopidy.py plugin: #997

@shad-lp
Copy link
Author

shad-lp commented Mar 19, 2023

@badaix Thx for your answer.
Here is my Iris debug snapcast status while playing a track, I have two rpi clients connected to two different streams :

{
  "server": {
    "groups": [
      {
        "clients": [
          {
            "config": {
              "instance": 1,
              "latency": 0,
              "name": "",
              "volume": {
                "muted": false,
                "percent": 52
              }
            },
            "connected": true,
            "host": {
              "arch": "aarch64",
              "ip": "192.168.100.104",
              "mac": "b8:27:eb:ff:ff:ff",
              "name": "jack",
              "os": "Debian GNU/Linux 11 (bullseye)"
            },
            "id": "b8:27:eb:ff:ff:ff",
            "lastSeen": {
              "sec": 1679210188,
              "usec": 814459
            },
            "snapclient": {
              "name": "Snapclient",
              "protocolVersion": 2,
              "version": "0.23.0"
            }
          }
        ],
        "id": "5c142573-efb2-0fcd-9aa5-4f0c3ae4810a",
        "muted": false,
        "name": "jack-group",
        "stream_id": "JACK"
      },
      {
        "clients": [
          {
            "config": {
              "instance": 1,
              "latency": 0,
              "name": "",
              "volume": {
                "muted": false,
                "percent": 100
              }
            },
            "connected": true,
            "host": {
              "arch": "armv7l",
              "ip": "192.168.100.102",
              "mac": "b8:27:eb:ff:ff:ff",
              "name": "thane",
              "os": "Raspbian GNU/Linux 11 (bullseye)"
            },
            "id": "b8:27:eb:ff:ff:ff",
            "lastSeen": {
              "sec": 1679210188,
              "usec": 725941
            },
            "snapclient": {
              "name": "Snapclient",
              "protocolVersion": 2,
              "version": "0.23.0"
            }
          }
        ],
        "id": "d23ac777-9567-b080-4b74-d10cdb56ea97",
        "muted": false,
        "name": "thane-group",
        "stream_id": "THANE"
      }
    ],
    "server": {
      "host": {
        "arch": "x86_64",
        "ip": "",
        "mac": "",
        "name": "iris-snapserver",
        "os": "Debian GNU/Linux 11 (bullseye)"
      },
      "snapserver": {
        "controlProtocolVersion": 1,
        "name": "Snapserver",
        "protocolVersion": 1,
        "version": "0.27.0"
      }
    },
    "streams": [
      {
        "id": "JACK",
        "properties": {
          "canControl": true,
          "canGoNext": true,
          "canGoPrevious": true,
          "canPause": true,
          "canPlay": true,
          "canSeek": true,
          "loopStatus": "none",
          "metadata": {
            "artUrl": "http://iris-mopidy-jack:6680/local/3b83327e86637f6d0ad61b03529190cb-800x800.jpeg",
            "artist": [
              "Lukas Graham"
            ],
            "comment": [
              "Freak37"
            ],
            "contentCreated": "2018",
            "discNumber": 1,
            "duration": 191.84300231933594,
            "genre": [
              "Pop"
            ],
            "title": "Lullaby",
            "trackId": "2",
            "trackNumber": 2,
            "url": "local:track:albums%20et%20various/Lukas%20Graham%20-%203%20%28The%20Purple%20Album%29%20%282018%29/02.%20Lullaby.mp3"
          },
          "mute": false,
          "playbackStatus": "playing",
          "position": 0.20800000429153442,
          "shuffle": false,
          "volume": 100
        },
        "status": "playing",
        "uri": {
          "fragment": "",
          "host": "",
          "path": "/tmp/jack_fifo",
          "query": {
            "chunk_ms": "20",
            "codec": "flac",
            "controlscript": "meta_mopidy.py",
            "controlscriptparams": "--mopidy-host=iris-mopidy-jack",
            "name": "JACK",
            "sampleformat": "48000:16:2"
          },
          "raw": "pipe:////tmp/jack_fifo?chunk_ms=20&codec=flac&controlscript=meta_mopidy.py&controlscriptparams=--mopidy-host=iris-mopidy-jack&name=JACK&sampleformat=48000:16:2",
          "scheme": "pipe"
        }
      },
      {
        "id": "THANE",
        "properties": {
          "canControl": true,
          "canGoNext": true,
          "canGoPrevious": true,
          "canPause": true,
          "canPlay": true,
          "canSeek": false,
          "loopStatus": "none",
          "playbackStatus": "stopped",
          "position": 0,
          "shuffle": false,
          "volume": 100
        },
        "status": "idle",
        "uri": {
          "fragment": "",
          "host": "",
          "path": "/tmp/thane_fifo",
          "query": {
            "chunk_ms": "20",
            "codec": "flac",
            "controlscript": "meta_mopidy.py",
            "controlscriptparams": "--mopidy-host=iris-mopidy-thane",
            "name": "THANE",
            "sampleformat": "48000:16:2"
          },
          "raw": "pipe:////tmp/thane_fifo?chunk_ms=20&codec=flac&controlscript=meta_mopidy.py&controlscriptparams=--mopidy-host=iris-mopidy-thane&name=THANE&sampleformat=48000:16:2",
          "scheme": "pipe"
        }
      }
    ]
  }
}

I read your discussion with jaedb, it's intereting, I feel like my setup should work. Basically I'm overriding the mopidy-host parameter from the meta_mopidy.py file with the controlscriptparams argument in the snapserver.conf file :

source = pipe:///tmp/jack_fifo?name=JACK&controlscript=meta_mopidy.py&controlscriptparams=--mopidy-host=iris-mopidy-jack

The JSON code above seems taking it into account correctly. Basically I just have to customize two parameters :

  • mopidy-host : see above
  • stream : passed with the 'name=JACK' argument

Rest can point to default values (mopidy-port, snapcast-host, snapcast-port)

One last question, do my snapclients on my rpi have to be on the 0.27.0 version too ? I feel like it should not be needed, but maybe I'm wrong.

@badaix
Copy link
Owner

badaix commented Mar 19, 2023

Ok, so the artUrl should be available to Iris, I hope that it will also pick it up and that I didn't break any compatibility on the control interface.
You don't need to pass the --stream parameter, this is done implicitly by the Snapserver.
I don't explicitly test the compatibility between different client and server versions, but older client versions should work fine, since I've not changed the streaming protocol for years. If your client is playing audio, then there should be no need to update.
When you find out something regarding the art url, please give me an update.

@jaedb
Copy link

jaedb commented Mar 21, 2023

I concur with @badaix that all is looking as expected from the Snapcast perspective. The question remains as to why the metadata.artUrl is not accessible by your browser.

Taking the example of:

"artUrl": "http://iris-mopidy-jack:6680/local/3b83327e86637f6d0ad61b03529190cb-800x800.jpeg",

is iris-mopidy-jack:6680 accessible in your browser (from a computer other than your Docker host)?

Based on your docker-compose.yml I would wager iris-mopidy-jack is the Docker internal network hostname and may not be accessible beyond your Docker host machine. What if you ran your Mopidy containers with network_mode: host, but map each to their own port?

This way you can set the Mopidy host to match your Docker host's ip address and the Docker container's port. The net result of this should be that each individual Mopidy instance is accessible to the wider LAN.

@shad-lp
Copy link
Author

shad-lp commented Mar 22, 2023

Hello,

Thnaks for your input. You are effectively right @jaedb. I had not understood that the browser had a direct connection to the mopidy hostname which is in this case its docker dns name. As a quick check, I edited the hosts file of the mopidy's host server to match iris-mopidy-jack to the internal Docker IP (172.19....) and the thumbnail is displayed indeed.

is iris-mopidy-jack:6680 accessible in your browser (from a computer other than your Docker host)?

Actually, I can display the jpeg via https://iris.domain.tld/local/3b83327e86637f6d0ad61b03529190cb-800x800.jpeg instead (via the reversr proxy). I feel like Mopidy could use the hostname specified in the mopidy.conf file to translate the docker interanl hostname to this :

[http]
hostname = 0.0.0.0
allowed_origins = iris.domain.tld
default_app = iris

Anyway, I would have prefered not to expose any port from the container (to make sure every access is done through the reverse proxy) but I'm happy to know why it did not work as I was expecting.

Thanks again @jaedb and @badaix for the hard work.

@shad-lp
Copy link
Author

shad-lp commented Mar 25, 2023

Hello @jaedb @badaix

I identified another little problem.
I customized the controlscriptparams of my second instance. As suggested, I switched to network_mode host to make my instance widely available on the network.

source = pipe:///tmp/jack_fifo?name=JACK&controlscript=meta_mopidy.py&controlscriptparams=--mopidy-host=shepard.xxxxx.ovh
source = pipe:///tmp/thane_fifo?name=THANE&controlscript=meta_mopidy.py&controlscriptparams=--mopidy-host=shepard.xxxxx.ovh%20--mopidy-port=6780

If I access Iris via HTTP, everything works well :

image

With HTTPS, I ran into a feature called Mixed content prevention on modern browsers (I tried Edge, Firefox and Chrome), this prevents loading unsecured (http) data, mainly images and videos, on site running as secured (https) :

Mixed Content: The page at 'https://iris.xxxxx.ovh/iris/album/bG9jYWw6YWxidW06bWQ1OjdhZjU1OTVhNTY3ZGY2MmE0ZTU0MWQ2N2M4YzU0ZDJh/Archangel' was loaded over HTTPS, but requested an insecure element 'http://shepard.xxxxx.ovh:6780/local/3b96134815076317c1980052b73b3310-500x500.jpeg'. This request was automatically upgraded to HTTPS, For more information see https://blog.chromium.org/2019/10/no-more-mixed-messages-about-https.html

Same data through HTTPS :

image

So I tried to customize the controlscriptparams to use my reverse proxy host and port (iris.xxxx.ovh:443).
But the meta_mopidy.py assumes that everything is running on the same host.
That means all JSON RPC, MPD, HTTP services.

So naturally, using the reverse proxy host & port for WebUI could make the trick, but it fails for everything related to audio playback.

2023-03-25 07-07-08.547 [Error] (PcmStream) Stream: JACK, message: 2023-03-25 07:07:08,547 meta_mopidy ERROR: Handshake status 400 Bad Request
2023-03-25 07-07-08.547 [Info] (PcmStream) Stream: JACK, message: 2023-03-25 07:07:08,547 meta_mopidy INFO: Snapcast RPC websocket closed
2023-03-25 07-07-09.551 [Error] (PcmStream) Stream: THANE, message: 2023-03-25 07:07:09,551 meta_mopidy ERROR: Snapcast RPC websocket error

Making Iris available natively on a secured port could do the trick, but that does not belong to this repository.
Or being able to disable to Mixed content prevention feature on my browsers, I didn't find how to, and it's probably not a lasting solution.
Maybe there's something that could be done on the meta_mopidy.py script, if I could dissociate the WebUI host part of the host used to send JSON RPC commands.

It seemd like it's more and more a feature request and not an issue reporting.
Feel free to close if that doesn't suit.

@shad-lp
Copy link
Author

shad-lp commented Mar 25, 2023

Nevermind, I just set Chrome to allow mixed content and it works perfectly.
Not a strong solution for sure, but it will do the job.

@shad-lp shad-lp closed this as completed Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants