Overview
Library types manage the user’s media collection including watched state, progress tracking, and metadata.LibraryBucket
Container for all library items belonging to a user.User ID (Option<UserId>) - None if not authenticated
Map of library items keyed by item ID
Methods
new(uid: UID, items: Vec<LibraryItem>) -> Self
Create a new library bucket from a user ID and list of items.
merge_bucket(&mut self, bucket: LibraryBucket)
Merge another library bucket into this one (only if UIDs match).
merge_items(&mut self, items: Vec<LibraryItem>)
Merge individual items into the library. Items are updated only if the new item has a newer mtime.
are_ids_in_recent(&self, ids: &[String]) -> bool
Check if all given IDs are in the most recent items.
split_items_by_recent(&self) -> (Vec<&LibraryItem>, Vec<&LibraryItem>)
Split items into recent and other items based on LIBRARY_RECENT_COUNT.
LibraryItem
Represents a single item in the user’s library.Unique identifier (serialized as
_id)Item name/title
Content type (e.g., “movie”, “series”, “other”)
URL to the poster image
Shape of the poster (Square, Landscape, or Poster)
Whether the item has been removed from the library
Whether this is a temporary item
Creation time (serialized as
_ctime)Modification time (serialized as
_mtime)Current state including watch progress
Behavior hints from metadata
Methods
should_sync<E: Env + 'static>(&self) -> bool
Determine if this item should be synced with the server.
is_in_continue_watching(&self) -> bool
Check if this item should appear in continue watching.
progress(&self) -> f64
Calculate watch progress as a percentage (0-100).
watched(&self) -> bool
Check if the item has been watched.
should_pull_notifications(&self) -> bool
Determine if notifications should be pulled for this item. Returns true for:
- Series (not movies or other)
- Items without a default video ID
- Non-removed, non-temporary items
- Items with notifications enabled (
!no_notif)
mark_as_watched<E: Env>(&mut self, is_watched: bool)
Mark the entire item as watched or unwatched.
mark_video_as_watched<E: Env>(&mut self, watched: &WatchedBitField, video: &Video, is_watched: bool)
Mark a specific video as watched/unwatched.
mark_videos_as_watched<E: Env>(&mut self, watched: &WatchedBitField, videos: Vec<&Video>, is_watched: bool)
Mark multiple videos as watched/unwatched.
LibraryItemState
Tracks the current state of a library item.Last time this item was watched. Updated when:
- Playing the item
- Marking as watched
- Marking a video as watched (if released date is more recent)
Total time watched in milliseconds
Current playback position in milliseconds
Overall time watched in milliseconds
Number of times this item has been watched
Flag indicating a movie has been watched
Total duration in milliseconds
ID of the last video watched. For items without videos, this is either
behavior_hints.default_video_id or the meta.idBitfield tracking which videos have been watched. None for items without videos.
Whether to disable notifications for this item
Methods
watched_bitfield(&self, videos: &[Video]) -> WatchedBitField
Construct a watched bitfield from the state and video list.
Related Types
PosterShape
Enum defining poster aspect ratios:Square: 1:1 aspect ratioLandscape: Wide horizontal formatPoster: Standard poster format (default)
LibraryBucketRef
A reference version of LibraryBucket for serialization.Reference to user ID
Map of item references
