Skip to content

Commit

Permalink
Merge pull request #461 from Stremio/feat/library-item-stream-id
Browse files Browse the repository at this point in the history
feat: library item progress
  • Loading branch information
elpiel authored Sep 13, 2023
2 parents e523982 + f88598f commit 1259c0c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/types/library/library_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ impl LibraryItem {
self.r#type != "other" && (!self.removed || self.temp) && self.state.time_offset > 0
}

/// Returns watch progress percentage
#[inline]
pub fn progress(&self) -> f64 {
if self.state.time_offset > 0 && self.state.duration > 0 {
(self.state.time_offset as f64 / self.state.duration as f64) * 100.0
} else {
0.0
}
}

/// Pulling notifications relies on a few key things:
///
/// - LibraryItem should not be "other" or "movie", i.e. if you have "series" it will pull notifications
Expand Down

0 comments on commit 1259c0c

Please sign in to comment.