Skip to main content

Overview

Library management commands handle media items (movies, TV shows, episodes) stored locally or in Google Drive. All commands return Promise-based results through the Tauri IPC bridge.

Commands

get_library

Retrieve library items filtered by media type.
#[tauri::command]
async fn get_library(
    state: State<'_, AppState>,
    media_type: String,
    search: Option<String>,
) -> Result<Vec<database::MediaItem>, String>
media_type
string
required
Type of media to retrieve: "movie" or "tv"
Optional search query to filter results by title
MediaItem[]
array
Array of media items matching the criteria

get_library_filtered

Get library items with cloud storage filtering.
#[tauri::command]
async fn get_library_filtered(
    state: State<'_, AppState>,
    media_type: String,
    search: Option<String>,
    is_cloud: Option<bool>,
) -> Result<Vec<database::MediaItem>, String>
media_type
string
required
Type of media: "movie" or "tv"
search
string | null
Optional search query
is_cloud
boolean | null
Filter by cloud storage:
  • true: Only cloud media
  • false: Only local media
  • null: All media

get_media_info

Retrieve detailed information for a specific media item.
#[tauri::command]
async fn get_media_info(
    state: State<'_, AppState>,
    media_id: i64,
) -> Result<database::MediaItem, String>
media_id
number
required
Database ID of the media item

get_episodes

Get all episodes for a TV show series.
#[tauri::command]
async fn get_episodes(
    state: State<'_, AppState>,
    series_id: i64,
) -> Result<Vec<database::MediaItem>, String>
series_id
number
required
Database ID of the parent TV show
MediaItem[]
array
Array of episode items with season_number, episode_number, and episode_title fields populated

delete_media_files

Permanently delete media files from disk or Google Drive.
#[tauri::command]
async fn delete_media_files(
    state: State<'_, AppState>,
    media_ids: Vec<i64>,
) -> Result<DeleteResponse, String>
media_ids
number[]
required
Array of media IDs to delete
DeleteResponse
object
This permanently deletes files. Cloud files are removed from Google Drive. Local files bypass the recycle bin.

get_resume_info

Get playback resume information for a media item.
#[tauri::command]
async fn get_resume_info(
    state: State<'_, AppState>,
    media_id: i64,
) -> Result<database::ResumeInfo, String>
media_id
number
required
Media item database ID
ResumeInfo
object

update_resume_position

Alias for update_progress. Updates the playback position for a media item.
#[tauri::command]
async fn update_progress(
    state: State<'_, AppState>,
    media_id: i64,
    current_time: f64,
    duration: f64,
) -> Result<ApiResponse, String>
media_id
number
required
Media item ID
current_time
number
required
Current playback position in seconds
duration
number
required
Total duration in seconds
Progress is automatically reset to 0 when playback reaches 95% completion.

mark_watched

Mark a media item as fully watched (100% complete).
#[tauri::command]
async fn mark_as_complete(
    state: State<'_, AppState>,
    media_id: i64,
) -> Result<ApiResponse, String>
media_id
number
required
Media item to mark as watched

mark_unwatched

Reset playback progress to unwatched state.
#[tauri::command]
async fn clear_progress(
    state: State<'_, AppState>,
    media_id: i64,
) -> Result<ApiResponse, String>
media_id
number
required
Media item to reset

get_watch_history

Retrieve recently watched media items.
#[tauri::command]
async fn get_watch_history(
    state: State<'_, AppState>,
    limit: Option<i32>,
) -> Result<Vec<database::MediaItem>, String>
limit
number
Maximum number of items to return (default: 50)
MediaItem[]
array
Array of media items ordered by last_watched timestamp (most recent first)

Build docs developers (and LLMs) love