mark watched and unwatched
This commit is contained in:
+42
-5
@@ -143,6 +143,43 @@ impl JellyfinClient {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn mark_played(&self, user_id: &str, item_id: &str) -> Result<(), String> {
|
||||
let base = self.base_url.trim_end_matches('/');
|
||||
let url = format!("{base}/Users/{user_id}/PlayedItems/{item_id}");
|
||||
|
||||
let resp = self
|
||||
.client
|
||||
.post(url)
|
||||
.header("X-Emby-Token", &self.token)
|
||||
.send()
|
||||
.map_err(|e| format!("mark_played request failed: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!("mark_played failed: HTTP {}", resp.status()));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn mark_unplayed(&self, user_id: &str, item_id: &str) -> Result<(), String> {
|
||||
let base = self.base_url.trim_end_matches('/');
|
||||
let url = format!("{base}/Users/{user_id}/PlayedItems/{item_id}");
|
||||
|
||||
let resp = self
|
||||
.client
|
||||
.delete(url)
|
||||
.header("X-Emby-Token", &self.token)
|
||||
.send()
|
||||
.map_err(|e| format!("mark_unplayed request failed: {e}"))?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!("mark_unplayed failed: HTTP {}", resp.status()));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
pub fn list_views(&self, user_id: &str) -> Result<Vec<JfItem>, String> {
|
||||
let url = format!("{}/Users/{}/Views", self.base_url, user_id);
|
||||
|
||||
@@ -416,19 +453,19 @@ pub struct JfStudio {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[derive(Deserialize, Clone, Debug, Default)]
|
||||
pub struct JfUserData {
|
||||
#[serde(rename = "Played")]
|
||||
pub played: Option<bool>,
|
||||
|
||||
#[serde(rename = "PlaybackPositionTicks")]
|
||||
pub playback_position_ticks: Option<i64>,
|
||||
|
||||
#[serde(rename = "PlayedPercentage")]
|
||||
pub played_percentage: Option<f64>,
|
||||
|
||||
#[serde(rename = "PlaybackPositionTicks")]
|
||||
pub playback_position_ticks: Option<i64>,
|
||||
|
||||
#[serde(rename = "UnplayedItemCount")]
|
||||
pub unplayed_item_count: Option<i64>,
|
||||
pub unplayed_item_count: Option<i32>,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user