Overview
Media items represent individual pieces of content in your ErsatzTV libraries: movies, TV episodes, music videos, songs, and images. The Media Items API provides query and management capabilities.The Media Items API is primarily accessed through the web UI search and browse interfaces. Direct API endpoints for media item queries are provided through the search functionality.
Media Item Types
ErsatzTV supports the following media types:Movies
Feature films and standalone video content
TV Episodes
Television show episodes organized by series and season
Music Videos
Music video clips with artist and album metadata
Songs
Audio tracks with album and artist information
Images
Still images for display (e.g., channel logos, artwork)
Other Videos
Miscellaneous video content not categorized as movies or episodes
Media Item Structure
Movie Metadata
Movies include:- Title
- Release year
- Plot summary
- Genres
- Content rating
- Runtime
- IMDb/TMDB IDs
- Poster and backdrop artwork
- Subtitle tracks
- Audio tracks
- Video codec information
Episode Metadata
TV episodes include:- Series title
- Season number
- Episode number
- Episode title
- Air date
- Plot summary
- Poster artwork
- Subtitle tracks
- Audio tracks
- Video codec information
Music Video Metadata
Music videos include:- Track title
- Artist name(s)
- Album name
- Release year
- Genre
- Duration
- Thumbnail artwork
Accessing Media Items
Through Collections
The primary way to work with media items programmatically is through Smart Collections:Through Search
ErsatzTV’s search functionality indexes all media items. While search is primarily accessed through the web UI, it uses the same underlying media item data.Media Item Properties
Common Properties
All media items share these base properties:Unique media item identifier
Type:
Movie, Episode, MusicVideo, Song, Image, OtherVideoID of the library containing this item
File system or remote path to the media file
Item state:
Normal, Unavailable, FileNotFoundMetadata Properties
Primary title of the media item
Title used for sorting (e.g., “Matrix, The”)
Release or air year
List of genre tags
Custom tags for organization
Description or plot summary
Technical Properties
Runtime in HH:MM:SS format
Video codec (e.g., “h264”, “hevc”, “av1”)
Codec profile (e.g., “Main”, “High”)
Audio codec (e.g., “aac”, “ac3”, “dts”)
Number of audio channels (e.g., 2, 6 for 5.1)
Video resolution (e.g., “1920x1080”, “3840x2160”)
Frames per second (e.g., 23.976, 29.97)
Media Item States
Media items can be in different states:Normal
Item is available and accessible for playback.Unavailable
Item is temporarily unavailable (e.g., remote server offline).FileNotFound
Item file no longer exists. Item is moved to trash during next library scan.Media Item Operations
Indexing
Media items are automatically indexed during library scans:Metadata Refresh
Metadata is refreshed during library scans. For immediate refresh:- Navigate to the item in the web UI
- Click Refresh Metadata
- Or trigger a library scan via API
Trash Management
Items marked for deletion are moved to trash:Working with Media Items
Creating Collections
Group media items using smart collections:Scheduling Content
Add media items to channel schedules:- Create a collection containing desired items
- Add the collection to a channel schedule
- Content plays according to schedule rules
Query Syntax
Smart collections use a query language to filter media:Basic Queries
Logical Operators
Ranges
Episode Queries
Query syntax is case-insensitive. Use quotes for multi-word values.
Media Item Artwork
Artwork is cached and served via the artwork endpoint:- Poster - Vertical artwork for movies and shows
- Thumbnail - Episode thumbnails
- Backdrop - Horizontal background images
- Logo - Channel and show logos
Subtitles
Media items can include subtitle tracks:Embedded Subtitles
Subtitles embedded in the media file container.External Subtitles
Sidecar subtitle files (.srt, .ass, .vtt).
Subtitle Extraction
Extract embedded subtitles to external files:Best Practices
Use Collections
Manage groups of media items with smart collections instead of individual items
Regular Scans
Schedule regular library scans to keep media metadata up to date
Clean Trash
Periodically empty trash to remove deleted items from the database
Monitor States
Check for items in
FileNotFound state and remove from schedulesTroubleshooting
Media Not Appearing
If media items don’t appear after adding files:- Trigger a library scan:
POST /api/libraries/{id}/scan - Check library path permissions
- Verify file formats are supported
- Review scan logs for errors
Missing Metadata
If metadata is incomplete:- Ensure files follow proper naming conventions
- Check metadata provider settings (TMDB, TVDB)
- Manually refresh metadata in the web UI
- Consider re-scanning with deep scan enabled
Playback Issues
If media items won’t play:- Verify file paths are accessible
- Check FFmpeg profile compatibility
- Review transcoding logs
- Test file playback outside ErsatzTV
Related APIs
- Libraries API - Scan and index media items
- Collections API - Group and organize media items
- Schedules API - Schedule media item playback
Next Steps
Collections
Create smart collections to organize media items
Schedules
Add media items to channel schedules
