Repository navigation
Conversation
a8252de to
773b95a
Compare
… 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>
1fbb0d1 to
130b7e4
Compare
edde746
left a comment
There was a problem hiding this comment.
#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-174carries audio from_selectedAudioStreamId, which is only set when a session commits. An audio track picked in the player goes through_onAudioTrackChangedand never updates it, so the reload after a download reverts to the earlier track. The old source-switch path had the same staleness. WithpreserveCurrentTrackSelectionnow on, direct play can carry the live track instead._supportsSubtitleSearchignoresisOfflinePlayback. 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.SubtitleSearchResultis still the Plex DTO: it decodes Plex field names and Jellyfin fills it withid: 0(subtitle_search.dart:72). Jellyfin ignores the Plex-onlydownloadSubtitlearguments, andexistingTrackIds/positiononfindDownloadedSubtitle.as ExternalSubtitleSearchClient(navigation.dart:93,subtitle_search_sheet.dart:107,:188) throws for a client without the interface. Anischeck 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.
|
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:
And the non-blocking ones:
I also merged 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 ! |
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>
69ad39b to
e9d9c3c
Compare
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>
|
@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>
|
Hi @edde746 ! I've merged the latest 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
left a comment
There was a problem hiding this comment.
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 returnssrtfor 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 checkcapabilities.externalSubtitleSearch, unliketrack_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 usesFilm.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.
|
Thanks. On it. About this:
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>
… 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>
|
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:
And the non-blocking ones:
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:
Each commit passes Thanks again ! [Note: PR made with Claude Opus 5.5 and Claude Sonnet 5.5, effort extra] |
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>
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 optionalExternalSubtitleSearchClientinterface, whichPlexClientandJellyfinClientimplement.PlexSubtitleSearchResultbecomesSubtitleSearchResult, inlib/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/AvailableOptionsat 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
Size, excluding comment lines, against
main(GitHub's +2,241 −614 counts comments too):lib/(22 files)Thanks a lot for considering it !
[Note: PR made with Claude Opus 5.5 and Claude Sonnet 5.5, effort high, then extra]