feat(plex): checkpoint plex lan integration and quality sync

cx
This commit is contained in:
vicrodh committed 2026-02-09 01:28:11 -06:00
1 parent d2531ea700
commit 228563454b
28 files changed
+2596 -107

No files matched your search

+1
View File
@@ -936,6 +936,7 @@ async fn play_album(
album_id: Some(album.id.clone()),
artist_id: t.performer.as_ref().map(|p| p.id),
streamable: t.streamable,
source: Some("qobuz".to_string()),
}
}).collect()
} else {
@@ -37,6 +37,7 @@ pub fn set_playback_context(
let content_source = match source.as_str() {
"qobuz" => ContentSource::Qobuz,
"local" => ContentSource::Local,
"plex" => ContentSource::Plex,
_ => return Err(format!("Invalid source: {}", source)),
};
+1
View File
@@ -327,6 +327,7 @@ fn track_to_queue_track(track: &Track) -> QueueTrack {
album_id,
artist_id,
streamable: track.streamable,
source: Some("qobuz".to_string()),
}
}
+17
View File
@@ -26,6 +26,7 @@ pub mod musicbrainz;
pub mod network;
pub mod offline;
pub mod playback_context;
pub mod plex;
pub mod player;
pub mod playlist_import;
pub mod queue;
@@ -672,6 +673,22 @@ pub fn run() {
cast::dlna::commands::dlna_stop,
cast::dlna::commands::dlna_seek,
cast::dlna::commands::dlna_set_volume,
// Plex LAN-only POC commands
plex::plex_ping,
plex::plex_get_music_sections,
plex::plex_get_section_tracks,
plex::plex_play_track,
plex::plex_auth_pin_start,
plex::plex_auth_pin_check,
plex::plex_open_auth_url,
plex::plex_cache_get_sections,
plex::plex_cache_save_sections,
plex::plex_cache_get_tracks,
plex::plex_cache_save_tracks,
plex::plex_cache_get_albums,
plex::plex_cache_get_album_tracks,
plex::plex_cache_search_tracks,
plex::plex_cache_clear,
// AirPlay casting commands - DISABLED until RAOP implementation is complete
// See docs/AIRPLAY_IMPLEMENTATION_STATUS.md for details
// cast::airplay::commands::airplay_start_discovery,
+1
View File
@@ -32,6 +32,7 @@ pub enum ContextType {
pub enum ContentSource {
Qobuz,
Local,
Plex,
}
/// Playback context - the semantic origin of playback
File diff suppressed because it is too large. Load diff
+3
View File
@@ -33,6 +33,9 @@ pub struct QueueTrack {
/// Whether the track is streamable on Qobuz (false = removed/unavailable)
#[serde(default = "default_streamable")]
pub streamable: bool,
/// Optional origin source (e.g. "qobuz", "local", "plex")
#[serde(default)]
pub source: Option<String>,
}
fn default_streamable() -> bool {
+25 -4
View File
@@ -27,6 +27,8 @@ pub struct PersistedQueueTrack {
pub artist_id: Option<u64>,
#[serde(default = "default_streamable")]
pub streamable: bool,
#[serde(default)]
pub source: Option<String>,
}
/// Represents the full persisted session state
@@ -110,7 +112,8 @@ impl SessionStore {
artwork_url TEXT,
hires INTEGER NOT NULL DEFAULT 0,
bit_depth INTEGER,
sample_rate REAL
sample_rate REAL,
source TEXT
);
-- Insert default row if not exists
@@ -158,6 +161,22 @@ impl SessionStore {
);
}
let has_source: bool = conn
.query_row(
"SELECT COUNT(*) FROM pragma_table_info('queue_tracks') WHERE name = 'source'",
[],
|row| row.get(0),
)
.unwrap_or(0) > 0;
if !has_source {
let _ = conn.execute_batch(
"
ALTER TABLE queue_tracks ADD COLUMN source TEXT;
"
);
}
Ok(Self { conn })
}
@@ -181,8 +200,8 @@ impl SessionStore {
// Insert queue tracks
for (pos, track) in session.queue_tracks.iter().enumerate() {
if let Err(e) = self.conn.execute(
"INSERT INTO queue_tracks (position, track_id, title, artist, album, duration_secs, artwork_url, hires, bit_depth, sample_rate, is_local, album_id, artist_id)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13)",
"INSERT INTO queue_tracks (position, track_id, title, artist, album, duration_secs, artwork_url, hires, bit_depth, sample_rate, is_local, album_id, artist_id, source)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14)",
params![
pos as i64,
track.id as i64,
@@ -197,6 +216,7 @@ impl SessionStore {
track.is_local as i64,
track.album_id,
track.artist_id.map(|v| v as i64),
track.source,
],
) {
let _ = self.conn.execute("ROLLBACK", []);
@@ -258,7 +278,7 @@ impl SessionStore {
// Load queue tracks
let mut stmt = self.conn
.prepare("SELECT track_id, title, artist, album, duration_secs, artwork_url, hires, bit_depth, sample_rate, is_local, album_id, artist_id FROM queue_tracks ORDER BY position")
.prepare("SELECT track_id, title, artist, album, duration_secs, artwork_url, hires, bit_depth, sample_rate, is_local, album_id, artist_id, source FROM queue_tracks ORDER BY position")
.map_err(|e| format!("Failed to prepare queue query: {}", e))?;
let tracks: Vec<PersistedQueueTrack> = stmt
@@ -277,6 +297,7 @@ impl SessionStore {
album_id: row.get(10)?,
artist_id: row.get::<_, Option<i64>>(11)?.map(|v| v as u64),
streamable: true, // Default to true for persisted tracks
source: row.get(12)?,
})
})
.map_err(|e| format!("Failed to query queue tracks: {}", e))?