home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.9k stars 30.97k forks source link

DLNA Media Renderer integration shows "Home Assistant" instead of the track title #74216

Closed Rudd-O closed 2 years ago

Rudd-O commented 2 years ago

The problem

I am expecting my MARANTZ receiver to show me the track title onscreen, along with the other information like album and artist. (This is just a standard MP3 file, by Andreas Tannenberger).

However, the track title, when ever it is queued up from Home Assistant, shows up as "Home Assistant" (the specific track should show as "Collides with beauty").

The server is Jellyfin but I doubt this has anything to do with it.

The code doesn't log anything even at debug level. I am expecting that the didl_metadata variable (media_player.py file of the integration) is containing the wrong value.

What version of Home Assistant Core has the issue?

2022.6.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

DLNA Media Renderer

Link to integration documentation on our website

https://www.home-assistant.io/integrations/dlna_dmr/

Diagnostics information

No diagnostic data available.

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Nothing suspicious.

Additional information

No response

probot-home-assistant[bot] commented 2 years ago

dlna_dmr documentation dlna_dmr source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @stevenlooman, @chishm, mind taking a look at this issue as it has been labeled with an integration (dlna_dmr) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

Rudd-O commented 2 years ago

I can verify that the MARANTZ receiver is receiving the correct ID3 tags, so I have to assume there's something in the exchange between Home Assistant and the receiver that's causing the issue. Will check that out right now.

TCPDUMP of the data between the renderer and the server.

....Y.........FP...B|..GET /Audio/e1bf78fe50f6b203c7101db0f8185939/universal?UserId=dcfe16c2904a4567b94c60f15dfd050b&DeviceId=2f3e6783-346a-4b97-a3a4-307c48f9a19e&api_key=07f8ef06a32b41549ba3cbd31dff13f7&MaxStreamingBitrate=140000000 HTTP/1.1
Host: penny.dragonfear:8096
Icy-MetaData: 1
Connection: close
transferMode.dlna.org: Streaming
User-Agent: WinampMPEG/2.8
Accept: */*

02:58:48.250290 IP penny.dragonfear.8096 > marantz.dragonfear.ltp-deepspace: Flags [.], ack 364, win 63877, length 0
E..("n@.@...
...
......Y...F....P...$...
02:58:50.069953 IP marantz.dragonfear > 239.255.250.250: igmp v1 report 239.255.250.250
E...?#....}8
.................................
02:58:50.393734 IP penny.dragonfear.8096 > marantz.dragonfear.ltp-deepspace: Flags [P.], seq 1:7301, ack 364, win 63877, length 7300
E..."o@.@..P
...
......Y...F....P...A+..HTTP/1.1 200 OK
Connection: close
Content-Type: audio/mpeg
Date: Thu, 30 Jun 2022 02:58:50 GMT
Server: Kestrel
Accept-Ranges: none
Transfer-Encoding: chunked
X-Response-Time-ms: 2141

10000
ID3......~TIT2.......Mysterious skies.TPE1.......ATB.TRCK.......06/13.TALB.......No silence.TYER.......2004.TCON.......Trance.TXXX... ...replaygain_album_peak.1.281841.TXXX... ...replaygain_track_peak.1.207477.TXXX... ...replaygain_track_gain.-7.97 dB.TXXX...#...ID3v1 Comment.www.torrentazos.com.TLEN.......330000.TXXX... ...replaygain_album_gain.-9.03 dB.TSSE.......Lavf58.76.100...............................................Xing................
Rudd-O commented 2 years ago

Yeap my theory was correct, Home Assistant's DLNA media renderer integration is sending the wrong track title. From tcpdump:

        xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
        s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <s:Body>
        <u:GetPositionInfoResponse xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
            <Track>1</Track>
            <TrackDuration>579:01:30</TrackDuration>
            <TrackMetaData>&lt;DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:sec="http://www.sec.co.kr/"&gt;&lt;item id="0" parentID="-1" restricted="false"&gt;&lt;dc:title&gt;Home Assistant&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem&lt;/upnp:class&gt;&lt;res protocolInfo="http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01D00000000000000000000000000000"&gt;http://penny.dragonfear:8096/Audio/d9d95d61dac0080c5c4a1c5697ac5a0e/universal?UserId=dcfe16c2904a4567b94c60f15dfd050b&amp;amp;DeviceId=2f3e6783-346a-4b97-a3a4-307c48f9a19e&amp;amp;api_key=07f8ef06a32b41549ba3cbd31dff13f7&amp;amp;MaxStreamingBitrate=140000000&lt;/res&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</TrackMetaData>
            <TrackURI>http://penny.dragonfear:8096/Audio/d9d95d61dac0080c5c4a1c5697ac5a0e/universal?UserId=dcfe16c2904a4567b94c60f15dfd050b&amp;DeviceId=2f3e6783-346a-4b97-a3a4-307c48f9a19e&amp;api_key=07f8ef06a32b41549ba3cbd31dff13f7&amp;MaxStreamingBitrate=140000000</TrackURI>
            <RelTime>0:00:00</RelTime>
            <AbsTime>11
03:03:02.999984 IP verena.dragonfear.40136 > marantz.dragonfear.webcache: Flags [.], ack 4474, win 63830, length 0
E..(m.@.@...
...
..........<..`.P..V$...

Pay attention to the track title in the TrackMetaData tag.

Rudd-O commented 2 years ago

Boom, found the problem:

        if not title:
            title = extra.get("title") or metadata.get("title") or "Home Assistant"
        if thumb := extra.get("thumb"):
            metadata["album_art_uri"] = thumb

Perhaps my Jellyfin server is not sending the title? But how can it be? I see the title onscreen in the media listing.

Rudd-O commented 2 years ago

Aha, found the bug:

{
    "Name": "Do you love me",
    "ServerId": "685c2f91a45243c7b25d27fdc0e0bd0e",
    "Id": "77950d325b40f528776abb1be2b28bcc",
    "Etag": "53dcb8fd894e51dc53dae9409b7c83b7",
    "DateCreated": "2009-07-28T11:37:30.0000000Z",
    "CanDelete": false,
    "CanDownload": true,
    "SortName": "0010 - Do you love me",
    "PremiereDate": "2003-01-01T00:00:00.0000000Z",
    "ExternalUrls": [],
    "MediaSources": [
        {
            "Protocol": "File",
            "Id": "77950d325b40f528776abb1be2b28bcc",
            "Path": "/srv/shared/Entertainment/Music/Good/Albums and singles/ATB/Addicted to music/Do you love me.mp3",
            "Type": "Default",
            "Container": "mp3",
            "Size": 9400610,
            "Name": "Do you love me",
            "IsRemote": false,
            "ETag": "5dc08ce8d0d0ec0cdfa2c8f3b50252ac",
            "RunTimeTicks": 3916277504,
            "ReadAtNativeFramerate": false,
            "IgnoreDts": false,
            "IgnoreIndex": false,
            "GenPtsInput": false,
            "SupportsTranscoding": true,
            "SupportsDirectStream": true,
            "SupportsDirectPlay": true,
            "IsInfiniteStream": false,
            "RequiresOpening": false,
            "RequiresClosing": false,
            "RequiresLooping": false,
            "SupportsProbing": true,
            "MediaStreams": [
                {
                    "Codec": "mp3",
                    "TimeBase": "1/14112000",
                    "DisplayTitle": "MP3 - Stereo",
                    "IsInterlaced": false,
                    "ChannelLayout": "stereo",
                    "BitRate": 192000,
                    "Channels": 2,
                    "SampleRate": 44100,
                    "IsDefault": false,
                    "IsForced": false,
                    "Type": "Audio",
                    "Index": 0,
                    "IsExternal": false,
                    "IsTextSubtitleStream": false,
                    "SupportsExternalStream": false,
                    "Level": 0
                }
            ],
            "MediaAttachments": [],
            "Formats": [],
            "Bitrate": 192031,
            "RequiredHttpHeaders": {},
            "DefaultAudioStreamIndex": 0
        }
    ],
    "Path": "/srv/shared/Entertainment/Music/Good/Albums and singles/ATB/Addicted to music/Do you love me.mp3",
    "EnableMediaSourceDisplay": true,
    "ChannelId": null,
    "Taglines": [],
    "Genres": [
        "Trance"
    ],
    "RunTimeTicks": 3916277504,
    "PlayAccess": "Full",
    "ProductionYear": 2003,
    "IndexNumber": 10,
    "RemoteTrailers": [],
    "ProviderIds": {},
    "IsFolder": false,
    "ParentId": "d3c9a42abccf5c47360fc09ddd0f7c40",
    "Type": "Audio",
    "People": [],
    "Studios": [],
    "GenreItems": [
        {
            "Name": "Trance",
            "Id": "efe04b5ddd5177b2b7e8820c57bd9f09"
        }
    ],
    "ParentLogoItemId": "71deff08f443e3e24c30e1a1b7a010ec",
    "ParentBackdropItemId": "71deff08f443e3e24c30e1a1b7a010ec",
    "ParentBackdropImageTags": [
        "be730e8d052e4dc1ef89c6524f346529"
    ],
    "LocalTrailerCount": 0,
    "UserData": {
        "PlaybackPositionTicks": 0,
        "PlayCount": 0,
        "IsFavorite": false,
        "Played": false,
        "Key": "ATB-Addicted to music-0010Do you love me"
    },
    "SpecialFeatureCount": 0,
    "DisplayPreferencesId": "61bba315f137702baa296a1c417faada",
    "Tags": [],
    "Artists": [
        "ATB"
    ],
    "ArtistItems": [
        {
            "Name": "ATB",
            "Id": "71deff08f443e3e24c30e1a1b7a010ec"
        }
    ],
    "Album": "Addicted to music",
    "AlbumId": "d3c9a42abccf5c47360fc09ddd0f7c40",
    "AlbumPrimaryImageTag": "74cf0d8f3c8978babc69d4854cfe3303",
    "AlbumArtist": "ATB",
    "AlbumArtists": [
        {
            "Name": "ATB",
            "Id": "71deff08f443e3e24c30e1a1b7a010ec"
        }
    ],
    "MediaStreams": [
        {
            "Codec": "mp3",
            "TimeBase": "1/14112000",
            "DisplayTitle": "MP3 - Stereo",
            "IsInterlaced": false,
            "ChannelLayout": "stereo",
            "BitRate": 192000,
            "Channels": 2,
            "SampleRate": 44100,
            "IsDefault": false,
            "IsForced": false,
            "Type": "Audio",
            "Index": 0,
            "IsExternal": false,
            "IsTextSubtitleStream": false,
            "SupportsExternalStream": false,
            "Level": 0
        }
    ],
    "ImageTags": {},
    "BackdropImageTags": [],
    "ParentLogoImageTag": "6a538fa77b639037f3b868c4c1504174",
    "ImageBlurHashes": {
        "Logo": {
            "6a538fa77b639037f3b868c4c1504174": "OdJRjkbcD*t7xtoeofs:V@oef6j[WBRk~qj=t7aybHa#j["
        },
        "Backdrop": {
            "be730e8d052e4dc1ef89c6524f346529": "W%J\u002BPz?vD%tRb^kC~q-;V@j[ozjZ%2xajst7t7j@o|xujFV[s:ad"
        },
        "Primary": {
            "74cf0d8f3c8978babc69d485(reverse-i-search)`tcpdump': clear ; ^Cpdump 'host penny.dragonfear' -A -s65536 -w capture.pcapystem",
            "MediaType": "Audio",
            "LockedFields": [],
            "LockData": false
        }[root@verena ~
        ]# 

From what you can see there, the title is right there in the "Name" field of the response from the DLNA server to the Home Assistant daemon.

So the fix is to look into making the code also accept the "Name" datum if the "title" datum is not present.

chishm commented 2 years ago

Thanks for the bug report and the detailed debugging session.

For your particular case, it looks like you're using the jellyfin and dlna_dmr integrations. Unfortunately dlna_dmr only knows how to get metadata from the dlna_dms integration (with some extra hacks for the extra keyword to the play_media service).

I think the problem might not be dlna_dmr in isolation so much as there's no standardised way for media source integrations to give metadata to media player integrations. Perhaps I should revive work on standardising media metadata.

Rudd-O commented 2 years ago

It's a bummer that the bug was closed. The data is there and could easily be used as the track name — there is no reason to use a fallback.