Skip to content

Commit

Permalink
Merge pull request #133 from Radiicall/live-tv-issues
Browse files Browse the repository at this point in the history
Fix LiveTV issues (#131)
  • Loading branch information
Radiicall authored Jul 30, 2024
2 parents f17a896 + c7837be commit 6147b0e
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions jellyfin-rpc/src/jellyfin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,28 @@ impl Session {
_ => {}
}

if !self.play_state.is_paused {
let ticks_to_seconds = 10000000;
if self.play_state.is_paused
|| self.play_state.position_ticks.is_none()
|| self.now_playing_item.run_time_ticks.is_none()
{
return Ok(EndTime::Paused);
}

if let Some(mut position_ticks) = self.play_state.position_ticks {
position_ticks /= ticks_to_seconds;
let ticks_to_seconds = 10000000;

let runtime_ticks = self.now_playing_item.run_time_ticks / ticks_to_seconds;
let position_ticks =
self.play_state.position_ticks.expect("Unreachable error") / ticks_to_seconds;

return Ok(EndTime::Some(
SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() as i64
+ (runtime_ticks - position_ticks),
));
}
}
Ok(EndTime::Paused)
let runtime_ticks = self
.now_playing_item
.run_time_ticks
.expect("Unreachable error")
/ ticks_to_seconds;

Ok(EndTime::Some(
SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() as i64
+ (runtime_ticks - position_ticks),
))
}
}

Expand Down Expand Up @@ -161,7 +168,7 @@ pub struct NowPlayingItem {
#[serde(rename = "Type")]
pub media_type: MediaType,
pub id: String,
pub run_time_ticks: i64,
pub run_time_ticks: Option<i64>,
pub production_year: Option<i64>,
pub genres: Option<Vec<String>>,
pub external_urls: Option<Vec<ExternalUrl>>,
Expand Down

0 comments on commit 6147b0e

Please sign in to comment.