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

Music assistant does not report - user or device when streaming from Jellyfin #3514

Open
1 task done
olterman opened this issue Jan 29, 2025 · 9 comments
Open
1 task done

Comments

@olterman
Copy link

What version of Music Assistant has the issue?

2.3.6

Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?

  • Yes

The problem

When playing music from Jellyfin, Music Assistant sends a direct transcode request of the API but does not give device or user in the UniversalAudioController API call, therefore the playcount, song etc cannot be seen in JellyfinLogs

2025-01-29 11:59:58.529 +00:00] [INF] [42] Jellyfin.Api.Helpers.MediaInfoHelper: User policy for "homeassistant". EnableAudioPlaybackTranscoding: True
[2025-01-29 12:03:13.701 +00:00] [INF] [50] Jellyfin.Api.Controllers.UniversalAudioController: GetPostedPlaybackInfo profile: DeviceProfile { Name: null, Id: null, MaxStreamingBitrate: 8000000, MaxStaticBitrate: 8000000, MusicStreamingTranscodingBitrate: 128000, MaxStaticMusicBitrate: 8000000, DirectPlayProfiles: [DirectPlayProfile { Container: "ogg", AudioCodec: null, VideoCodec: null, Type: Audio }, DirectPlayProfile { Container: "flac", AudioCodec: null, VideoCodec: null, Type: Audio }, DirectPlayProfile { Container: "mp3", AudioCodec: null, VideoCodec: null, Type: Audio }, DirectPlayProfile { Container: "aac", AudioCodec: null, VideoCodec: null, Type: Audio }, DirectPlayProfile { Container: "mpeg", AudioCodec: null, VideoCodec: null, Type: Audio }, DirectPlayProfile { Container: "alac", AudioCodec: null, VideoCodec: null, Type: Audio }, DirectPlayProfile { Container: "wav", AudioCodec: null, VideoCodec: null, Type: Audio }, DirectPlayProfile { Container: "aiff", AudioCodec: null, VideoCodec: null, Type: Audio }, DirectPlayProfile { Container: "wma", AudioCodec: null, VideoCodec: null, Type: Audio }, DirectPlayProfile { Container: "m4a", AudioCodec: null, VideoCodec: null, Type: Audio }, DirectPlayProfile { Container: "m4b", AudioCodec: null, VideoCodec: null, Type: Audio }, DirectPlayProfile { Container: "dsf", AudioCodec: null, VideoCodec: null, Type: Audio }, DirectPlayProfile { Container: "opus", AudioCodec: null, VideoCodec: null, Type: Audio }, DirectPlayProfile { Container: "wv", AudioCodec: null, VideoCodec: null, Type: Audio }], TranscodingProfiles: [TranscodingProfile { Container: "mp3", Type: Audio, VideoCodec: "", AudioCodec: "mp3", Protocol: http, EstimateContentLength: False, EnableMpegtsM2TsMode: False, TranscodeSeekInfo: Auto, CopyTimestamps: False, Context: Streaming, EnableSubtitlesInManifest: False, MaxAudioChannels: null, MinSegments: 0, SegmentLength: 0, BreakOnNonKeyFrames: False, Conditions: [], EnableAudioVbrEncoding: True }], ContainerProfiles: [], CodecProfiles: [], SubtitleProfiles: [] }

How to reproduce

Play any song or playlist from Jellyfin

Music Providers

Jellyfin

Player Providers

n.a.

Full log output

d5369777_music_assistant_2025-01-29T12-44-31.959Z.log

Additional information

I think this belongs here ... unless it's an issue of the Jellyfin api, however other apps accessing the api does result in logging ...

What version of Home Assistant Core are your running

2025.1.4

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Linux

@Jc2k
Copy link

Jc2k commented Jan 29, 2025

It does include both. Here's an example of the audio url it streams from on my prod instance which is running 2.3.6:

https://myinstance/Audio/95d4876bee5c5958b82aea3cdbe290f1/universal?UserId=8e0d18ecb611428a98169f5e29cd7108&DeviceId=cf49e1f6-bdd8-44d2-b854-0dcff238485b&MaxStreamingBitrate=140000000&api_key=xxxx

You can see the URL's your instance is generating by going to a track in your MA and expanding the "Provider details" section. The URL it generates is there.

Note that it currently uses UserId and DeviceId, exactly the same as the official python client here: https://github.com/jellyfin/jellyfin-apiclient-python/blob/master/jellyfin_apiclient_python/api.py#L199. On the beta release we have switched to 'userId' and 'deviceId' which matches the API docs. I'd be interested to know if that changes anything?

@Jc2k
Copy link

Jc2k commented Jan 29, 2025

Note that we don't currently hit /Sessions/Playing, /Sessions/Playing/Progress or /Sessions/Playing/Stopped which are what drive the now playing widgets in the admin dashboard (AIUI). Thats expected and won't change in the near future.

@OzGav
Copy link
Contributor

OzGav commented Jan 31, 2025

@olterman please advise if the info above resolves your query

@DefenestratingWizard
Copy link

For posterity, May I ask why this is expected to not change in the future? Is this a deliberate design decision? If so what is the reasoning?

@Jc2k
Copy link

Jc2k commented Jan 31, 2025

I said "near" future.

@olterman
Copy link
Author

Yes this answers the question, as in this is not a provided feature. Some users like to just be able to play music from their jellyfin server while some would prefer to pull stats from the server as well, and lets face it most homeassistant users would like a sensor with stats. I guess it should then be added to feature requests.

@DefenestratingWizard
Copy link

DefenestratingWizard commented Jan 31, 2025

Sorry, I didn't mean to come off aggressive. Just wanted to know if it was that way by specific design intentions or its just not implemented yet and could be by someone in the future (but probably not soon). It seems it's the second one. Thanks for the response

@Jc2k
Copy link

Jc2k commented Jan 31, 2025

Sorry, I didn't mean to come off aggressive. Just wanted to know if it was that way by specific design intentions or its just not implemented yet and could be by someone in the future (but probably not soon). It seems it's the second one. Thanks for the response

Work to investigate those APIs hasn't happened yet. So while it might be the second one, there might be architectural issues. So might not be possible.

Right now we log in as a device. The APIs I mention start a "play session" that is linked to a device. Does Jellyfin understand multiple play sessions linked to a single device (which for all the apps I know of, that wouldn't make any sense), or do we have to maintain play sessions per play queue (login and get an api key and device id for each queue)? That's not game over, but would probably be annoying to write.

It's also not clear from the docs I've seen what is the least amount of information you can provide to those APIs is. As an example, the web client sends the current play queue to Jellyfin. Obviously we can't do that, the next track could be on Spotify or on a local file system.

@Jc2k
Copy link

Jc2k commented Jan 31, 2025

Yes this answers the question, as in this is not a provided feature. Some users like to just be able to play music from their jellyfin server while some would prefer to pull stats from the server as well, and lets face it most homeassistant users would like a sensor with stats. I guess it should then be added to feature requests.

Not against an FR, but I think what you want is a small pebble on a much larger beach and the FR needs to capture information about the beach (the full surface of Jellyfin play sessions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants