Skip to content

Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.

refactor(playback): keep explicit subtitle selection popup on stream playback

Samir Hossains20063300c2e9
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 56fae89..ca08c1e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,10 +3,6 @@
## [Unreleased]
### Added
-- **Preferred subtitle auto-selection**: Added `preferred_subtitle_language` (default `"English"`)
- and `auto_load_subtitles` (default `true`) configuration options. When playback resolves,
- matching subtitle tracks are automatically attached and the player launches immediately,
- bypassing the repetitive subtitle picker popup during binge-watching.
- **1-Key direct watch history resume (`Space` / `P`)**: Pressing `Space` or `P` on any item in
`/history` immediately launches direct playback for the recorded season and episode without
manual Details navigation. Opening Details from history (`Enter`) pre-seeds selection to the
diff --git a/docs/config.md b/docs/config.md
index 550fad8..048d618 100644
--- a/docs/config.md
+++ b/docs/config.md
@@ -17,8 +17,6 @@ macOS `~/Library/Application Support/moviebox-tui`, Linux `~/.config/moviebox-tu
| `tv_enabled` | bool | Enable TV Mode navigation in bottom dock (`/enable-tv`, `/disable-tv`). |
| `addons_enabled` | bool | Enable Addon Mode navigation in bottom dock (`/enable-addons`, `/disable-addons`). |
| `default_player` | string or null | Preferred player: `mpv`, `iina`, `vlc`, `android`; absent/null until you choose one from the in-app picker. |
-| `preferred_subtitle_language` | string or null | Preferred subtitle language for auto-selection (default `"English"`; case-insensitive matching). |
-| `auto_load_subtitles` | bool | Automatically load and attach matching preferred subtitles without opening the picker modal (default `true`). |
| `download_dir` | string or null | Custom directory for video and subtitle downloads (null uses OS default). |
## Other persisted files
diff --git a/src/config.rs b/src/config.rs
index 092ef29..199d628 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -18,8 +18,6 @@ pub struct Config {
pub addons_enabled: bool,
pub default_player: Option<String>,
pub download_dir: Option<String>,
- pub preferred_subtitle_language: Option<String>,
- pub auto_load_subtitles: bool,
}
impl Default for Config {
fn default() -> Self {
@@ -35,8 +33,6 @@ impl Default for Config {
addons_enabled: false,
default_player: None,
download_dir: None,
- preferred_subtitle_language: Some("English".to_string()),
- auto_load_subtitles: true,
}
}
}
@@ -161,18 +157,11 @@ mod tests {
#[test]
fn config_defaults_and_serde() {
let config = Config::default();
- assert_eq!(
- config.preferred_subtitle_language.as_deref(),
- Some("English")
- );
- assert!(config.auto_load_subtitles);
+ assert!(config.auto_update);
+ assert_eq!(config.active_provider, ProviderKind::MovieBox);
let json = serde_json::to_string(&config).expect("serialize");
let deserialized: Config = serde_json::from_str(&json).expect("deserialize");
- assert_eq!(
- deserialized.preferred_subtitle_language,
- config.preferred_subtitle_language
- );
- assert_eq!(deserialized.auto_load_subtitles, config.auto_load_subtitles);
+ assert_eq!(deserialized.active_mode, config.active_mode);
}
}
diff --git a/src/tui/app/mod.rs b/src/tui/app/mod.rs
index 39c2801..948867c 100644
--- a/src/tui/app/mod.rs
+++ b/src/tui/app/mod.rs
@@ -77,8 +77,6 @@ impl App {
state.active_theme_kind = config.active_theme;
state.default_player = config.default_player;
state.download_dir = config.download_dir.map(std::path::PathBuf::from);
- state.preferred_subtitle_language = config.preferred_subtitle_language;
- state.auto_load_subtitles = config.auto_load_subtitles;
state.installed_addons = crate::config::load_addons();
let env_theme = std::env::var("MOVIEBOX_THEME")
@@ -170,8 +168,6 @@ impl App {
.download_dir
.as_ref()
.map(|p| p.to_string_lossy().to_string()),
- preferred_subtitle_language: self.state.preferred_subtitle_language.clone(),
- auto_load_subtitles: self.state.auto_load_subtitles,
};
crate::tui::config::save(&config);
}
diff --git a/src/tui/app/playback.rs b/src/tui/app/playback.rs
index ba56fd6..265db7e 100644
--- a/src/tui/app/playback.rs
+++ b/src/tui/app/playback.rs
@@ -514,26 +514,6 @@ impl App {
self.state.is_resolving_playback = false;
let options = crate::tui::state::caption_options(&ext_captions);
- if self.state.auto_load_subtitles {
- if let Some(preferred) = &self.state.preferred_subtitle_language {
- let pref_lower = preferred.to_lowercase();
- if let Some((_, sub_url)) = options.iter().find(|(name, url)| {
- !url.is_empty() && name.to_lowercase().contains(&pref_lower)
- }) {
- if open_with {
- self.action_sender
- .send(Action::ShowPlayerPicker(link, Some(sub_url.clone())))
- .ok();
- } else {
- self.action_sender
- .send(Action::LaunchMpv(link, Some(sub_url.clone())))
- .ok();
- }
- return None;
- }
- }
- }
-
if options.len() > 1 {
self.state.show_help = false;
self.state.player_picker_popup = false;
@@ -744,41 +724,8 @@ mod tests {
}
#[tokio::test]
- async fn auto_select_matching_preferred_subtitle() {
- let mut app = crate::tui::app::App::new();
- app.state.auto_load_subtitles = true;
- app.state.preferred_subtitle_language = Some("English".to_string());
-
- let ext_captions = serde_json::json!({
- "extCaptions": [
- { "lanName": "Spanish", "url": "https://example.com/es.srt" },
- { "lanName": "English (Full)", "url": "https://example.com/en.srt" }
- ]
- });
-
- app.handle_playback(crate::tui::action::Action::ShowSubtitlePopup(
- "https://example.com/video.mp4".to_string(),
- ext_captions,
- false,
- ))
- .await;
-
- assert!(!app.state.subtitle_popup);
- let action = app.action_receiver.recv().await;
- assert!(matches!(
- action,
- Some(crate::tui::action::Action::LaunchMpv(
- link,
- Some(sub)
- )) if link == "https://example.com/video.mp4" && sub == "https://example.com/en.srt"
- ));
- }
-
- #[tokio::test]
- async fn show_popup_when_auto_load_subtitles_disabled_or_no_match() {
+ async fn show_popup_when_subtitles_available() {
let mut app = crate::tui::app::App::new();
- app.state.auto_load_subtitles = false;
- app.state.preferred_subtitle_language = Some("English".to_string());
let ext_captions = serde_json::json!({
"extCaptions": [
diff --git a/src/tui/state.rs b/src/tui/state.rs
index acfe785..8299e34 100644
--- a/src/tui/state.rs
+++ b/src/tui/state.rs
@@ -189,8 +189,6 @@ pub struct AppState {
pub subtitle_list_state: ListState,
pub pending_play_link: Option<String>,
pub pending_open_with: bool,
- pub preferred_subtitle_language: Option<String>,
- pub auto_load_subtitles: bool,
pub basic_terminal: bool,
pub bdix_enabled: bool,
pub streaming_enabled: bool,
@@ -346,8 +344,6 @@ impl Default for AppState {
subtitle_list_state: ListState::default(),
pending_play_link: None,
pending_open_with: false,
- preferred_subtitle_language: Some("English".to_string()),
- auto_load_subtitles: true,
bdix_enabled: false,
streaming_enabled: true,
is_tv_mode: false,