Skip to content

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

fix(moviebox): Update APK spoofing to v4.0.01, forward mobile User-Agent, and fix stream resolutions

Samir Hossains29c7bcfd028b
diff --git a/src/providers/moviebox/client.rs b/src/providers/moviebox/client.rs
index 4a6accb..6c33d0f 100644
--- a/src/providers/moviebox/client.rs
+++ b/src/providers/moviebox/client.rs
@@ -74,6 +74,10 @@ impl MovieBoxClient {
&self.client
}
+ pub fn user_agent(&self) -> &str {
+ &self.user_agent
+ }
+
pub async fn init(&self) -> Result<(), ScraperError> {
let path = "/wefeed-mobile-bff/tab-operating?page=1&tabId=0&version=";
let _ = self.request_hosts("GET", path, None).await?;
diff --git a/src/providers/moviebox/crypto.rs b/src/providers/moviebox/crypto.rs
index 00f55fc..c8225ae 100644
--- a/src/providers/moviebox/crypto.rs
+++ b/src/providers/moviebox/crypto.rs
@@ -228,7 +228,7 @@ pub(crate) fn generate_client_info_and_ua() -> (String, String) {
("M2012K11AG", "Redmi"),
("M2007J20CG", "Redmi"),
];
- let version_codes = [50020042, 50020043, 50020044, 50020045, 50020046];
+ let version_codes = [50020117, 50020118, 50020119, 50020120, 50020121];
let network_types = ["NETWORK_WIFI", "NETWORK_MOBILE"];
let timezones = [
"Asia/Kolkata",
@@ -252,7 +252,7 @@ pub(crate) fn generate_client_info_and_ua() -> (String, String) {
);
let client_info = format!(
- r#"{{"package_name":"com.community.oneroom","version_name":"3.0.03.0529.03","version_code":{},"os":"android","os_version":"{}","install_ch":"ps","device_id":"{}","install_store":"ps","gaid":"{}","brand":"{}","model":"{}","system_language":"en","net":"{}","region":"US","timezone":"{}","sp_code":"40401","X-Play-Mode":"2"}}"#,
+ r#"{{"package_name":"com.community.oneroom","version_name":"4.0.01.0813.03","version_code":{},"os":"android","os_version":"{}","install_ch":"ps","device_id":"{}","install_store":"ps","gaid":"{}","brand":"{}","model":"{}","system_language":"en","net":"{}","region":"US","timezone":"{}","sp_code":"40401","X-Play-Mode":"2"}}"#,
version_code, android.0, device_id, gaid, device.1, device.0, network, timezone
);
@@ -330,4 +330,22 @@ mod tests {
assert_eq!(parts[1], "2");
assert!(!parts[2].is_empty());
}
+
+ #[test]
+ fn test_generate_client_info_and_ua() {
+ let (ua, client_info) = generate_client_info_and_ua();
+ assert!(ua.contains("com.community.oneroom/500201"));
+ assert!(ua.contains("Cronet/135.0.7012.3"));
+
+ let parsed: serde_json::Value =
+ serde_json::from_str(&client_info).expect("valid JSON client_info");
+ assert_eq!(parsed["version_name"], "4.0.01.0813.03");
+ assert_eq!(parsed["package_name"], "com.community.oneroom");
+ let code = parsed["version_code"]
+ .as_i64()
+ .expect("version_code is number");
+ assert!((50020117..=50020121).contains(&code));
+ assert_eq!(parsed["sp_code"], "40401");
+ assert_eq!(parsed["X-Play-Mode"], "2");
+ }
}
diff --git a/src/providers/moviebox/mod.rs b/src/providers/moviebox/mod.rs
index 277980d..1004804 100644
--- a/src/providers/moviebox/mod.rs
+++ b/src/providers/moviebox/mod.rs
@@ -169,7 +169,22 @@ impl MovieBoxClient {
if let Some(cols) = res.get("collectionResolutions").and_then(|c| c.as_array()) {
for col in cols {
if let Some(r) = col.get("resolution").and_then(|v| v.as_u64()) {
- resolutions.push(r as u32);
+ if r > 0 {
+ resolutions.push(r as u32);
+ }
+ }
+ }
+ }
+
+ if resolutions.is_empty() {
+ if let Some(list) = res.get("list").and_then(|l| l.as_array()) {
+ for item in list {
+ if let Some(r) = item.get("resolution").and_then(|v| v.as_u64()) {
+ let res_u32 = r as u32;
+ if res_u32 > 0 && !resolutions.contains(&res_u32) {
+ resolutions.push(res_u32);
+ }
+ }
}
}
}
@@ -179,7 +194,6 @@ impl MovieBoxClient {
if resolutions.is_empty() {
resolutions = vec![1080, 720, 480, 360];
}
-
Ok(resolutions)
}
diff --git a/src/tui/app/download.rs b/src/tui/app/download.rs
index 83f1e3f..4df3472 100644
--- a/src/tui/app/download.rs
+++ b/src/tui/app/download.rs
@@ -124,9 +124,11 @@ impl App {
let cancel = self.state.cancel_download.clone();
let sender = self.action_sender.clone();
+ let user_agent = self.service.client.user_agent().to_string();
let client = crate::net::http_client_builder()
.connect_timeout(std::time::Duration::from_secs(15))
.tcp_keepalive(std::time::Duration::from_secs(30))
+ .user_agent(user_agent)
.build()
.unwrap_or_else(|err| {
log::warn!(
diff --git a/src/tui/app/playback.rs b/src/tui/app/playback.rs
index 5d73620..1613613 100644
--- a/src/tui/app/playback.rs
+++ b/src/tui/app/playback.rs
@@ -644,7 +644,11 @@ impl App {
self.state.is_resolving_playback = false;
self.state.player_picker_popup = false;
self.state.last_playback_launch = std::time::Instant::now();
- self.launch_player(kind, link, sub, Vec::new());
+ let headers = vec![(
+ "User-Agent".to_string(),
+ self.service.client.user_agent().to_string(),
+ )];
+ self.launch_player(kind, link, sub, headers);
}
Action::LaunchPlayback(kind, source) => {
self.state.is_resolving_playback = false;
diff --git a/src/tui/screens/details.rs b/src/tui/screens/details.rs
index 158eeaf..99e5574 100644
--- a/src/tui/screens/details.rs
+++ b/src/tui/screens/details.rs
@@ -1872,7 +1872,7 @@ mod tests {
assert_eq!(spans_720[0].content, " 720p ");
let spans_sd = resolution_badge_spans(480, &theme, false);
- assert_eq!(spans_sd[0].content, " SD ");
+ assert_eq!(spans_sd[0].content, " 480p ");
let basic_4k = resolution_badge_spans(2160, &theme, true);
assert_eq!(basic_4k[0].content.trim(), "[4K]");
diff --git a/src/tui/widgets/badge.rs b/src/tui/widgets/badge.rs
index c8f3320..1f760d4 100644
--- a/src/tui/widgets/badge.rs
+++ b/src/tui/widgets/badge.rs
@@ -15,15 +15,9 @@ pub fn resolution_label(resolution: i64) -> &'static str {
2160 | 4320 => "4K",
1080 => "1080p",
720 => "720p",
- 480 | 540 | 576 => "SD",
- _ if resolution > 0 => match resolution {
- 2160 => "4K",
- 1080 => "1080p",
- 720 => "720p",
- 480 => "480p",
- 360 => "360p",
- _ => "HD",
- },
+ 480 | 540 | 576 => "480p",
+ 360 => "360p",
+ _ if resolution > 0 => "HD",
_ => "SD",
}
}
@@ -38,18 +32,9 @@ pub fn resolution_badge_spans<'a>(
2160 | 4320 => ("[4K]", theme.rating.add_modifier(Modifier::BOLD)),
1080 => ("[1080p]", theme.highlight.add_modifier(Modifier::BOLD)),
720 => ("[720p]", theme.teal.add_modifier(Modifier::BOLD)),
- 480 | 540 | 576 => ("[SD]", theme.text_dim.add_modifier(Modifier::BOLD)),
- _ if resolution > 0 => (
- match resolution {
- 2160 => "[4K]",
- 1080 => "[1080p]",
- 720 => "[720p]",
- 480 => "[480p]",
- 360 => "[360p]",
- _ => "[HD]",
- },
- theme.text.add_modifier(Modifier::BOLD),
- ),
+ 480 | 540 | 576 => ("[480p]", theme.text_dim.add_modifier(Modifier::BOLD)),
+ 360 => ("[360p]", theme.text_dim.add_modifier(Modifier::BOLD)),
+ _ if resolution > 0 => ("[HD]", theme.text.add_modifier(Modifier::BOLD)),
_ => ("[SD]", theme.text_dim),
};
return vec![Span::styled(format!("{:<7}", label), style), Span::raw(" ")];
@@ -86,19 +71,17 @@ pub fn resolution_badge_spans<'a>(
480 | 540 | 576 => (
theme_color(theme.surface2, Color::Rgb(88, 91, 112)),
theme_color(theme.text, Color::White),
- " SD ",
+ " 480p ",
+ ),
+ 360 => (
+ theme_color(theme.surface2, Color::Rgb(88, 91, 112)),
+ theme_color(theme.text, Color::White),
+ " 360p ",
),
_ if resolution > 0 => (
theme_color(theme.surface2, Color::Rgb(88, 91, 112)),
theme_color(theme.text, Color::White),
- match resolution {
- 2160 => " 4K ",
- 1080 => " 1080p ",
- 720 => " 720p ",
- 480 => " 480p ",
- 360 => " 360p ",
- _ => " HD ",
- },
+ " HD ",
),
_ => (
theme_color(theme.surface2, Color::Rgb(88, 91, 112)),
@@ -364,8 +347,8 @@ mod tests {
assert_eq!(resolution_label(2160), "4K");
assert_eq!(resolution_label(1080), "1080p");
assert_eq!(resolution_label(720), "720p");
- assert_eq!(resolution_label(480), "SD");
- assert_eq!(resolution_label(576), "SD");
+ assert_eq!(resolution_label(480), "480p");
+ assert_eq!(resolution_label(576), "480p");
assert_eq!(resolution_label(360), "360p");
assert_eq!(resolution_label(0), "SD");
}
diff --git a/tests/live_stream_verification.rs b/tests/live_stream_verification.rs
new file mode 100644
index 0000000..d09ab5f
--- /dev/null
+++ b/tests/live_stream_verification.rs
@@ -0,0 +1,92 @@
+use moviebox_tui::providers::moviebox::client::MovieBoxClient;
+
+#[tokio::test]
+#[ignore = "live network test; run with cargo test --test live_stream_verification -- --ignored"]
+async fn test_live_movie_stream_real_urls() {
+ let client = MovieBoxClient::new();
+ client.init().await.expect("client init successful");
+
+ // Avatar subject_id: 1654274595068805784
+ let (items, _) = client
+ .fetch_resource_page("1654274595068805784", 0, 1)
+ .await
+ .expect("fetch resource page");
+ assert!(!items.is_empty(), "items should not be empty");
+
+ let notice_hash = "1c7de0bd3393702d9191801f15f88f8d";
+ let mut real_streams_found = 0;
+
+ for item in &items {
+ if let Some(link) = item.get("resourceLink").and_then(|l| l.as_str()) {
+ println!("Movie stream link: {}", link);
+ assert!(
+ !link.contains(notice_hash),
+ "Stream URL should NOT be the legacy upgrade notice video: {}",
+ link
+ );
+ assert!(
+ link.contains("bcdn.hakunaymatata.com") || link.contains("sign="),
+ "Stream URL should be a signed CDN link: {}",
+ link
+ );
+ real_streams_found += 1;
+ }
+ }
+
+ assert!(
+ real_streams_found > 0,
+ "Should find at least one real movie stream"
+ );
+}
+
+#[tokio::test]
+#[ignore = "live network test; run with cargo test --test live_stream_verification -- --ignored"]
+async fn test_live_series_resolutions_and_streams() {
+ let client = MovieBoxClient::new();
+ client.init().await.expect("client init successful");
+
+ // Loki subject_id: 8449792878959887920
+ let resolutions = client
+ .fetch_collection_resolutions("8449792878959887920")
+ .await
+ .expect("fetch collection resolutions");
+
+ println!("Series resolutions: {:?}", resolutions);
+ assert!(!resolutions.is_empty(), "resolutions should not be empty");
+ assert!(
+ resolutions.contains(&1080) || resolutions.contains(&720) || resolutions.contains(&480),
+ "resolutions should contain standard qualities: {:?}",
+ resolutions
+ );
+
+ // Fetch season 1 episode 1
+ let res = client
+ .get_resources("8449792878959887920", 1, 1, 1, None, 20)
+ .await
+ .expect("fetch episode resources");
+
+ let items = res
+ .get("list")
+ .and_then(|l| l.as_array())
+ .cloned()
+ .unwrap_or_default();
+ let notice_hash = "1c7de0bd3393702d9191801f15f88f8d";
+ let mut episode_streams_found = 0;
+
+ for item in &items {
+ if let Some(link) = item.get("resourceLink").and_then(|l| l.as_str()) {
+ println!("Episode stream link: {}", link);
+ assert!(
+ !link.contains(notice_hash),
+ "Episode stream URL should NOT be the legacy upgrade notice video: {}",
+ link
+ );
+ episode_streams_found += 1;
+ }
+ }
+
+ assert!(
+ episode_streams_found > 0,
+ "Should find at least one real episode stream"
+ );
+}