Apply remaining working-tree updates

This commit is contained in:
2026-02-14 00:36:01 -08:00
parent 9b24e09d48
commit 14acb09b89
40 changed files with 1001 additions and 607 deletions

View File

@@ -0,0 +1,45 @@
---
id: TASK-48
title: Add streaming mode integration in subminer using ani-cli stream source
status: To Do
assignee: []
created_date: '2026-02-14 06:01'
updated_date: '2026-02-14 08:19'
labels:
- stream
- ani-cli
- jimaku
dependencies: []
priority: high
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Implement a new streaming mode so SubMiner can resolve and play episodes via ani-cli stream sources instead of existing file/download flow. The mode is enabled with a CLI flag (`-s` / `--stream`) and, when active, should prefer streamed playback and subtitle handling that keeps Japanese (or configured primary) subtitles as the main track. If a stream lacks Japanese subtitle tracks, fetch and inject subtitles from Jimaku and set them as primary subtitles according to SubMiner config.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Add a command-line option `-s`/`--stream` that enables streaming mode and is documented in help/config UX.
- [ ] #2 When streaming mode is enabled, resolve episode/video URLs using existing ani-cli stream selection logic (ported into SubMiner) and route playback to the resolved stream source.
- [ ] #3 If stream metadata contains a Japanese subtitle track, preserve that track as the primary subtitle stream path per current primary-subtitle selection behavior.
- [ ] #4 If no Japanese subtitle track is present in the stream metadata, fetch matching subtitles from Jimaku and load them into playback.
- [ ] #5 When loading Jimaku subtitles, replace/overwrite existing non-Japanese primary subtitle track behavior so the language configured as primary in SubMiner config is used instead.
- [ ] #6 Non-streaming mode continues to follow current behavior when `-s`/`--stream` is not set.
<!-- AC:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Superseded by TASK-51. Streaming via ani-cli in subminer was removed due Cloudflare 403/unreliable source metadata; re-evaluate later if reintroduced behind a feature flag and redesigned resolver/metadata pipeline.
<!-- SECTION:NOTES:END -->
## Definition of Done
<!-- DOD:BEGIN -->
- [ ] #1 CLI accepts both `-s` and `--stream` and enables streaming-specific behavior.
- [ ] #2 Streaming mode resolves streams through migrated ani-cli logic.
- [ ] #3 Japanese subs are preferred from stream metadata when available; Jimaku fallback is used only when absent.
- [ ] #4 Primary subtitle language in config determines which language is treated as default stream subtitle track after fallback.
- [ ] #5 Behavior is verified via test or manual checklist and documented in task notes.
<!-- DOD:END -->

View File

@@ -0,0 +1,33 @@
---
id: TASK-48.1
title: Add streaming CLI flag plumbing and option wiring
status: To Do
assignee: []
created_date: '2026-02-14 06:03'
updated_date: '2026-02-14 08:19'
labels:
- stream
- cli
dependencies: []
parent_task_id: TASK-48
priority: medium
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Add the `-s`/`--stream` option end-to-end in SubMiner CLI and configuration handling, including defaults, help text, parsing/validation, and explicit routing so streaming mode is only enabled when requested.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Introduce `-s` short option and `--stream` long option in CLI parsing without breaking existing flags.
- [ ] #2 When set, the resulting config state reflects streaming mode enabled and is propagated to playback/session startup.
- [ ] #3 When unset, behavior remains identical to current non-streaming flows.
<!-- AC:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Superseded by TASK-51. CLI stream mode work deferred until streaming architecture is revisited.
<!-- SECTION:NOTES:END -->

View File

@@ -0,0 +1,33 @@
---
id: TASK-48.2
title: Port ani-cli stream-resolution logic into SubMiner
status: To Do
assignee: []
created_date: '2026-02-14 06:03'
updated_date: '2026-02-14 08:19'
labels:
- stream
- ani-cli
dependencies: []
parent_task_id: TASK-48
priority: high
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Implement stream URL resolution by porting ani-cli logic for selecting providers/episodes and obtaining playable stream URLs so SubMiner can consume stream sources directly.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Encapsulate stream search/provider selection logic in a dedicated module in SubMiner.
- [ ] #2 Resolve episode query input into a canonical playable stream URL in streaming mode.
- [ ] #3 Preserve existing behavior for non-streaming flow and expose errors when stream resolution fails.
<!-- AC:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Superseded by TASK-51. Stream URL resolution via ani-cli postponed; previous attempt exposed anti-bot/403 fragility and poor title-source reliability.
<!-- SECTION:NOTES:END -->

View File

@@ -0,0 +1,33 @@
---
id: TASK-48.3
title: Implement stream subtitle selection and primary-language precedence
status: To Do
assignee: []
created_date: '2026-02-14 06:03'
updated_date: '2026-02-14 08:19'
labels:
- stream
- subtitles
dependencies: []
parent_task_id: TASK-48
priority: high
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Handle subtitle track selection for stream playback so Japanese (or configured primary language) subtitle behavior is correctly applied when stream metadata includes or omits JP tracks.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Use stream metadata to choose and mark the configured primary language subtitle as active when available.
- [ ] #2 If no matching primary language track exists in stream metadata, keep previous fallback behavior only for non-streaming mode.
- [ ] #3 When no Japanese track exists and config primary is different, explicitly set configured primary as primary track for streaming flow.
<!-- AC:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Superseded by TASK-51. Stream subtitle language precedence in streaming mode deferred with full design revisit.
<!-- SECTION:NOTES:END -->

View File

@@ -0,0 +1,34 @@
---
id: TASK-48.4
title: Add Jimaku subtitle fallback for stream mode
status: To Do
assignee: []
created_date: '2026-02-14 06:03'
updated_date: '2026-02-14 08:19'
labels:
- stream
- jimaku
- subtitles
dependencies: []
parent_task_id: TASK-48
priority: medium
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
When a resolved stream lacks JP/primary-language tracks, fetch subtitles from Jimaku and inject them for playback, overriding non-primary subtitle defaults in streaming mode according to config.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Detect missing primary subtitle from stream metadata and trigger Jimaku lookup for matching episode.
- [ ] #2 Load fetched Jimaku subtitles into playback pipeline and mark them as the primary subtitle track.
- [ ] #3 Fallback is only used in streaming mode and should not alter subtitle behavior outside streaming.
<!-- AC:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Superseded by TASK-51. Jimaku fallback for streams deferred along with entire streaming flow.
<!-- SECTION:NOTES:END -->

View File

@@ -0,0 +1,33 @@
---
id: TASK-48.5
title: Add verification plan/tests for streaming mode behavior
status: To Do
assignee: []
created_date: '2026-02-14 06:03'
updated_date: '2026-02-14 08:19'
labels:
- stream
- qa
dependencies: []
parent_task_id: TASK-48
priority: low
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Create a validation plan or tests for CLI flag behavior, stream resolution, and subtitle precedence/fallback rules so streaming mode changes are measurable and regressions are caught.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 Document/manual checklist covers `-s` and `--stream` invocation and streaming-only behavior.
- [ ] #2 Include cases for (a) stream with JP subtitles, (b) no JP subtitles with Jimaku fallback, (c) primary-language not Japanese.
- [ ] #3 Run or provide reproducible checks to confirm non-streaming behavior unchanged.
<!-- AC:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Superseded by TASK-51. Verification plan moved to deferred reimplementation context.
<!-- SECTION:NOTES:END -->

View File

@@ -0,0 +1,49 @@
---
id: TASK-48.6
title: Wire -s/--stream mode to Ani-cli and Jimaku subtitle fallback
status: To Do
assignee: []
created_date: '2026-02-14 06:06'
updated_date: '2026-02-14 08:19'
labels: []
dependencies: []
references:
- ani-cli/ani-cli
- src/jimaku/utils.ts
- src/core/services/anki-jimaku-service.ts
documentation:
- ani-cli/README.md
- subminer
- src/cli/help.ts
parent_task_id: TASK-48
priority: high
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Implement SubMiner streaming mode end-to-end behind a `-s`/`--stream` flag. In stream mode, use the vendored ani-cli resolution flow to get playable stream URLs instead of local file/YouTube URL handling. If resolved streams do not expose Japanese subtitles, fetch matching subtitles from Jimaku and load them into mpv as the active primary subtitle track, overwriting the current non-primary/non-Japanese default according to subminer primary-subtitle configuration.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 When `subminer -s` is used, resolution should pass a search/query through ani-cli stream logic and play the resolved stream source.
- [ ] #2 If the stream includes a Japanese subtitle track, preserve and select the configured primary subtitle language behavior without Jimaku injection.
- [ ] #3 If no Japanese (or configured primary language) subtitle exists in stream metadata, fetch and inject Jimaku subtitles before playback starts.
- [ ] #4 Loaded Jimaku subtitles should become the selected primary subtitle track, replacing any existing default non-primary subtitle in that context.
- [ ] #5 When `-s` is not passed, non-streaming behavior remains unchanged.
<!-- AC:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Superseded by TASK-51. End-to-end stream wiring to ani-cli is deferred.
<!-- SECTION:NOTES:END -->
## Definition of Done
<!-- DOD:BEGIN -->
- [ ] #1 CLI exposes both `-s` and `--stream` in help/config and validation.
- [ ] #2 Implementation includes a clear fallback path when stream subtitles are absent and Jimaku search/download fails gracefully.
- [ ] #3 Subtitles loading path avoids temp-file leaks; temporary media/subtitle artifacts are cleaned up on exit.
- [ ] #4 At least one verification step (manual or test) confirms stream mode path works for an episode with and without Japanese stream subtitles.
<!-- DOD:END -->

View File

@@ -0,0 +1,30 @@
---
id: TASK-51
title: Revisit Ani-cli stream mode integration later
status: To Do
assignee: []
created_date: '2026-02-14 08:19'
labels:
- someday
- streaming
- ani-cli
- feature-flag
dependencies: []
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Current codebase has removed ani-cli integration and stream-mode from subminer temporarily. Keep a deferred design task to reintroduce streaming mode in a future cycle.
Findings from prior attempts:
- `subminer -s <query>` path relied on `ani-cli` resolving stream URLs, but returned stream URLs that are Cloudflare-protected (`tools.fast4speed.rsvp`) and often returned 403 from mpv/ytdl-hook (generic anti-bot/Forbidden).
- Even after passing `ytdl` extractor args, stream playback via subminer still failed because URL/anti-bot handling differed from direct ani-cli execution context.
- We also observed stream title resolution issues: selected titles from ani-cli menu were unreliable/random and broke downstream Jimaku matching behavior.
- ffsubsync failures were difficult to debug initially due to OSD-only error visibility; logging was added to mpv log path.
- Based on these findings and instability, stream mode should be explicitly deferred rather than partially reintroduced.
Proposal:
- Reintroduce behind a feature flag / future milestone only.
- Re-design around a dedicated stream source resolver with robust URL acquisition and source metadata preservation (query/episode/title) before subtitle sync flows.
<!-- SECTION:DESCRIPTION:END -->

View File

@@ -0,0 +1,47 @@
---
id: TASK-52
title: >-
Consolidate stream-mode/ani-cli work into one deferred streaming integration
ticket
status: To Do
assignee: []
created_date: '2026-02-14 08:21'
labels:
- someday
- streaming
- ani-cli
- feature-flag
- consolidation
dependencies: []
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Replace fragmented streaming-mode items with a single future-oriented task.
Context:
- Previous attempts to support `subminer -s` via ani-cli were removed due instability and blockers.
- Stream URLs resolved through ani-cli often hit Cloudflare anti-bot/403 (`generic:impersonate`) in subminer/mpv/ytdl-hook path.
- URL/title handling from stream selection was inconsistent, breaking robust subtitle discovery/matching.
- Subsync logging/debugging required improvements before deeper stream validation.
- A single cohesive redesign is preferable over piecemeal reintroduction.
Scope (one ticket):
- Reintroduce streaming mode behind a feature flag only.
- Evaluate and redesign stream source resolution architecture (not a direct ani-cli passthrough by default).
- Define robust metadata pipeline so source title/query/episode are reliable for Jimaku/subsync matching.
- Define a single end-to-end flow for stream subtitle source selection + fallback, including explicit failure handling.
- Add verification plan for playback and subtitle matching before implementation.
Notes:
- This ticket supersedes and consolidates the old fragmented streaming tasks:
- TASK-48, TASK-48.1, TASK-48.2, TASK-48.3, TASK-48.4, TASK-48.5, TASK-48.6
- TASK-51
Acceptance Criteria:
- One documented design + implementation plan exists for future reintroduction.
- A feature-flagged streaming mode path is specified with clear boundaries and testability.
- Stream source resolution and subtitle matching rules are deterministic and validated.
- No partial reintroduction until full path is implemented and tested.
<!-- SECTION:DESCRIPTION:END -->