Skip to content

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

feat: add native android support for video player and downloads

Samir Hossainsded5feb7b142
diff --git a/Cargo.lock b/Cargo.lock
index 5efae51..88620e0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -731,6 +731,21 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
+[[package]]
+name = "foreign-types"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
+dependencies = [
+ "foreign-types-shared",
+]
+
+[[package]]
+name = "foreign-types-shared"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
+
[[package]]
name = "form_urlencoded"
version = "1.2.2"
@@ -1034,6 +1049,22 @@ dependencies = [
"tower-service",
]
+[[package]]
+name = "hyper-tls"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0"
+dependencies = [
+ "bytes",
+ "http-body-util",
+ "hyper",
+ "hyper-util",
+ "native-tls",
+ "tokio",
+ "tokio-native-tls",
+ "tower-service",
+]
+
[[package]]
name = "hyper-util"
version = "0.1.20"
@@ -1541,7 +1572,7 @@ dependencies = [
[[package]]
name = "moviebox-tui"
-version = "0.1.9"
+version = "0.1.10"
dependencies = [
"base64 0.23.1",
"crossterm",
@@ -1580,6 +1611,23 @@ dependencies = [
"pxfm",
]
+[[package]]
+name = "native-tls"
+version = "0.2.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2"
+dependencies = [
+ "libc",
+ "log",
+ "openssl",
+ "openssl-probe",
+ "openssl-sys",
+ "schannel",
+ "security-framework",
+ "security-framework-sys",
+ "tempfile",
+]
+
[[package]]
name = "new_debug_unreachable"
version = "1.0.6"
@@ -1661,12 +1709,49 @@ dependencies = [
"libc",
]
+[[package]]
+name = "openssl"
+version = "0.10.81"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "77823a27f0babb03091cb9ed9ef80af3b39dbc82f97e8fa530374b7dafd87a45"
+dependencies = [
+ "bitflags 2.13.1",
+ "cfg-if",
+ "foreign-types",
+ "libc",
+ "openssl-macros",
+ "openssl-sys",
+]
+
+[[package]]
+name = "openssl-macros"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
[[package]]
name = "openssl-probe"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"
+[[package]]
+name = "openssl-sys"
+version = "0.9.117"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695"
+dependencies = [
+ "cc",
+ "libc",
+ "pkg-config",
+ "vcpkg",
+]
+
[[package]]
name = "option-ext"
version = "0.2.0"
@@ -2063,7 +2148,7 @@ dependencies = [
"once_cell",
"socket2",
"tracing",
- "windows-sys 0.61.2",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -2394,9 +2479,11 @@ dependencies = [
"http-body-util",
"hyper",
"hyper-rustls",
+ "hyper-tls",
"hyper-util",
"js-sys",
"log",
+ "native-tls",
"percent-encoding",
"pin-project-lite",
"quinn",
@@ -2407,6 +2494,7 @@ dependencies = [
"serde_json",
"sync_wrapper",
"tokio",
+ "tokio-native-tls",
"tokio-rustls",
"tower",
"tower-http",
@@ -2527,7 +2615,7 @@ dependencies = [
"security-framework",
"security-framework-sys",
"webpki-root-certs",
- "windows-sys 0.61.2",
+ "windows-sys 0.52.0",
]
[[package]]
@@ -2940,6 +3028,19 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
+[[package]]
+name = "tempfile"
+version = "3.27.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
+dependencies = [
+ "fastrand",
+ "getrandom 0.3.4",
+ "once_cell",
+ "rustix 1.1.4",
+ "windows-sys 0.52.0",
+]
+
[[package]]
name = "tendril"
version = "0.5.1"
@@ -3137,6 +3238,16 @@ dependencies = [
"syn 3.0.3",
]
+[[package]]
+name = "tokio-native-tls"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
+dependencies = [
+ "native-tls",
+ "tokio",
+]
+
[[package]]
name = "tokio-rustls"
version = "0.26.4"
@@ -3300,6 +3411,12 @@ dependencies = [
"wasm-bindgen",
]
+[[package]]
+name = "vcpkg"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
+
[[package]]
name = "version_check"
version = "0.9.5"
@@ -3555,7 +3672,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
- "windows-sys 0.61.2",
+ "windows-sys 0.52.0",
]
[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 39c7744..242062c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,7 +24,6 @@ md-5 = "0.11.0"
rand = "0.10.2"
ratatui = "0.30.2"
ratatui-image = { version = "11.0.6", default-features = false, features = ["crossterm"] }
-reqwest = { version = "0.13.4", default-features = false, features = ["json", "rustls"] }
rustls = { version = "0.23.42", default-features = false, features = ["ring", "std"] }
scraper = "0.27.0"
semver = "1.0.28"
@@ -55,3 +54,9 @@ codegen-units = 1
panic = "abort"
strip = true
+
+[target.'cfg(not(target_os = "android"))'.dependencies]
+reqwest = { version = "0.13.4", default-features = false, features = ["json", "rustls"] }
+
+[target.'cfg(target_os = "android")'.dependencies]
+reqwest = { version = "0.13.4", default-features = false, features = ["json", "native-tls"] }
diff --git a/src/providers/bdix/circleftp/client.rs b/src/providers/bdix/circleftp/client.rs
index 58f883b..4cf82ad 100644
--- a/src/providers/bdix/circleftp/client.rs
+++ b/src/providers/bdix/circleftp/client.rs
@@ -127,22 +127,40 @@ impl CircleFtpClient {
let title_full = json.get("title").and_then(|v| v.as_str()).unwrap_or("");
let t_lower = title_full.to_lowercase();
-
+
let audios = [
- ("hindi", "Hindi"), ("bengali", "Bengali"), ("bangla", "Bengali"),
- ("english", "English"), ("tamil", "Tamil"), ("telugu", "Telugu"),
- ("malayalam", "Malayalam"), ("korean", "Korean"),
- ("dual audio", "Dual Audio"), ("multi audio", "Multi Audio"),
- ].iter().find(|(k, _)| t_lower.contains(k)).map(|(_, v)| v.to_string());
+ ("hindi", "Hindi"),
+ ("bengali", "Bengali"),
+ ("bangla", "Bengali"),
+ ("english", "English"),
+ ("tamil", "Tamil"),
+ ("telugu", "Telugu"),
+ ("malayalam", "Malayalam"),
+ ("korean", "Korean"),
+ ("dual audio", "Dual Audio"),
+ ("multi audio", "Multi Audio"),
+ ]
+ .iter()
+ .find(|(k, _)| t_lower.contains(k))
+ .map(|(_, v)| v.to_string());
let prints = [
- ("cam", "CAM"), ("hdcam", "CAM"),
- ("hdtc", "HDTC"), ("tc", "HDTC"),
- ("hdrip", "HDRip"), ("hd rip", "HDRip"),
- ("webrip", "WEBRip"), ("web-rip", "WEBRip"),
- ("webdl", "WEB-DL"), ("web-dl", "WEB-DL"),
- ("bluray", "BluRay"), ("brrip", "BluRay"),
- ].iter().find(|(k, _)| t_lower.contains(k)).map(|(_, v)| v.to_string());
+ ("cam", "CAM"),
+ ("hdcam", "CAM"),
+ ("hdtc", "HDTC"),
+ ("tc", "HDTC"),
+ ("hdrip", "HDRip"),
+ ("hd rip", "HDRip"),
+ ("webrip", "WEBRip"),
+ ("web-rip", "WEBRip"),
+ ("webdl", "WEB-DL"),
+ ("web-dl", "WEB-DL"),
+ ("bluray", "BluRay"),
+ ("brrip", "BluRay"),
+ ]
+ .iter()
+ .find(|(k, _)| t_lower.contains(k))
+ .map(|(_, v)| v.to_string());
Ok(MediaDetails {
id: ProviderMediaId {
@@ -211,16 +229,28 @@ impl CircleFtpClient {
let t_lower = title_str.to_lowercase();
let codec = [
- ("x264", "x264"), ("h264", "x264"),
- ("x265", "HEVC"), ("hevc", "HEVC"),
+ ("x264", "x264"),
+ ("h264", "x264"),
+ ("x265", "HEVC"),
+ ("hevc", "HEVC"),
("av1", "AV1"),
- ].iter().find(|(k, _)| t_lower.contains(k)).map(|(_, v)| v.to_string());
+ ]
+ .iter()
+ .find(|(k, _)| t_lower.contains(k))
+ .map(|(_, v)| v.to_string());
let language = [
- ("hindi", "Hindi"), ("bengali", "Bengali"), ("bangla", "Bengali"),
- ("english", "English"), ("tamil", "Tamil"), ("telugu", "Telugu"),
+ ("hindi", "Hindi"),
+ ("bengali", "Bengali"),
+ ("bangla", "Bengali"),
+ ("english", "English"),
+ ("tamil", "Tamil"),
+ ("telugu", "Telugu"),
("malayalam", "Malayalam"),
- ].iter().find(|(k, _)| t_lower.contains(k)).map(|(_, v)| v.to_string());
+ ]
+ .iter()
+ .find(|(k, _)| t_lower.contains(k))
+ .map(|(_, v)| v.to_string());
if r#type == "series" {
if let (Some(target_s), Some(target_e)) = (season, episode) {
diff --git a/src/tui/app.rs b/src/tui/app.rs
index b789ed1..aa560ba 100644
--- a/src/tui/app.rs
+++ b/src/tui/app.rs
@@ -555,8 +555,21 @@ impl App {
let base_dir = dirs::download_dir()
.or_else(|| dirs::home_dir().map(|h| h.join("Downloads")))
- .unwrap_or_else(|| std::path::PathBuf::from("."))
- .join("MovieBox-TUI");
+ .unwrap_or_else(|| std::path::PathBuf::from("."));
+
+ #[cfg(target_os = "android")]
+ let base_dir = if let Some(home) = dirs::home_dir() {
+ let android_storage = home.join("storage/downloads");
+ if android_storage.exists() {
+ android_storage
+ } else {
+ base_dir
+ }
+ } else {
+ base_dir
+ };
+
+ let base_dir = base_dir.join("MovieBox-TUI");
let (target_dir, base_name) = if media_type == 2 {
(
base_dir
@@ -1792,18 +1805,7 @@ impl App {
}
if lower_query == "/github" {
- #[cfg(target_os = "windows")]
- let _ = std::process::Command::new("cmd")
- .args(["/C", "start", "https://github.com/mesamirh/MovieBox-Tui"])
- .spawn();
- #[cfg(target_os = "macos")]
- let _ = std::process::Command::new("open")
- .arg("https://github.com/mesamirh/MovieBox-Tui")
- .spawn();
- #[cfg(all(target_os = "linux", not(target_os = "android")))]
- let _ = std::process::Command::new("xdg-open")
- .arg("https://github.com/mesamirh/MovieBox-Tui")
- .spawn();
+ let _ = open::that("https://github.com/mesamirh/MovieBox-Tui");
self.state.search_query.clear();
self.state.input_mode = InputMode::Normal;
return None;
@@ -3578,6 +3580,7 @@ impl App {
crate::tui::state::PlayerKind::Mpv => "MPV",
crate::tui::state::PlayerKind::Iina => "IINA",
crate::tui::state::PlayerKind::Vlc => "VLC",
+ crate::tui::state::PlayerKind::AndroidIntent => "Android Player",
};
self.state.notify(
NotificationKind::Info,
diff --git a/src/tui/player.rs b/src/tui/player.rs
index 440c520..601d8ca 100644
--- a/src/tui/player.rs
+++ b/src/tui/player.rs
@@ -10,6 +10,12 @@ const VLC_MACOS: &str = "/Applications/VLC.app/Contents/MacOS/VLC";
pub fn detect() -> Vec<PlayerKind> {
let mut players = Vec::new();
+ #[cfg(target_os = "android")]
+ {
+ players.push(PlayerKind::AndroidIntent);
+ return players;
+ }
+
#[cfg(target_os = "macos")]
if iina_available() {
players.push(PlayerKind::Iina);
@@ -26,6 +32,9 @@ pub fn detect() -> Vec<PlayerKind> {
}
pub fn supports_headers(kind: PlayerKind, headers: &[(String, String)]) -> bool {
+ if kind == PlayerKind::AndroidIntent {
+ return false;
+ }
kind != PlayerKind::Vlc
|| headers.iter().all(|(name, _)| {
name.eq_ignore_ascii_case("referer") || name.eq_ignore_ascii_case("user-agent")
@@ -42,9 +51,23 @@ pub fn command(
PlayerKind::Mpv => mpv_command(url, subtitle, headers, false),
PlayerKind::Iina => iina_command(url, subtitle, headers),
PlayerKind::Vlc => vlc_command(url, subtitle, headers),
+ PlayerKind::AndroidIntent => android_intent_command(url),
}
}
+fn android_intent_command(url: &str) -> Command {
+ let mut command = Command::new("am");
+ command
+ .arg("start")
+ .arg("-a")
+ .arg("android.intent.action.VIEW")
+ .arg("-d")
+ .arg(url)
+ .arg("-t")
+ .arg("video/*");
+ command
+}
+
fn mpv_command(
url: &str,
subtitle: Option<&str>,
diff --git a/src/tui/screens/details.rs b/src/tui/screens/details.rs
index 6f1bdbe..33d6686 100644
--- a/src/tui/screens/details.rs
+++ b/src/tui/screens/details.rs
@@ -1089,6 +1089,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)
crate::tui::state::PlayerKind::Mpv => "mpv",
crate::tui::state::PlayerKind::Iina => "IINA",
crate::tui::state::PlayerKind::Vlc => "VLC",
+ crate::tui::state::PlayerKind::AndroidIntent => "Android Player",
}
.to_string()
})
diff --git a/src/tui/screens/home.rs b/src/tui/screens/home.rs
index cfd9b2d..efe80cf 100644
--- a/src/tui/screens/home.rs
+++ b/src/tui/screens/home.rs
@@ -1137,6 +1137,7 @@ pub fn draw(frame: &mut Frame, area: Rect, state: &mut AppState, theme: &Theme)
crate::tui::state::PlayerKind::Mpv => "mpv",
crate::tui::state::PlayerKind::Iina => "IINA",
crate::tui::state::PlayerKind::Vlc => "VLC",
+ crate::tui::state::PlayerKind::AndroidIntent => "Android Player",
}
.to_string()
})
diff --git a/src/tui/state.rs b/src/tui/state.rs
index 0395956..064be27 100644
--- a/src/tui/state.rs
+++ b/src/tui/state.rs
@@ -6,6 +6,7 @@ pub enum PlayerKind {
Mpv,
Iina,
Vlc,
+ AndroidIntent,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]