Skip to content

feat(player): offer subtitle search on Jellyfin through its subtitle plugins - #2875

Open
jucor wants to merge 24 commits into
edde746:mainfrom
jucor:jellyfin-subtitle-search
Open

jucor wants to merge 24 commits into
edde746:mainfrom
jucor:jellyfin-subtitle-search

Conversation

@jucor

@jucor jucor commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Hi !

This brings the player's Search Subtitles sheet to Jellyfin, following up on #2015: unlike Emby's, Jellyfin's subtitle search is free, as long as the server has a subtitle plugin loaded, such as the official Open Subtitles one. Same sheet and same download flow as Plex; Plex and Emby are unchanged.

How

Following MediaDeletionPermissionClient's pattern, an optional ExternalSubtitleSearchClient interface, which PlexClient and JellyfinClient implement. PlexSubtitleSearchResult becomes SubtitleSearchResult, in lib/media/, since both backends now return it.

The tile only shows on Jellyfin, for movies and episodes, when the user may manage subtitles (admins always can) and a subtitle fetcher is loaded. Plezy reads that from /Libraries/AvailableOptions at each health check, so admins and other users get the same answer without the admin-only /Plugins.

After a download, Jellyfin renumbers every stream, so the new subtitle is found by its file path, and the reload carries the audio track over by what it is rather than by its old index.

A Jellyfin busy rescanning its libraries can also take longer than the sheet's 15 s to list the new file -- 14 to 16 s here while Bazarr was writing subtitles -- so on Jellyfin the sheet waits up to 30 s. Plex keeps its 15 s.

How I checked it

  • Unit and widget tests for the guard, the search, the download, the renumbering and the reload. Full suite on macOS at 82b4928: 8,534 pass.
  • On the first version of this PR, not re-run since the reviews: Plezy's own client against Jellyfin 10.9, 10.10, 10.11 and 12.3, each with the plugin version it installs: search works for admins and for users with the permission, and is hidden for the others; a downloaded file is found.
  • End to end on my Mac against my Jellyfin 12.3, on the first version and again on 82b4928: I downloaded a subtitle for The Crow (2024) from the sheet, and playback switched to it with the same audio track, although the download had renumbered every stream. On the first version, a home video also hid the tile.

Size, excluding comment lines, against main (GitHub's +2,241 −614 counts comments too):

Added Removed
Hand-written code in lib/ (22 files) 485 196
Tests (13 files) 1,407 253
Generated translation files, regenerated (25 files) 116 114
The one new string, in English and 22 translations 23 0
Total 2,031 563

Thanks a lot for considering it !

[Note: PR made with Claude Opus 5.5 and Claude Sonnet 5.5, effort high, then extra]

@jucor
jucor marked this pull request as ready for review October 29, 2026 01:57
@jucor jucor changed the title feat(player): search subtitles on Jellyfin through its Open Subtitles plugin feat(player): in-playback subtitles search on Jellyfin through its Open Subtitles plugin Oct 29, 2026
@jucor
jucor force-pushed the jellyfin-subtitle-search branch from a8252de to 773b95a Compare October 29, 2026 03:10
… plugin

The player's Search Subtitles sheet, Plex-only until now, also works on
Jellyfin servers that load the official Open Subtitles plugin. Emby
keeps it off: it gates these routes behind Premiere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jucor
jucor force-pushed the jellyfin-subtitle-search branch from 1fbb0d1 to 130b7e4 Compare October 29, 2026 21:34

@edde746 edde746 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2880 and #2874 are merged, and this branch still merges cleanly onto main. Three things need to change before this can land:

1. Alternate versions get the wrong file. Search and download use metadata.id (subtitle_search.dart:61, :100), and the poll reads the media source whose Id == itemId (:128). When a merged alternate version is playing, Jellyfin saves the subtitle next to the primary version's file. The row found on the primary is then applied to a reload that keeps _requestedMediaSourceId, i.e. the alternate's catalog. That reload ends up with another subtitle or none, and the sheet still reports success. Either target the playing source (for merged versions, Jellyfin's MediaSourceId is the alternate item's id) through search, download and polling, or hide the tile while a non-primary source is playing.

2. Backend checks in the player UI. navigation.dart:103 (plex ? 15 : 30), navigation.dart:131 (plex ? .source : .downloaded) and track_controls.dart:233 (Jellyfin item kinds) branch on MediaBackend in widget code. The UI should read these from the client contract instead: the poll timeout, whether stream ids are stable across the rescan, and which item kinds can be searched. ExternalSubtitleSearchClient or ServerCapabilities is the place, so a third implementation doesn't have to edit the player.

3. The first new subtitle path is taken as the download. subtitle_search.dart:116 takes firstOrNull of every path that is new since the download started. If Bazarr, a scan, or another client adds a file in the 30 s window, Plezy applies whichever file sorts first. An unrelated file can also make a failed download look successful. Match the new path against the chosen result (at least its language and format) and decline when several candidates remain.

Non-blocking:

  • playback_reload.dart:173-174 carries audio from _selectedAudioStreamId, which is only set when a session commits. An audio track picked in the player goes through _onAudioTrackChanged and never updates it, so the reload after a download reverts to the earlier track. The old source-switch path had the same staleness. With preserveCurrentTrackSelection now on, direct play can carry the live track instead.
  • _supportsSubtitleSearch ignores isOfflinePlayback. When a downloaded copy is playing, the reload reopens the local file without the new subtitle and the sheet still says it downloaded. Plex has the same gap today.
  • SubtitleSearchResult is still the Plex DTO: it decodes Plex field names and Jellyfin fills it with id: 0 (subtitle_search.dart:72). Jellyfin ignores the Plex-only downloadSubtitle arguments, and existingTrackIds/position on findDownloadedSubtitle.
  • as ExternalSubtitleSearchClient (navigation.dart:93, subtitle_search_sheet.dart:107, :188) throws for a client without the interface. An is check reads better.
  • The title field means a server-side search on Plex and a local filter over release names on Jellyfin. The sheet presents both the same way.

Checked: the touched test files pass on their own and with #2880 and #2874 merged in, and dart analyze lib test is clean. Not checked against a live server.

@jucor

jucor commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks a lot for the thorough review !

All done, one commit per point, on top of the reviewed one so you can take them in turn:

  1. Alternate versions (cf368ca): search, download and polling now use the playing version's own item, through ExternalSubtitleSearchClient.subtitleItemIdFor. Once the download is found, the other versions' rows are refreshed too, since the reload reads the primary item's row cache-first; if the server refuses that refresh, the next poll retries it. I checked on a throwaway Jellyfin 12.3 with two versions of one film: the alternate's media source id is a Movie item of its own, and a subtitle saved for it shows up in the primary's PlaybackInfo for that MediaSourceId.
  2. Backend checks in the player (9d3f15f): the client now declares the poll timeout, whether stream ids survive the rescan, and which item kinds can be searched, so the player no longer names a backend.
  3. First new path (c0833e0): only a new file whose language, format and forced flag match the chosen result counts, and the poll declines when that still leaves more than one. (One wrinkle: from 10.11 Jellyfin reports Greek's language as "Greek, Modern (1453-)" rather than a code, so for such a name the code in the file name decides.)

And the non-blocking ones:

  • audio (44ff7c9): you were right, and it was wider than the download: a pick in the player's audio list never updated the committed source stream that reloads carry, so on Jellyfin the audio also reverted after a quality or subtitle switch. In direct play the pick now commits the source stream it plays (not under a transcode, nor where the engine's tracks don't line up with the source rows). Two small commits on top since: a test that drives that reload through the real player screen (e8cc540), and the same fix for the cycle-audio hotkey and the companion remote, which skipped it (0fb7dc1).
  • offline playback (94aca45): the tile is hidden while a downloaded copy plays, on Plex too.
  • SubtitleSearchResult (8252ce2) is now a plain row: Plex's JSON mapping moved into PlexClient, downloadSubtitle takes the row, and a test pins what Plex sends. findDownloadedSubtitle's existingTrackIds/position stay, documented as serving a server that keeps its stream ids.
  • is checks (33b8a5e).
  • the title field (8b50532) reads "Filter by release name" on Jellyfin, with a filter icon: the plugin names each result after its release.

I also merged main in, as the new string conflicted in the generated i18n files. Each commit passes dart analyze lib test on its own, and the full suite on macOS passes on the branch (8,365 tests).

I force-pushed to fold the review fixes into each point's commit, so each one reads on its own; sorry if you'd already started on the earlier ones.

Thanks again !

jucor and others added 9 commits November 1, 2026 02:22
Bazarr, a scan or another client can add a subtitle file while the player
waits for the download, and the poll took whichever new file sorted first.
It now takes a new file only when its language, format and forced flag
match the chosen result, and declines when that still leaves more than one.
The language is the code Jellyfin reads from the name it saved the file
under, so a file whose name carries no language never matches. From 10.11
Jellyfin keeps a language whose name has a dash (Greek) as that name; the
code in the file name then decides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The player branched on the backend for three things: how long to wait for
a download, whether its stream ids survive the server's rescan, and which
item kinds can be searched. ExternalSubtitleSearchClient now declares all
three, so the player no longer names a backend and a third implementation
needs no player change. Behaviour is unchanged on both servers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It was still Plex's DTO: it decoded Plex field names and Jellyfin filled it
with id 0, while downloadSubtitle took Plex-only arguments Jellyfin ignored.
The class is now a plain row each client maps its wire format onto (Plex's
mapping moves into PlexClient, filling the language from the search as the
sheet used to), and downloadSubtitle takes the chosen row. What Plex sends
is unchanged, pinned by a new test. findDownloadedSubtitle's doc now says
which of its arguments serve a server that keeps its stream ids.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Search, download and polling used the item id, so with a merged alternate
version playing, Jellyfin saved the subtitle next to the primary version's
file and the reload, which keeps the alternate's source, never saw it. The
client now names the item those calls take for the playing media source:
the alternate's own item on Jellyfin (a source without an id stays on the
item), and the item itself on Plex, as before. Once the download is found,
the other versions' rows are refreshed too, since playback reads the
primary item's row cache-first and would otherwise resolve against the old
numbering. The download is forgotten only after that refresh, so one the
server refuses is retried by the next poll.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pick in the player's audio list changed what the engine played but not
the committed source stream, which reloads carry. So on Jellyfin the audio
reverted to the earlier track after a subtitle download, a quality switch
or a subtitle switch, and a source audio list kept ticking the old
row. In direct play the pick now commits the source stream it plays. It
leaves the committed one alone under a transcode, whose engine tracks
describe the output, and where the engine's list does not line up with
the source rows (external audio rows, a single engine track).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On both servers, with an offline copy playing, the download landed on the
server, the reload reopened the local file without it, and the sheet still
reported success. The tile now goes with the other server-side controls
that offline playback already hides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The sheet and the download handler cast the server's client to
ExternalSubtitleSearchClient, which throws for a client without the
interface. They now check with is, and a client without it searches
nothing. The download handler goes through the same lookup as the sheet,
so it also requires the server to still offer subtitle search.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… name

On Plex the field is a title search the server runs; on Jellyfin, whose
search takes no title, it filters the results by the name the sheet shows,
which the Open Subtitles plugin fills with the release name, yet the sheet
presented both the same way. The client now says which it is, and on
Jellyfin the field reads "Filter by release name" (in every locale) with a
filter icon. Plex is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jucor
jucor force-pushed the jellyfin-subtitle-search branch from 69ad39b to e9d9c3c Compare November 1, 2026 02:28
jucor and others added 3 commits November 1, 2026 05:30
The fix for an audio pick reverting on a reload was tested only through
its mapping helper. This test opens a Jellyfin file with three audio
tracks, picks French in the player, reloads for a downloaded subtitle, and
checks the open carries French. It fails with the pick's commit removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cycle-audio hotkey and the companion remote's audio button switch the
engine's track through TrackManager.cycleAudioTrack, which skipped the
screen's handling of a pick: the cycled track neither became the session's
audio preference, which the next episode carries, nor, in direct play, the
source stream reloads carry. So both went back to the earlier track. The
cycle now returns the track it moved to, and the screen records it as it
does a pick from the audio list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The audio-pick reload test copied its setup from the first-frame test:
the per-file environment, the channel mocks, the providers, the route
push, the switch loop and the shutdown. Both now run on a shared
runPlayerScreen in test_helpers, with a FakeStreamClient base for their
Jellyfin fakes. ServerLimitHarness had the same per-file setup line for
line, so it is now an alias of the shared class. What each test checks is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jucor

jucor commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

@edde746 all your points are addressed, one commit each (details in my reply above), plus a few small audio follow-ups on top. Whenever you have a moment for another look, thanks !

(I'd have clicked "re-request review", but GitHub won't let me do it from my side 😅)

PlexClient now implements both MediaDeletionPermissionClient (from main)
and ExternalSubtitleSearchClient. The new pt-PT locale gets the
filterSubtitlesByReleaseName string; generated translations regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jucor

jucor commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Hi @edde746 ! I've merged the latest main into the branch, so it's mergeable again. The conflicts were only the generated i18n files and PlexClient's implements list, plus the new pt-PT locale needing the one string this PR adds. Full suite green on macOS (8,525 pass).

All the points from your review are addressed, one commit each (details in my reply above). Whenever you have a moment for another look, thanks a lot !

@edde746 edde746 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The three points from the last review are addressed: search, download and polling follow the playing version; the player reads the poll timeout, stream-id stability and searchable kinds from the client; and the poll matches language, format and forced, and declines when several files match. Four things still need to change:

1. Download state lives on the shared client. _pendingSubtitleDownloads (subtitle_search.dart:13) is keyed by item, and findDownloadedSubtitle ignores the existingTrackIds/position it is given. The poll keeps running after the sheet closes (already true on main), so: start a download, close the sheet, reopen it and download again for the same item. The first poll reads the second download's entry, applies it and removes the entry; the second sheet then times out and shows an error although the subtitle was applied. Have downloadSubtitle return a handle for that one download (Jellyfin keeps its path snapshot in it, Plex its existing track ids and position) and poll through the handle. That also removes the ignored parameters.

2. The snapshot and the format check can both accept the wrong file.

  • The before-download snapshot comes from fetchItem (subtitle_search.dart:113, :169), which returns null on a 404 or non-JSON body and falls back to the cached row on a transport error (browse.dart:895-911). With an empty or stale snapshot, a same-language file that was already there counts as new, and the sheet reports success. If the snapshot can't be read, fail the download instead of polling.
  • Format equality goes through CodecUtils.getSubtitleExtension (:134, :151), which returns srt for null and for any codec it doesn't know (codec_utils.dart:11, :36). A failed SRT download plus another new same-language file in an unknown format (.smi) matches. Jellyfin saves the file as {name}.{lang}[.forced].{format}, so comparing the new path's extension with the requested format is exact.

3. Typing in the title field re-runs the remote search on Jellyfin. Each 500 ms pause (subtitle_search_sheet.dart:136) calls /RemoteSearch/Subtitles again (subtitle_search.dart:80), which the plugin forwards to OpenSubtitles, and only then filters locally. Results already on screen are replaced by a spinner and can turn into an error. When subtitleTitleFiltersByReleaseName is true, filter the rows already loaded.

4. An audio pick can commit the wrong source stream. sourceAudioStreamIdForPick (video_player_screen.dart:341) maps the pick through playingSourceAudioTrack, which matches by position first (track_selection_service.dart:562). Nothing checks that the engine lists as many audio tracks as the source has rows; when the counts differ, the wrong id is committed and sent as the explicit audio stream on the next quality switch, on Plex and Jellyfin. Commit only when the counts match.

Non-blocking:

  • The probe accepts only a fetcher named Open Subtitles (subtitle_search.dart:7, :48), from the server-wide list. The search route serves any subtitle provider, so a server with only another provider never gets the tile, while a library that disables the fetcher, or a plugin without credentials, shows the tile and every search comes back empty. Accepting any loaded fetcher matches what the route supports.
  • After a download, audio carries by its properties (playback_reload.dart:173-175, :237-239). Two identically tagged tracks (e.g. two English AAC stereo) tie, and the reload falls back to the server default. The rescan only inserts subtitle streams, so the row's position among the audio rows survives it.
  • PlaybackSubtitleResolver.preferredTrackForSource (playback_subtitle_resolver.dart:344) only has test callers now.
  • The sheet's _searchClient() (subtitle_search_sheet.dart:184-187) doesn't check capabilities.externalSubtitleSearch, unlike track_controls.dart:229, so Emby is kept out only at the tile.
  • The Greek fallback looks for .el. in the file name (subtitle_search.dart:144), and the test uses Film.el.srt. If Jellyfin names the file with the provider's three-letter code, it never matches. Not checked against a server.
  • player_screen_harness.dart:182: when the body throws, shutdown and unmount are skipped.

Already on main, now with a 30 s window on Jellyfin: closing the sheet doesn't stop the poll, so the reload happens later with no feedback; and applied means the video reopened, not that the new subtitle loaded.

Checked at 2873809: dart analyze lib test is clean and the touched test files pass. Not checked against a server with a subtitle fetcher.

@jucor

jucor commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks. On it.

About this:

"Already on main, now with a 30 s windown on Jellyfin"

Do you prefer I fix them in this PR, or that I open separate PRs once this one lands? If no answer, I'll default to separate PRs once this one lands, for separation of concern.

Jellyfin kept the before-download snapshot in a map keyed by item, so a
second download of the same item (sheet closed, poll still running,
sheet reopened) overwrote the first one's entry: the first poll applied
the second download and removed the entry, and the second sheet then
timed out although its subtitle was applied.

downloadSubtitle now returns a SubtitleDownload, a function that polls
against that download's own snapshot: Jellyfin's paths, or Plex's track
ids and position. findDownloadedSubtitle is gone. The controls make the
request, since they hold the ids and position, so downloadSubtitle takes
them; Jellyfin does not need them. A newer download on the same controls
stops the older poll: two same-language downloads would otherwise both
take a file that lands after both requests, and reload twice. It counts
from the request, so a newer download that fails stops it too.

When the controls can't apply a download (the item changed under an
open sheet, the controls are gone), nothing is requested and the sheet
says the download failed, as when Plex doesn't confirm one. Plex now
polls even if the sheet closes while its request is in flight, and
reads the position once, at the download, instead of at each poll.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jucor and others added 8 commits November 24, 2026 23:13
… the format by extension

The before-download snapshot came through fetchItem, which answers null
on a 404 or a non-JSON body and the cached row on a transport error, and
the poll read through it too. With an empty or stale listing, a
same-language file already there counted as new. Both now read the item
straight from the server, require a non-empty MediaSources, and still
rewrite the row playback reads. The download fails when its snapshot
can't be read; a poll that can't read the item is retried.

The format check went through CodecUtils.getSubtitleExtension, which
maps unknown codecs to srt, so a new .smi file matched an SRT download.
Jellyfin saves the file as {name}.{lang}[.forced][.sdh].{format}, so the
new path's extension is compared with the requested format instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hing again

Each 500 ms pause in the title field re-ran /RemoteSearch/Subtitles,
which the plugin forwards to OpenSubtitles, only to filter by name
afterwards: rows on screen turned into a spinner and could turn into an
error. Where the client filters by release name, the sheet now filters
the rows it already loaded as the user types, and no longer sends the
title; the client no longer filters. With rows loaded, Enter only moves
to them; it still searches to retry a failed search, or while one is
running (as before), so focus moves once the rows arrive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k per source row

sourceAudioStreamIdForPick maps the pick through playingSourceAudioTrack,
which matches by position first, and only declined a single engine
track. When the engine lists a different number of audio tracks than
the source has rows, a wrong id was committed (an engine track with no
row made a French pick commit the English row) and sent as the explicit
audio stream on the next quality switch. It now commits only when the
counts match; otherwise the committed stream stays as it was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The probe accepted only a fetcher named Open Subtitles, but the search
route serves whichever subtitle provider the server has loaded, so a
server with only another provider never got the tile. The probe now
accepts any loaded fetcher, and asks for those of films and series
alike rather than films only, since the tile also serves episodes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only tests called it once the reload stopped using it. The three
resolver tests that built their preferred track with it now build it
with subtitleTrackForSource, as the player does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rs it

The sheet took any ExternalSubtitleSearchClient as its search client,
without the capabilities.externalSubtitleSearch check the track controls
make, so only the tile kept Emby, or a Jellyfin user without subtitle
search, from searching. The sheet now makes the same check. The
Jellyfin sheet tests probe their client first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…throws

runPlayerScreen skipped the video shutdown and the unmount when the
body threw. They now run in a finally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a downloaded subtitle's rescan may have renumbered every stream
(Jellyfin), the reload carried the committed audio row by language,
codec and channels only. Two identically tagged tracks, such as two
English AAC stereo, tied there, and the reload fell back to the
server's default track.

A subtitle rescan keeps the audio rows' order, so the reload now also
passes the row's position as preferredAudioOrdinal. Jellyfin still
matches by meaning first, and uses the position only when that match
ties, taking the row there if it matches. Plex keeps stream ids across
a download and never sets it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jucor

jucor commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks a lot for this second careful pass @edde746 !

All four are done, one commit each on top of 2873809, so you can take them in turn:

  1. One handle per download (500d4f4): downloadSubtitle now returns a SubtitleDownload, a function the controls poll for that download alone. Jellyfin's path snapshot lives in it, and so do Plex's track ids and position, so findDownloadedSubtitle is gone. A newer download also stops the older poll, so a same-language file that lands after both requests is applied once, not twice. If the item changes under an open sheet, nothing is requested and the sheet says the download failed.
  2. Snapshot and format (37b9d7a): the snapshot and the poll both read the item straight from the server and require at least one media source, with no cached fallback, and still refresh the row playback reads. The download fails when its snapshot can't be read. The new file's extension is compared with the requested format.
  3. Title filter (c6921dc): on Jellyfin the field filters the rows already loaded, and the title is no longer sent. With rows loaded, Enter only moves to them; it still searches to retry a failed search, or while one is running, as before. Plex is unchanged.
  4. Audio pick (edbf224): it's committed only when the engine lists as many audio tracks as the source has rows. When they differ, the committed stream stays as it was, so the next quality switch reopens that one rather than a wrong one.

And the non-blocking ones:

  • Any fetcher (e07c5b6): the probe accepts any loaded subtitle fetcher, for films and series alike. On your library-disabled case, from Jellyfin's source (10.11.11): the manual search (SubtitleController.cs#L133) builds a request whose defaults search every provider with no disabled fetchers (SubtitleSearchRequest.cs#L14-L20), so the library's list never applies (SubtitleManager.cs#L79-L80) and that case doesn't arise.
  • Audio by position (bd8f153): the reload also carries the row's position. Jellyfin still matches by language, codec and channels first, and uses the position only when that match ties, taking the row there if it matches.
  • preferredTrackForSource is gone (8295f54).
  • The sheet checks the capability (bfbebbf), so Emby is kept out there too.
  • Greek: I checked the source rather than a server. The plugin builds each result's id as srt-{language}-{fileId} from the language the client searched with (plugin), returns that language on download, and TrySaveSubtitle names the file {name}.{language}[.forced][.sdh].{format} (server, 10.11.11). So a search in el gives Film.el.srt, and the .el. fallback holds. (On Jellyfin's master Greek is now reported as ell, which the language check already accepts.)
  • Harness (fdff654): shutdown and unmount now run in a finally.

Updated the description to match, so it's worth a second look: a subtitle fetcher of any kind, not only Open Subtitles (the title too); the suite count, 8,534 at 82b4928; the Jellyfin-version runs marked as done on the first version, not re-run since, and the end-to-end run redone on 82b4928; the #2880 paragraph dropped now it's merged; and the AI note now names every model used.

Limits:

  1. New in this PR: downloadSubtitle still takes position, which Jellyfin doesn't read: only the controls know which file of a stacked Plex item plays. existingTrackIds is gone (82b4928): Plex now reads its subtitle ids straight from its own server before the download, as Jellyfin does, instead of taking the player's. That costs one more request to the Plex server per download, which I took to keep both backends on the same contract; the download already polls the server every 2 s, up to 7 times on Plex, so one more is small. It also stops a subtitle added since playback started (by Bazarr, say) from being taken for the download. Plex's server isn't open source, so I haven't checked how it attaches a download to a stacked item; if it lands where the poll can see it without the position, position could go too -- happy to follow up.
  2. New in this PR on Jellyfin, pre-existing on main on Plex: the two backends differ in what counts as the download. On Jellyfin only a new file matching the chosen language, format and forced flag counts, and the poll declines when several match, as you asked in the first review; so two same-language downloads of one item can't be told apart once both have landed, and the sheet says the download may have failed. On Plex the poll still takes the first new external track, whatever its language. Happy to add the same matching and declining to Plex if you'd like. Also new: a second download that fails stops the first one's poll.
  3. New in this PR: with no account set in the plugin, its login throws (OpenSubtitleDownloader.cs#L383-L386) and Jellyfin logs it and returns no rows (SubtitleManager.cs#L124-L128), shown as "No subtitles found". When its login fails or its daily download quota is spent, a manual search still runs (#L71-L89: only automated tasks stop) but the download throws (#L242-L267), Jellyfin answers 204 anyway (SubtitleController.cs#L158-L170), and after 30 s the sheet says it may have failed. Plezy can't tell these apart; an admin sees the reason in Jellyfin's log. No fix I know of on the client side.
  4. Pre-existing on main, now narrower: on main an audio pick in the player never commits its source stream, so a reload reopens the stream committed before the pick. This PR commits it, except when the engine and the source list different numbers of audio tracks, as Plezy then can't tell which source track was picked. The progress report to the server (playback_progress_tracker.dart:806) matches the engine's track to a source track by position without that check, so it can report the wrong one -- happy to add the same check to the progress tracker in a follow-up.
  5. Pre-existing on main: closing the sheet doesn't stop the poll, and "applied" means the video reopened, not that the subtitle loaded; on Jellyfin the poll now runs up to 30 s. I've opened draft fix(player): report a subtitle download after its sheet closes, and count it applied only once selected #3159 for both, built on this branch, to be rebased onto main once this one lands -- happy to fold it in here instead if you'd rather.
  6. Pre-existing on main: on a Plex item with several versions, the poll reads the first playable version (getVideoPlaybackData's default mediaIndex), not necessarily the one playing, so a download attached to another version may never be found, and the sheet then says it may have failed. Plex's server isn't open source, so where it attaches a download on such an item is untested; passing the playing version to the poll would cover it -- happy to follow up.

Each commit passes dart analyze lib test and the format check on its own, and the full suite passes on macOS (8,534 tests).

Thanks again !

[Note: PR made with Claude Opus 5.5 and Claude Sonnet 5.5, effort extra]

@jucor
jucor requested a review from edde746 November 25, 2026 08:45
@jucor jucor changed the title feat(player): in-playback subtitles search on Jellyfin through its Open Subtitles plugin feat(player): in-playback subtitle search on Jellyfin through its subtitle plugins Nov 25, 2026
@jucor jucor changed the title feat(player): in-playback subtitle search on Jellyfin through its subtitle plugins feat(player): offer subtitle search on Jellyfin through its subtitle plugins Nov 25, 2026
@jucor
jucor marked this pull request as draft November 25, 2026 10:12
@jucor
jucor marked this pull request as ready for review November 25, 2026 10:20
downloadSubtitle took the player's subtitle ids for Plex, which Jellyfin
does not read. Plex now reads what its server lists before the request,
straight from the server as Jellyfin does, for one more request to the
Plex server per download, so existingTrackIds goes. position stays: only
the controls know which file of a stacked item plays.

What a Plex user may notice:
- A subtitle added since playback started (by Bazarr, say) is no longer
  taken for the download, nor an external one the player leaves out of
  its list, nor one on another version than the one the poll reads: the
  snapshot asks what the poll asks (checkFiles included), so on a network
  read both pick the same version and file.
- If that listing can't be read, no download is requested and the sheet
  says the download failed, as for a failed request; an item listing no
  file says so at once instead of timing out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

2 participants