Skip to content

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

refactor(core): decouple player, config, and updater for multi-frontend support

Samir Hossainsb8283d39a30b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d5d0643..143c305 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,10 @@
- **Selector Tab Preservation in Standard Displays**:
- Maintained visibility of Audio Languages, Seasons, and Episodes selector tabs side-by-side in standard ~80-column terminals when focusing Streams, preventing tabs from disappearing when 0 streams are available.
+### Changed
+- **Multi-System Core Module Decoupling**:
+ - Promoted `player.rs` (process management & detection), `config.rs` (shared configuration), and `updater.rs` (release checks) to core modules in `src/`, preparing the architecture for upcoming CLI and GUI frontends with full backward compatibility.
+
### Documentation
- **Streamlined README & Controls Guide**:
- Transformed `README.md` into a focused landing page with measured `~5 MB RAM` benchmark data, defensible value propositions, and direct links to deep guides in `docs/`.
diff --git a/docs/players.md b/docs/players.md
index a2b8c8c..62e8d97 100644
--- a/docs/players.md
+++ b/docs/players.md
@@ -1,6 +1,6 @@
# Players
-Playback is handed to an external player. `tui/player.rs` detects available players and
+Playback is handed to an external player. `player.rs` detects available players and
builds the exact command; `tui/app/playback.rs` spawns it.
## Detection
diff --git a/src/tui/config.rs b/src/config.rs
similarity index 100%
rename from src/tui/config.rs
rename to src/config.rs
diff --git a/src/lib.rs b/src/lib.rs
index fdccc15..3b95f3e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,6 +1,9 @@
pub mod cache;
+pub mod config;
pub mod download;
pub mod history;
pub mod logging;
+pub mod player;
pub mod providers;
pub mod tui;
+pub mod updater;
diff --git a/src/tui/player.rs b/src/player.rs
similarity index 93%
rename from src/tui/player.rs
rename to src/player.rs
index 60e60c7..3918149 100644
--- a/src/tui/player.rs
+++ b/src/player.rs
@@ -1,6 +1,43 @@
-use crate::tui::state::PlayerKind;
use std::{path::Path, process::Command};
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum PlayerKind {
+ Mpv,
+ Iina,
+ Vlc,
+ AndroidIntent,
+}
+
+impl PlayerKind {
+ pub fn label(&self) -> &'static str {
+ match self {
+ PlayerKind::Mpv => "mpv",
+ PlayerKind::Iina => "IINA",
+ PlayerKind::Vlc => "VLC",
+ PlayerKind::AndroidIntent => "Android Player",
+ }
+ }
+
+ pub fn config_key(&self) -> &'static str {
+ match self {
+ PlayerKind::Mpv => "mpv",
+ PlayerKind::Iina => "iina",
+ PlayerKind::Vlc => "vlc",
+ PlayerKind::AndroidIntent => "android",
+ }
+ }
+
+ pub fn parse(value: &str) -> Option<PlayerKind> {
+ match value.to_ascii_lowercase().as_str() {
+ "mpv" => Some(PlayerKind::Mpv),
+ "iina" => Some(PlayerKind::Iina),
+ "vlc" => Some(PlayerKind::Vlc),
+ "android" | "androidintent" | "android-intent" => Some(PlayerKind::AndroidIntent),
+ _ => None,
+ }
+ }
+}
+
const MPV_WINDOWS: &str = r"C:\Program Files\mpv\mpv.exe";
const MPV_MACOS: &str = "/Applications/mpv.app/Contents/MacOS/mpv";
const VLC_WINDOWS: &str = r"C:\Program Files\VideoLAN\VLC\vlc.exe";
diff --git a/src/tui/mod.rs b/src/tui/mod.rs
index 126cd01..3628ef7 100644
--- a/src/tui/mod.rs
+++ b/src/tui/mod.rs
@@ -1,14 +1,14 @@
pub mod action;
pub mod app;
-pub mod config;
+pub use crate::config;
pub mod event;
pub mod overlay;
-pub mod player;
+pub use crate::player;
pub mod state;
pub mod terminal;
pub mod text;
pub mod theme;
-pub mod updater;
+pub use crate::updater;
pub fn clear_area(frame: &mut ratatui::Frame, area: ratatui::layout::Rect, _theme: &theme::Theme) {
frame.render_widget(ratatui::widgets::Clear, area);
diff --git a/src/tui/state.rs b/src/tui/state.rs
index 590cf78..fd63388 100644
--- a/src/tui/state.rs
+++ b/src/tui/state.rs
@@ -1,43 +1,7 @@
use crate::providers::models::ProviderKind;
use ratatui::widgets::{ListState, TableState};
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub enum PlayerKind {
- Mpv,
- Iina,
- Vlc,
- AndroidIntent,
-}
-
-impl PlayerKind {
- pub fn label(&self) -> &'static str {
- match self {
- PlayerKind::Mpv => "mpv",
- PlayerKind::Iina => "IINA",
- PlayerKind::Vlc => "VLC",
- PlayerKind::AndroidIntent => "Android Player",
- }
- }
-
- pub fn config_key(&self) -> &'static str {
- match self {
- PlayerKind::Mpv => "mpv",
- PlayerKind::Iina => "iina",
- PlayerKind::Vlc => "vlc",
- PlayerKind::AndroidIntent => "android",
- }
- }
-
- pub fn parse(value: &str) -> Option<PlayerKind> {
- match value.to_ascii_lowercase().as_str() {
- "mpv" => Some(PlayerKind::Mpv),
- "iina" => Some(PlayerKind::Iina),
- "vlc" => Some(PlayerKind::Vlc),
- "android" | "androidintent" | "android-intent" => Some(PlayerKind::AndroidIntent),
- _ => None,
- }
- }
-}
+pub use crate::player::PlayerKind;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Screen {
diff --git a/src/tui/updater.rs b/src/updater.rs
similarity index 100%
rename from src/tui/updater.rs
rename to src/updater.rs