Skip to content

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

fix(tui): surface exact root-cause diagnostics in player, download, and provider notifications

Samir Hossains7dad08635cef
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1103380..5a49f2c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,11 +9,11 @@
- Pre-downloaded subtitles locally for `mpv` with remote URL fallback, appended an 8-char URL hash to subtitle filenames to prevent cross-language overwrites, and sanitized commas in `--script-opts`.
- Mounted `xdg-cache/moviebox-tui:ro`, `xdg-data/moviebox-tui`, and `/tmp:ro` in `flatpak run` while preserving custom user Flatpak flags so sandboxed `mpv` and `VLC` can read subtitles and write watch progress.
- Served Termux private-storage subtitles over the local `StreamRelay` `/sub/` loopback endpoint when Android shared storage is unavailable, and restricted startup subtitle cleanup to internal cache/temp folders.
- - Enforced UTF-8 character boundaries when truncating player error logs.
+ - Parsed player `stderr` and exit diagnostics to surface exact failure reasons (`HTTP 403`, `HTTP 404`, `HTTP 410`, timeout, connection refused) instead of vague guesses.
- **StreamRelay Proxy & Downloader**:
- Forwarded `User-Agent` and `Referer` while isolating stream cookies (`Cookie: Edge-Cache-Cookie=...`) to same-host requests across `StreamRelay`, subtitle pre-downloads, and media downloads, preventing HTTP 403 CDN rejections.
- Capped `.m4s` segment chunk fetching in `StreamRelay` to batches of 16 concurrent `Range` requests and enforced `http://` / `https://` scheme validation on `/proxy?url=` routes.
- - Guarded `yt-dlp` progress parsing to match `"at"` strictly after `"of"`, preventing slice panics on out-of-order status lines.
+ - Reported exact subtitle and DASH download errors (HTTP status, timeout, missing `yt-dlp` vs `ffmpeg`) and guarded `yt-dlp` progress parsing against out-of-order status tokens.
- **Providers & Disk Cache**:
- Removed the broad `"notice"` substring filter in MovieBox stream adaptation while keeping `/notice.mp4` and known deprecation hashes, restoring streams for titles like *Red Notice* and *Burn Notice*.
- Required a leading `'S'` prefix in 4KHDHub season count parsing so release years after `"Score"` are not parsed as thousands of seasons.
@@ -25,6 +25,7 @@
- Processed active Picker and Subtitle popups before the background loading guard on `Enter`, cleared queued season downloads when cancelling the download subtitle prompt or on stream failure, and reset TV input focus on overlay dismissal.
- Enabled `/browse` for Stremio Addons, skipped search pagination on active addon catalogs, and clamped initial cursor selection in empty TV and Addon manager modals.
- Synchronized `Home` and `Details` mouse hitboxes with the 3-row download gauge, narrow `< 85` col selector panes, compact `< 76` col bottom bar buttons, non-Stream footer `[Enter] Select` actions, and outside-click theme preview revert.
+ - Shortened toast notifications to show filenames instead of full paths and removed duplicate status-bar/toast alerts on compact terminals.
## [0.1.25] - 2026-09-27
diff --git a/src/download.rs b/src/download.rs
index 7020c36..ccdd554 100644
--- a/src/download.rs
+++ b/src/download.rs
@@ -136,6 +136,9 @@ impl DownloadError {
}
}
Self::File(error) => format!("File write error: {}.", error.kind()),
+ Self::InvalidRange(reason) if reason.contains("timeout") => {
+ "Connection timed out.".to_string()
+ }
Self::InvalidRange(_) => "Server returned invalid partial response.".to_string(),
Self::Incomplete {
downloaded,
diff --git a/src/providers/fourkhdhub/client.rs b/src/providers/fourkhdhub/client.rs
index 6d1773e..a93dd46 100644
--- a/src/providers/fourkhdhub/client.rs
+++ b/src/providers/fourkhdhub/client.rs
@@ -21,10 +21,35 @@ pub enum FourKHdHubError {
impl FourKHdHubError {
pub fn user_message(&self) -> &'static str {
match self {
- Self::Network(_) => "Cannot reach 4KHDHub.",
+ Self::Network(err) => {
+ if err.is_timeout() {
+ "4KHDHub timed out."
+ } else if let Some(status) = err.status() {
+ match status.as_u16() {
+ 403 => "4KHDHub blocked (HTTP 403).",
+ 404 => "4KHDHub page not found (HTTP 404).",
+ 429 => "4KHDHub rate limited (HTTP 429).",
+ 500..=599 => "4KHDHub server error.",
+ _ => "Cannot reach 4KHDHub.",
+ }
+ } else {
+ "Cannot reach 4KHDHub."
+ }
+ }
Self::InvalidUrl(_) => "Invalid 4KHDHub URL.",
Self::Parse(_) => "4KHDHub parse error.",
- Self::NoPlayableMirror(_) => "Mirrors dead or expired.",
+ Self::NoPlayableMirror(reason) => {
+ let lower = reason.to_ascii_lowercase();
+ if lower.contains("timed out") || lower.contains("timeout") {
+ "4KHDHub mirror probe timed out."
+ } else if lower.contains("quota") {
+ "4KHDHub mirror quota exceeded."
+ } else if lower.contains("expired") {
+ "4KHDHub mirror link expired."
+ } else {
+ "No working 4KHDHub mirrors found."
+ }
+ }
}
}
}
@@ -148,7 +173,7 @@ impl FourKHdHubClient {
if unique_candidates.is_empty() {
return Err(FourKHdHubError::NoPlayableMirror(
- "Mirrors for this release are dead or expired on 4KHDHub. Select another release (e.g. 1080p) or press Ctrl+P for MovieBox.".into(),
+ "no working mirror links extracted".into(),
));
}
@@ -219,7 +244,7 @@ impl FourKHdHubClient {
release.filename
);
Err(FourKHdHubError::NoPlayableMirror(
- "Mirrors for this release are dead or expired on 4KHDHub. Select another release (e.g. 1080p) or press Ctrl+P for MovieBox.".into(),
+ "all candidate mirrors failed preflight".into(),
))
}
diff --git a/src/service.rs b/src/service.rs
index 70a7f2d..82bfd4a 100644
--- a/src/service.rs
+++ b/src/service.rs
@@ -392,15 +392,22 @@ impl MovieBoxService {
let response = tokio::time::timeout(std::time::Duration::from_secs(8), request.send())
.await
- .map_err(|_| "Subtitle download timed out".to_string())?
- .map_err(|e| format!("Failed to request subtitle: {e}"))?
- .error_for_status()
- .map_err(|e| format!("Subtitle response status error: {e}"))?;
+ .map_err(|_| "timed out".to_string())?
+ .map_err(|e| {
+ if e.is_timeout() {
+ "timed out".to_string()
+ } else {
+ "connection failed".to_string()
+ }
+ })?;
+ if !response.status().is_success() {
+ return Err(format!("HTTP {}", response.status().as_u16()));
+ }
let bytes = response
.bytes()
.await
- .map_err(|e| format!("Failed to read subtitle bytes: {e}"))?;
+ .map_err(|_| "read error".to_string())?;
let extension = subtitle_extension_from_url(url);
let base_dir = resolve_subtitle_dir();
@@ -424,7 +431,7 @@ impl MovieBoxService {
let path = base_dir.join(format!("{file_stem}.{extension}"));
tokio::fs::write(&path, bytes)
.await
- .map_err(|e| format!("Failed to write subtitle file: {e}"))?;
+ .map_err(|e| format!("write error ({})", e.kind()))?;
Ok(path)
}
diff --git a/src/tui/app/download.rs b/src/tui/app/download.rs
index 55ce3f9..775033c 100644
--- a/src/tui/app/download.rs
+++ b/src/tui/app/download.rs
@@ -188,44 +188,55 @@ impl App {
let result =
tokio::time::timeout(std::time::Duration::from_secs(30), sub_req.send()).await;
match result {
- Ok(Ok(response)) => match response.error_for_status() {
- Ok(response) => match response.bytes().await {
- Ok(bytes) => {
- if tokio::fs::write(subtitle_path, bytes).await.is_err() {
+ Ok(Ok(response)) => {
+ let status = response.status();
+ if !status.is_success() {
+ sender
+ .send(Action::SetStatus(format!(
+ "Warning: Subtitle unavailable (HTTP {}).",
+ status.as_u16()
+ )))
+ .ok();
+ } else {
+ match response.bytes().await {
+ Ok(bytes) => {
+ if let Err(io_err) =
+ tokio::fs::write(subtitle_path, bytes).await
+ {
+ sender
+ .send(Action::SetStatus(format!(
+ "Warning: Subtitle save failed ({}).",
+ io_err.kind()
+ )))
+ .ok();
+ }
+ }
+ Err(_) => {
sender
.send(Action::SetStatus(
- "Error: Subtitle save failed.".to_string(),
+ "Warning: Subtitle read interrupted.".to_string(),
))
.ok();
}
}
- Err(_) => {
- sender
- .send(Action::SetStatus(
- "Error: Subtitle download failed.".to_string(),
- ))
- .ok();
- }
- },
- Err(_) => {
- sender
- .send(Action::SetStatus(
- "Error: Subtitle download failed.".to_string(),
- ))
- .ok();
}
- },
- Ok(Err(_)) => {
+ }
+ Ok(Err(req_err)) => {
+ let reason = if req_err.is_timeout() {
+ "timed out"
+ } else {
+ "connection failed"
+ };
sender
- .send(Action::SetStatus(
- "Error: Subtitle download failed.".to_string(),
- ))
+ .send(Action::SetStatus(format!(
+ "Warning: Subtitle download {reason}."
+ )))
.ok();
}
Err(_) => {
sender
.send(Action::SetStatus(
- "Error: Subtitle download timed out.".to_string(),
+ "Warning: Subtitle download timed out.".to_string(),
))
.ok();
}
@@ -233,15 +244,22 @@ impl App {
}
if is_dash {
- let Some(ytdlp_bin) = crate::player::find_in_path("yt-dlp") else {
- sender
- .send(Action::DownloadFailed(yt_dlp_missing_guidance()))
- .ok();
+ let has_ytdlp = crate::player::find_in_path("yt-dlp");
+ let has_ffmpeg = crate::player::find_in_path("ffmpeg");
+ let Some(ytdlp_bin) = has_ytdlp else {
+ let msg = if has_ffmpeg.is_none() {
+ "Missing yt-dlp and ffmpeg for DASH download."
+ } else {
+ "Missing yt-dlp for DASH download."
+ };
+ sender.send(Action::DownloadFailed(msg.to_string())).ok();
return;
};
- if crate::player::find_in_path("ffmpeg").is_none() {
+ if has_ffmpeg.is_none() {
sender
- .send(Action::DownloadFailed(yt_dlp_missing_guidance()))
+ .send(Action::DownloadFailed(
+ "Missing ffmpeg for DASH stream muxing.".to_string(),
+ ))
.ok();
return;
}
@@ -297,7 +315,8 @@ impl App {
Err(err) => {
sender
.send(Action::DownloadFailed(format!(
- "Failed to start yt-dlp: {err}"
+ "yt-dlp launch failed ({}).",
+ err.kind()
)))
.ok();
return;
@@ -414,11 +433,8 @@ impl App {
.cloned();
drop(lines);
let err_msg = match last_err {
- Some(e) if e.contains("ffmpeg") || e.contains("ffprobe") => {
- format!("{e}\n{}", yt_dlp_missing_guidance())
- }
- Some(e) => e,
- None => format!("yt-dlp exited with status {s}"),
+ Some(e) => clean_ytdlp_error(&e),
+ None => format!("yt-dlp exited ({s})."),
};
sender.send(Action::DownloadFailed(err_msg)).ok();
}
@@ -806,10 +822,14 @@ impl App {
Action::DownloadCompleted(path) => {
self.state.download_progress = Some(100.0);
self.state.download_status = Some("Completed".into());
+ let display_name = std::path::Path::new(&path)
+ .file_name()
+ .map(|n| n.to_string_lossy().into_owned())
+ .unwrap_or(path);
self.state.notify(
NotificationKind::Success,
- "Download complete",
- format!("Saved to {path}"),
+ "Download Complete",
+ format!("Saved {display_name}"),
);
let sender = self.action_sender.clone();
tokio::spawn(async move {
@@ -827,12 +847,12 @@ impl App {
let completed = total.saturating_sub(remaining + 1);
self.state.notify(
NotificationKind::Error,
- "Season download halted",
- format!("{completed}/{total} files finished before error: {error}"),
+ "Season Download Halted",
+ format!("{completed}/{total} done: {error}"),
);
} else {
self.state
- .notify(NotificationKind::Error, "Download failed", error);
+ .notify(NotificationKind::Error, "Download Failed", error);
}
self.state.download_queue.clear();
self.state.download_queue_total = 0;
@@ -847,14 +867,18 @@ impl App {
let completed = total.saturating_sub(remaining + 1);
self.state.notify(
NotificationKind::Warning,
- "Season download paused",
- format!("{completed}/{total} files finished. Resume with {path}.part"),
+ "Season Download Paused",
+ format!("{completed}/{total} finished."),
);
} else {
+ let file_name = std::path::Path::new(&path)
+ .file_name()
+ .map(|n| n.to_string_lossy().into_owned())
+ .unwrap_or(path);
self.state.notify(
NotificationKind::Warning,
- "Download paused",
- format!("Start again to resume {path}.part"),
+ "Download Paused",
+ format!("Paused {file_name}"),
);
}
self.state.download_queue.clear();
@@ -1031,19 +1055,34 @@ async fn prepare_target_dir(
}
Ok(())
}
-pub(crate) fn yt_dlp_missing_guidance() -> String {
- if crate::updater::artifact::is_termux_environment() {
- "DASH streams require yt-dlp & ffmpeg.\nRun: pkg install yt-dlp ffmpeg".to_string()
- } else if cfg!(target_os = "macos") {
- "DASH streams require yt-dlp & ffmpeg.\nRun: brew install yt-dlp ffmpeg".to_string()
- } else if cfg!(target_os = "windows") {
- "DASH streams require yt-dlp & ffmpeg.\nRun: winget install yt-dlp.yt-dlp Gyan.FFmpeg"
- .to_string()
- } else if cfg!(target_os = "linux") {
- "DASH streams require yt-dlp & ffmpeg.\nInstall via system package manager".to_string()
+pub(crate) fn clean_ytdlp_error(raw: &str) -> String {
+ let trimmed = raw.trim().trim_start_matches("ERROR:").trim();
+ let stripped = if let Some(rest) = trimmed.strip_prefix('[')
+ && let Some((_, after_bracket)) = rest.split_once(']')
+ {
+ let after = after_bracket.trim();
+ if let Some((_, msg)) = after.split_once(": ") {
+ msg.trim()
+ } else {
+ after
+ }
} else {
- "DASH streams require yt-dlp & ffmpeg.".to_string()
+ trimmed
+ };
+ let lower = stripped.to_ascii_lowercase();
+ if lower.contains("http error 403") || lower.contains("403: forbidden") {
+ return "Server refused download (HTTP 403).".to_string();
+ }
+ if lower.contains("http error 404") || lower.contains("404: not found") {
+ return "Stream file not found (HTTP 404).".to_string();
+ }
+ if lower.contains("timed out") || lower.contains("timeout") {
+ return "Connection timed out.".to_string();
+ }
+ if lower.contains("ffmpeg") || lower.contains("ffprobe") {
+ return "Missing ffmpeg for DASH stream muxing.".to_string();
}
+ crate::tui::text::truncate_width(stripped, 64).into_owned()
}
pub(crate) fn parse_ytdlp_progress(line: &str) -> Option<(f64, String)> {
@@ -1234,13 +1273,19 @@ mod tests {
}
#[test]
- fn test_yt_dlp_missing_guidance_contains_platform_hint() {
- let guidance = super::yt_dlp_missing_guidance();
- assert!(guidance.contains("DASH streams require yt-dlp & ffmpeg"));
- #[cfg(target_os = "macos")]
- assert!(guidance.contains("brew install yt-dlp ffmpeg"));
- #[cfg(target_os = "windows")]
- assert!(guidance.contains("winget install yt-dlp.yt-dlp Gyan.FFmpeg"));
+ fn test_clean_ytdlp_error_extracts_concise_reason() {
+ assert_eq!(
+ super::clean_ytdlp_error(
+ "ERROR: [generic] index: Unable to download webpage: HTTP Error 403: Forbidden"
+ ),
+ "Server refused download (HTTP 403)."
+ );
+ assert_eq!(
+ super::clean_ytdlp_error(
+ "ERROR: You have requested merging of multiple formats but ffmpeg is not installed"
+ ),
+ "Missing ffmpeg for DASH stream muxing."
+ );
}
#[tokio::test]
diff --git a/src/tui/app/keyboard.rs b/src/tui/app/keyboard.rs
index 10e0f2b..9999bd0 100644
--- a/src/tui/app/keyboard.rs
+++ b/src/tui/app/keyboard.rs
@@ -114,12 +114,10 @@ impl App {
KeyCode::Char('b') | KeyCode::Char('B')
if env == crate::updater::apply::InstallationEnvironment::Homebrew =>
{
- self.state
- .set_status_short("Run: brew upgrade moviebox-tui");
self.state.notify(
crate::tui::overlay::NotificationKind::Info,
- "Homebrew Upgrade",
- "Run: brew upgrade moviebox-tui",
+ "Homebrew Update",
+ "Installed via Homebrew.",
);
self.state.update_available = None;
return None;
@@ -127,12 +125,10 @@ impl App {
KeyCode::Char('s') | KeyCode::Char('S')
if env == crate::updater::apply::InstallationEnvironment::Scoop =>
{
- self.state
- .set_status_short("Run: scoop update moviebox-tui");
self.state.notify(
crate::tui::overlay::NotificationKind::Info,
- "Scoop Upgrade",
- "Run: scoop update moviebox-tui",
+ "Scoop Update",
+ "Installed via Scoop.",
);
self.state.update_available = None;
return None;
diff --git a/src/tui/app/mouse.rs b/src/tui/app/mouse.rs
index 788797a..f4617e7 100644
--- a/src/tui/app/mouse.rs
+++ b/src/tui/app/mouse.rs
@@ -330,21 +330,17 @@ impl App {
if col < layout.update_btn_end_x {
match env {
crate::updater::apply::InstallationEnvironment::Homebrew => {
- self.state
- .set_status_short("Run: brew upgrade moviebox-tui");
self.state.notify(
NotificationKind::Info,
- "Homebrew Upgrade",
- "Run: brew upgrade moviebox-tui",
+ "Homebrew Update",
+ "Installed via Homebrew.",
);
}
crate::updater::apply::InstallationEnvironment::Scoop => {
- self.state
- .set_status_short("Run: scoop update moviebox-tui");
self.state.notify(
NotificationKind::Info,
- "Scoop Upgrade",
- "Run: scoop update moviebox-tui",
+ "Scoop Update",
+ "Installed via Scoop.",
);
}
crate::updater::apply::InstallationEnvironment::DirectReplace
diff --git a/src/tui/app/playback.rs b/src/tui/app/playback.rs
index edc553c..f6d54f2 100644
--- a/src/tui/app/playback.rs
+++ b/src/tui/app/playback.rs
@@ -89,22 +89,13 @@ impl App {
self.state.is_resolving_playback = false;
self.state.pending_playback_source = None;
let chosen_name = chosen.label();
- let body = if !compatible_alternatives.is_empty() {
- let alternatives_str = compatible_alternatives
- .iter()
- .map(|k| k.label())
- .collect::<Vec<_>>()
- .join(" or ");
+ let body = if let Some(first) = compatible_alternatives.first() {
format!(
- "{chosen_name} lacks header support. Switch to {alternatives_str} in /settings."
+ "{chosen_name} lacks header support. Switch to {} in /settings.",
+ first.label()
)
} else {
- let supported_str = crate::player::header_capable_players()
- .iter()
- .map(|k| k.label())
- .collect::<Vec<_>>()
- .join(" or ");
- format!("{chosen_name} lacks header support. Install {supported_str}.")
+ format!("{chosen_name} lacks custom header support.")
};
self.state.notify(
NotificationKind::Warning,
@@ -115,15 +106,10 @@ impl App {
PlaybackResolution::NoCompatiblePlayer { available: _ } => {
self.state.is_resolving_playback = false;
self.state.pending_playback_source = None;
- let supported_str = crate::player::header_capable_players()
- .iter()
- .map(|k| k.label())
- .collect::<Vec<_>>()
- .join(" or ");
self.state.notify(
NotificationKind::Error,
- "Incompatible Media Player",
- format!("Headers unsupported. Install {supported_str}."),
+ "Incompatible Player",
+ "Installed player lacks custom stream header support.".to_string(),
);
}
PlaybackResolution::NoPlayersInstalled => {
@@ -142,14 +128,13 @@ impl App {
)
} else if crate::updater::artifact::is_termux_environment() {
(
- "No Media Player Found",
- "Run 'pkg install termux-tools' and install an Android video player."
- .to_string(),
+ "No Media Player",
+ "No Android video player or termux-tools detected.".to_string(),
)
} else {
(
- "No Media Player Found",
- "Install mpv, IINA, or VLC to enable video playback.".to_string(),
+ "No Media Player",
+ "No supported media player (mpv, IINA, VLC) found.".to_string(),
)
};
self.state.notify(NotificationKind::Error, title, message);
@@ -349,18 +334,17 @@ impl App {
temporary_subtitle = Some(path);
}
}
- Err(_) => {
+ Err(err) => {
log::warn!(
- "subtitle download failed for {:?} player (url was {})",
+ "subtitle download failed for {:?} player ({err}, url was {})",
kind,
crate::logging::sanitize_url(url)
);
if !matches!(kind, crate::tui::state::PlayerKind::Mpv) {
local_subtitle = None;
- let _ = sender.send(Action::SetStatus(
- "Warning: External subtitle unavailable; playing stream directly."
- .to_string(),
- ));
+ let _ = sender.send(Action::SetStatus(format!(
+ "Warning: Subtitle unavailable ({err}); playing without subs."
+ )));
}
}
}
@@ -436,7 +420,7 @@ impl App {
log::error!("Failed to spawn stream proxy sidecar: {err}");
let _ = sender.send(Action::PlayerExited);
let _ = sender.send(Action::SetStatus(format!(
- "Error: Stream proxy initialization failed: {err}"
+ "Error: Stream proxy failed ({err})"
)));
return;
}
@@ -729,14 +713,47 @@ fn is_user_quit(status: &std::process::ExitStatus) -> bool {
fn clean_player_error(code: Option<i32>, signal: Option<i32>, stderr: &str) -> String {
let trimmed = stderr.trim();
if !trimmed.is_empty() {
- let bounded = if trimmed.len() > 512 {
- let mut end = 512;
- while end > 0 && !trimmed.is_char_boundary(end) {
+ let lower = trimmed.to_ascii_lowercase();
+ if lower.contains("403 forbidden") || lower.contains("http error 403") {
+ return "Stream forbidden by server (HTTP 403).".to_string();
+ }
+ if lower.contains("404 not found") || lower.contains("http error 404") {
+ return "Stream link not found (HTTP 404).".to_string();
+ }
+ if lower.contains("410 gone") || lower.contains("http error 410") {
+ return "Stream link expired (HTTP 410).".to_string();
+ }
+ if lower.contains("connection refused") {
+ return "Stream connection refused.".to_string();
+ }
+ if lower.contains("timed out") || lower.contains("timeout") {
+ return "Stream connection timed out.".to_string();
+ }
+ if lower.contains("unrecognized option") || lower.contains("unknown option") {
+ return "Unsupported player CLI option.".to_string();
+ }
+ let best_line = trimmed
+ .lines()
+ .rev()
+ .map(str::trim)
+ .find(|l| {
+ !l.is_empty()
+ && (l.contains("error")
+ || l.contains("Error")
+ || l.contains("ERROR")
+ || l.contains("failed")
+ || l.contains("Failed"))
+ })
+ .or_else(|| trimmed.lines().rev().map(str::trim).find(|l| !l.is_empty()))
+ .unwrap_or(trimmed);
+ let bounded = if best_line.len() > 120 {
+ let mut end = 120;
+ while end > 0 && !best_line.is_char_boundary(end) {
end -= 1;
}
- &trimmed[..end]
+ &best_line[..end]
} else {
- trimmed
+ best_line
};
return bounded.to_string();
}
@@ -1075,29 +1092,31 @@ impl App {
} else if is_termux_tool_crash {
(
"Termux Setup",
- "Run 'pkg install termux-tools'.".to_string(),
+ "Missing termux-tools package in Termux.".to_string(),
)
} else {
+ let has_specific =
+ !error_msg.is_empty() && !error_msg.starts_with("Player exited");
match code {
Some(2) => (
- "Stream Dead",
- if !error_msg.is_empty() && !error_msg.starts_with("Player exited") {
+ "Stream Error",
+ if has_specific {
error_msg
} else {
- "Link expired or unreachable.".to_string()
+ "Player failed to open stream (exit code 2).".to_string()
},
),
Some(1) => (
"Player Error",
- if error_msg.is_empty() || error_msg.starts_with("Player exited") {
- "Check player configuration.".to_string()
- } else {
+ if has_specific {
error_msg
+ } else {
+ "Player exited with error code 1.".to_string()
},
),
Some(c) => (
"Playback Failed",
- if !error_msg.is_empty() && !error_msg.starts_with("Player exited") {
+ if has_specific {
error_msg
} else {
format!("Player exited ({c}).")
@@ -1105,7 +1124,7 @@ impl App {
),
None => (
"Playback Failed",
- if !error_msg.is_empty() && !error_msg.starts_with("Player exited") {
+ if has_specific {
error_msg
} else {
"Player terminated.".to_string()
@@ -1114,8 +1133,6 @@ impl App {
}
};
- self.state.set_status(format!("{title}: {message}"), 300);
-
self.state.notify(NotificationKind::Error, title, message);
}
_ => return None,
@@ -1153,14 +1170,14 @@ mod tests {
}
#[test]
fn player_exit_code_interpretation() {
- let code = Some(2);
- let msg = match code {
- Some(2) => ("Stream Dead", "Link expired or unreachable."),
- Some(1) => ("Player Error", "Check player configuration."),
- _ => ("Playback Failed", "Player exited."),
- };
- assert_eq!(msg.0, "Stream Dead");
- assert_eq!(msg.1, "Link expired or unreachable.");
+ assert_eq!(
+ clean_player_error(Some(2), None, "ffmpeg/http: HTTP error 403 Forbidden"),
+ "Stream forbidden by server (HTTP 403)."
+ );
+ assert_eq!(
+ clean_player_error(Some(2), None, "Connection timed out"),
+ "Stream connection timed out."
+ );
}
#[test]
@@ -1500,7 +1517,10 @@ mod tests {
.back()
.expect("expected notification");
assert_eq!(last_notification.title, "Termux Setup");
- assert_eq!(last_notification.message, "Run 'pkg install termux-tools'.");
+ assert_eq!(
+ last_notification.message,
+ "Missing termux-tools package in Termux."
+ );
}
#[tokio::test]
@@ -1575,7 +1595,10 @@ mod tests {
.back()
.expect("expected notification");
assert_eq!(last_notification.title, "Termux Setup");
- assert_eq!(last_notification.message, "Run 'pkg install termux-tools'.");
+ assert_eq!(
+ last_notification.message,
+ "Missing termux-tools package in Termux."
+ );
}
#[tokio::test]
diff --git a/src/tui/app/system.rs b/src/tui/app/system.rs
index 29e6c75..d5e977a 100644
--- a/src/tui/app/system.rs
+++ b/src/tui/app/system.rs
@@ -696,7 +696,7 @@ impl App {
let trimmed = rest.trim_start_matches(':').trim();
("4KHDHub Stream Unavailable", trimmed)
} else {
- ("Operation failed", body)
+ ("Error", body)
};
self.state
.notify(NotificationKind::Error, title, clean_body);
@@ -705,11 +705,9 @@ impl App {
self.state
.notify(NotificationKind::Warning, "Notice", body.trim());
} else {
- if self.state.active_screen != crate::tui::state::Screen::Home
- || self.state.addon_manager_popup
- {
+ if self.state.addon_manager_popup {
self.state
- .notify(NotificationKind::Info, "Status", msg.clone());
+ .notify(NotificationKind::Info, "Addons", msg.clone());
}
self.state.set_status_default(msg);
}
@@ -825,11 +823,10 @@ impl App {
self.state.is_updating = true;
self.state.update_available = None;
self.state.update_progress_msg = Some("Starting self-update...".to_string());
- self.state.set_status_long("Starting self-update...");
self.state.notify(
NotificationKind::Info,
"Self-Update",
- "Downloading release artifact and verifying checksum...",
+ "Downloading and verifying release...",
);
let cached_release = self.state.update_release.clone();
@@ -881,12 +878,10 @@ impl App {
self.state.update_progress_msg = None;
match result {
Ok(crate::updater::SelfUpdateOutcome::Success) => {
- self.state
- .set_status_long("Update successful! Restarting...");
self.state.notify(
NotificationKind::Success,
"Update Installed",
- "MovieBox-Tui was updated successfully. Restarting process...",
+ "Restarting MovieBox-Tui...",
);
crossterm::terminal::disable_raw_mode().ok();
@@ -907,12 +902,10 @@ impl App {
std::process::exit(0);
}
Ok(crate::updater::SelfUpdateOutcome::RequiresManualUpgrade(msg)) => {
- self.state.set_status(msg.clone(), 300);
self.state
- .notify(NotificationKind::Warning, "Manual Update Required", msg);
+ .notify(NotificationKind::Warning, "Manual Update", msg);
}
Err(err) => {
- self.state.set_status_long(format!("Update failed: {err}"));
self.state
.notify(NotificationKind::Error, "Update Failed", err);
}
@@ -1052,7 +1045,7 @@ mod tests {
let info_notif = app.state.notifications.back().expect("info toast");
assert_eq!(info_notif.kind, NotificationKind::Info);
- assert_eq!(info_notif.title, "Status");
+ assert_eq!(info_notif.title, "Addons");
assert_eq!(info_notif.message, "Installed Cinemeta v1.0.0");
}
}