Overview
StreamVault uses SQLite to organize your media library with intelligent TV show episode grouping, season organization, and automatic duplicate detection. The database stores metadata, progress, and relationships between series and episodes.Database Schema
The core database structure stores all media types in a single table with hierarchical relationships.Media Table
Media Types
movie- Standalone movie filestvshow- TV series container (virtual, no actual file)tvepisode- Individual episode (linked to tvshow viaparent_id)
TV Show Episode Grouping
StreamVault automatically groups episodes under their parent TV show using TMDB IDs and title matching.Series Detection
Finding Series by TMDB ID or Title
Creating TV Shows
tvshow://1396/breaking_bad
Linking Episodes
Fetching Episodes
- Episodes sorted by season first, then episode number
- Season 1 Episode 1 comes before Season 1 Episode 2
- Season 1 comes before Season 2
Season/Episode Organization
Episodes are organized hierarchically:Episode Metadata Cache
Episode metadata is pre-fetched from TMDB and cached:Caching Episode Metadata
- Faster episode browsing (no repeated TMDB calls)
- Offline metadata access
- Episode thumbnails pre-downloaded
Duplicate Detection
StreamVault prevents duplicate entries using unique file path constraints.Unique Constraint
Cloud File Duplicate Check
Orphan Cleanup
StreamVault detects and removes orphaned media entries when files are deleted.Orphan Detection
Empty Series Cleanup
Image Cleanup
- No media entry references them
- Parent TV show is deleted
- Manual cleanup is triggered
Cloud Storage Integration
Cloud media is stored in the same table with special flags.Cloud Folder Management
Adding Cloud Media
Filtering by Source
App Settings Storage
Global settings are stored in a separate table.Settings Table
Storing Settings
gdrive_changes_token- Google Drive sync statelast_scan_time- Last library scan timestampuser_preferences- JSON blob of user preferences
Database Location
- Windows:
%APPDATA%/StreamVault/media_library.db - Linux:
~/.StreamVault/media_library.db - macOS:
~/Library/Application Support/StreamVault/media_library.db
%APPDATA%/StreamVault-Dev/media_library.db
Performance Optimizations
Indexes
Cascading Deletes
Troubleshooting
”Duplicate episodes appearing”
- Check for different file paths to the same episode
- Run orphan cleanup to remove duplicates
- Use Fix Match to consolidate under correct series
”TV show not grouping episodes”
- Ensure filenames have consistent naming (e.g., all use S01E01 format)
- Check that series title matches across episodes
- Use Fix Match on the series to set correct TMDB ID
”Database corruption”
- Close StreamVault completely
- Backup
media_library.db - Run SQLite integrity check:
sqlite3 media_library.db "PRAGMA integrity_check;" - If corrupted, restore from backup or re-scan library