Skip to content

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

fix(tui): clean subtitle filenames and shorten stream error alerts

Samir Hossainse10ae6ce16a0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index eaef2bf..3a24cd9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,10 @@
- Added multi-dub and language rip resolution supporting original, English, and localized dubs with composite subject ID routing (`{title_id}::{rip}`).
- Added `ProviderKind::Dramachi` support across `MovieBoxService`, TUI search, details, stream resolution, downloads, settings, and badges (`[Dramachi]`).
### Fixed
+- **Human-Readable Subtitle Filenames & Intent Storage**:
+ - Formatted subtitle filenames with media titles and season/episode tags (e.g. `<Title> - S<N:02>E<E:02>.<ext>`) in `src/service.rs` and `src/tui/app/playback.rs`, replacing random process/timestamp IDs for easy identification in external player file pickers (`moviebox_subs/`).
+- **Concise Stream Failure Notifications**:
+ - Simplified verbose episode stream failure messages (`Provider is temporarily unavailable: No stream sources available`) to clean, high-signal alerts (`No streams available`) in `src/tui/app/requests.rs`.
- **Stream Proxy Subtitle Whitelist & Scope Isolation**:
- Permitted external subtitle CDN hosts in `src/proxy.rs` proxy connection validation, preventing HTTP 403 errors when media players fetch external subtitle tracks alongside DASH stream manifests.
- Scoped authentication headers exclusively to target video hosts, preventing credential spillage to subtitle CDNs.
diff --git a/docs/players.md b/docs/players.md
index 98d57ef..589787d 100644
--- a/docs/players.md
+++ b/docs/players.md
@@ -40,7 +40,10 @@ The `supports_headers` gate in `app/playback.rs` validates whether a player can
- VLC and IINA download the subtitle to a temp file first, preserving the URL's
extension (srt/vtt/ass/…), and pass the local path. The download applies the source
headers. On failure a status is shown and playback continues without subtitles.
-- Android intent playback downloads subtitles to shared storage (`~/storage/downloads/moviebox_subs`) and passes local file paths to `am`/`termux-am` via `subtitles_location` and `subs` intent extras. Subtitles are retained during playback without premature deletion on intent command exit, and purged on a 24-hour retention cycle.
+- Android intent playback downloads subtitles to shared storage (`~/storage/downloads/moviebox_subs` or `/sdcard/Download/moviebox_subs`) named clearly after the media title (e.g. `<Title> - S<N:02>E<E:02>.<ext>` or `<Title>.<ext>`), and passes local file paths to `am`/`termux-am` via `subtitles_location` and `subs` intent extras.
+ - Players supporting automatic subtitle intent binding (e.g. MX Player) load the file automatically.
+ - For players that do not auto-load external file paths from remote stream intents (e.g. VLC for Android, mpv-android), the file is immediately available in the player's subtitle file picker under `Download/moviebox_subs/`.
+ - Subtitles are retained during playback without premature deletion on intent command exit, and purged on a 24-hour retention cycle or via `/settings` → Clear Disk Cache.
- Desktop temp files are cleaned up after the player process exits and purged at startup if stale.
## Playback Tracking & Resume
diff --git a/src/service.rs b/src/service.rs
index 4f5bd11..b4e3a53 100644
--- a/src/service.rs
+++ b/src/service.rs
@@ -305,6 +305,7 @@ impl MovieBoxService {
&self,
url: &str,
headers: &[(String, String)],
+ preferred_filename: Option<&str>,
) -> Result<PathBuf, String> {
let mut request = self.http_client.get(url);
for (name, value) in headers {
@@ -333,16 +334,19 @@ impl MovieBoxService {
let base_dir = resolve_subtitle_dir();
let _ = std::fs::create_dir_all(&base_dir);
- let path = base_dir.join(format!(
- "{}_{}.{}",
- std::process::id(),
- std::time::SystemTime::now()
- .duration_since(std::time::UNIX_EPOCH)
- .unwrap_or_default()
- .as_nanos(),
- extension
- ));
-
+ let file_stem = if let Some(pref) = preferred_filename {
+ crate::download::safe_file_stem(pref)
+ } else {
+ format!(
+ "{}_{}",
+ std::process::id(),
+ std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .unwrap_or_default()
+ .as_nanos()
+ )
+ };
+ 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}"))?;
diff --git a/src/tui/app/playback.rs b/src/tui/app/playback.rs
index 6ed2354..62dbb84 100644
--- a/src/tui/app/playback.rs
+++ b/src/tui/app/playback.rs
@@ -298,6 +298,19 @@ impl App {
(rows as u32 * cell_height).clamp(180, 1080),
)
});
+ let preferred_sub_name = history_item.as_ref().map(|item| {
+ if item.season > 0 || item.episode > 0 {
+ format!(
+ "{} - S{:02}E{:02}",
+ item.title,
+ item.season.max(1),
+ item.episode.max(1)
+ )
+ } else {
+ item.title.clone()
+ }
+ });
+
tokio::spawn(async move {
let mut local_subtitle = subtitle.clone();
let mut temporary_subtitle = None;
@@ -309,7 +322,7 @@ impl App {
) && let Some(ref url) = subtitle
{
let download_res = crate::service::MovieBoxService::new()
- .download_subtitle_file(url, &headers)
+ .download_subtitle_file(url, &headers, preferred_sub_name.as_deref())
.await;
match download_res {
Ok(path) => {
diff --git a/src/tui/app/requests.rs b/src/tui/app/requests.rs
index 2d3fd09..a11169b 100644
--- a/src/tui/app/requests.rs
+++ b/src/tui/app/requests.rs
@@ -1899,10 +1899,19 @@ impl App {
target_se,
target_ep
);
+ let clean_err = if err.contains("No stream sources available") {
+ "No streams available".to_string()
+ } else if let Some(stripped) =
+ err.strip_prefix("Provider is temporarily unavailable: ")
+ {
+ stripped.to_string()
+ } else {
+ err
+ };
self.state.notify(
crate::tui::overlay::NotificationKind::Error,
"Streams Failed",
- err,
+ clean_err,
);
}
_ => return None,