fredrikburmester / streamyfin

A Jellyfin client build with Expo
Mozilla Public License 2.0
699 stars 18 forks source link

Option for default language #36

Open PCJones opened 1 month ago

PCJones commented 1 month ago

Describe the solution you'd like An option in the settings for the default audio language track that should be selected if available.

Additional context Currently the default language is not defined or always seems to be English. A lot of German users have dual language files, so it would be great to have the option to select another language as default.

It might be overkill, but a truly great upgrade for this feature that no other client has would be to select multiple preferred languages in descending order or to have the option to select "Original" as preferred language. The use case for this is that often users might want to prefer English/German in general but Japanese for anime. A basic setting to simply chose a default language is more than enough though.

sjorge commented 1 month ago

Yes this would be great, it would also be nice to be able to set this globally and per-library, e.g. one might want different defaults just for their anime library (if they have a separate one)

PCJones commented 1 month ago

Being able to specify this per library might be a solution that could be easier to implement than my "advanced" proposal whilst achieving the same. Good thought!

fredrikburmester commented 3 weeks ago

I'm not sure how to do this Jellyfin wise. Are language codes always the same for audio tracks, etc. More information here would be great. Any ideas of implementation logic would also be great.

sjorge commented 3 weeks ago

I'm not sure how the web client does it (its per user there, I know the value is stored in jellyfin.db somewhere) I'll have a look around in the source later but I'm not sure what to look for.

I did some digging, the web client sets the settings like so:

curl 'https://<domain>/Users/<uiserId>/Configuration' -X POST -H 'Authorization: MediaBrowser Client="Jellyfin Web", Device="Firefox", DeviceId="XXX", Version="10.9.9", Token="XXX"' -H 'Content-Type: application/json' --data-raw '{"AudioLanguagePreference":"jpn","PlayDefaultAudioTrack":false,"SubtitleLanguagePreference":"eng","DisplayMissingEpisodes":false,"GroupedFolders":[],"SubtitleMode":"Default","DisplayCollectionsView":false,"EnableLocalPassword":false,"OrderedViews":[...],"LatestItemsExcludes":[],"MyMediaExcludes":[...],"HidePlayedInLatest":true,"RememberAudioSelections":true,"RememberSubtitleSelections":true,"EnableNextEpisodeAutoPlay":false,"CastReceiverId":"F007D354"}'

Specifically these in the payload (but it looks like you need to send everything even when only chaging one thing:

{
  "AudioLanguagePreference": "jpn",
  "SubtitleLanguagePreference": "eng"
}

These seem to be using the ISO language codes, this seems to end up in jellyfin.db in the users table.

As this is a per user setting, I think it would be OK to be able at least fetch these and use them where applicable.

This is from spying at the requests with web developer tools in firefox but, when navigating to an item it seems it looks up the items and in the MediaStreams section the audio and subtitle tracks use the same language codes as in the preferences, the web client seems to just pre-select those when there is a match, if no match it goes for the one that is flagged as default, or if non is flagged it seems to get the first one listed.

So for the simple version I guess looking up the users preferences and making the same selection before playback would do it. For the nicer per-library option it probably starts as the same, but if there is a library default set we prefer that over the users default... or always prefer the user default and only use the library one if there is none set. Not sure what would be expected.