jellyfin-media-player icon indicating copy to clipboard operation
jellyfin-media-player copied to clipboard

Automatic server discovery

Open mijofa opened this issue 2 years ago • 6 comments

Is your feature request related to a problem? Please describe. I'm not actually sure if this should be considered a bug or a feature request, but automatic server discovery doesn't work. So any instance run with a fresh config requires the first user to manually type out the URL of the jellyfin server.

Describe the solution you'd like I'd like to at least see a list of servers to just select one. If only 1 server is discovered then it should probably just pick that one.

Describe alternatives you've considered Alternatively, some way of specifying the Jellyfin URL on the command line would be appreciated. Then I can sort out the "auto discovery" in my own way, was thinking of using SRV records for that anyway.

Additional context Jellyfin supposedly already has an auto-discovery system: https://jellyfin.org/docs/general/networking/index.html I haven't seen anything actually implement that, but I confirmed it worked by running: socat - udp-sendto:[JellyfinServerHostname]:7359,broadcast <<< 'Who is JellyfinServer?' I also tried using Wireshark to monitor network packets while starting up jellyfin-media-player and I didn't see any broadcast or multicast traffic at all.

mijofa avatar Nov 27 '21 00:11 mijofa

I've tried setting "startupurl_desktop" to http://[JellyfinServerHostname]:8096/web/index.html, but it just goes blank right after the loading screen, so I'm guessing I'm doing that wrong.

mijofa avatar Nov 27 '21 01:11 mijofa

Confirming this is a feature request. I have not implemented it.

iwalton3 avatar Nov 27 '21 01:11 iwalton3

If I was at all familiar with C++ I'd be trying to write a patch, but I am not, so I wrote this rather horrible workaround for myself. It does the job, but I do not endorse this for anyone's usage. :laughing:

It's a Python script (depends on python3-plyvel) that creates & writes to QtWebEngine's Local Storage database just enough data for it to preload a single server. So I run this immediately before running jellyfin-media-player for the first time, and it jumps straight to the user list. It will not overwrite the servers already in the local storage, so it's safe to run this every single time. It also doesn't touch the DeviceID key, so it can be run on multiple separate devices without causing conflicts.

/usr/local/bin/set-jellyfin-server.py

mijofa avatar Nov 27 '21 02:11 mijofa

It seems like current stable versions of Jellyfin don't return the published server URLs correctly, see https://github.com/jellyfin/jellyfin/issues/10005

It should be fixed in the next release, but i haven't tried the dev branch to confirm.

In the meantime, getting a proper HTTPS URL will not work from broadcast:

 echo -n 'Who is JellyfinServer?' | socat - udp-datagram:255.255.255.255:7359,broadcast
{"Address":"http://192.168.1.2:8095/media","Id":"REDACTED","Name":"REDACTED","EndpointAddress":null}

selfhoster1312 avatar Nov 04 '23 14:11 selfhoster1312

Unfortunately https://github.com/jellyfin/jellyfin/issues/10005 did not fix the issue. I opened https://github.com/jellyfin/jellyfin/issues/11564 instead.

EDIT: My bad, it looks like we can control the returned URL via jellyfin CLI arg, or environment variable. There is no network.xml setting for this but the bug is fixed apparently.

selfhoster1312 avatar May 12 '24 12:05 selfhoster1312

Hello @iwalton3! Now that the bug has been fixed upstream and the server can be discovered on LAN, can we try to implement this? I'd like to try but i would need guidance if that's not asking for too much... otherwise i'm happy if someone else implements it :)

So apparently the server settings are stored in a levelDB storage in the home directory. I don't understand why use levelDB at all for simple settings, and i don't understand where the server list is loaded in the client but @mijofa mentioned a script to populate the server list with a well-known URL.

It seems like writing a broadcast receiver in Qt is easy, see this example, and there's apparently a qtleveldb library to write to the storage. But we would need to write to the storage before starting the webview, right? Or could we restart it if we ever get a LAN answer? Is there a better/simpler way to do it? Like having a URL fragment in the web client to update the selected server?

Would someone like to do it, or help me do it? Thanks!

selfhoster1312 avatar May 14 '24 14:05 selfhoster1312