- Create docs-vault/Streaming.md with full streaming architecture docs - Update docs-vault/Index.md to link to streaming documentation
4.5 KiB
4.5 KiB
Streaming System
Overview
Showy includes an in-app streaming system that embeds video players from external streaming APIs. The system supports 4 providers (8 total servers) and is designed to be easily extensible.
Architecture
StreamingSection (Entry Page UI)
└── StreamingPlayer (iframe + controls)
├── ServerSelector (dropdown)
├── EpisodeNavigator (season/episode grid)
└── AutoMarkWatchedPrompt
useStreamingStore (Zustand)
└── streaming-manager.ts (core logic)
└── providers/ (adapters per API)
├── vidlink.ts
├── vidking.ts
└── anyembed.ts
Providers
| Provider | Servers | Events | Progress | ID Support |
|---|---|---|---|---|
| #VidLink | 2 (Default, JW Player) | ✅ | ✅ | TMDB |
| #VidKing | 1 | ✅ | ✅ | TMDB |
| #AnyEmbed | 5 (server 1-5) | ❌ | ❌ | TMDB, IMDB |
VidLink
- Base:
https://vidlink.pro - Movie:
/movie/{tmdbId} - TV:
/tv/{tmdbId}/{season}/{episode} - Supports: autoplay, next button, custom player (JW), startAt, progress tracking via postMessage
VidKing
- Base:
https://www.vidking.net - Movie:
/embed/movie/{tmdbId} - TV:
/embed/tv/{tmdbId}/{season}/{episode} - Supports: autoPlay, nextEpisode button, episodeSelector, progress resume, color customization
AnyEmbed
- Base:
https://anyembed.xyz - Movie:
/movie/{id}(TMDB or IMDB withttprefix) - TV:
/tv/{id}/{season}/{episode} - Supports:
?server={1-5}parameter for server selection
Key Files
| File | Purpose |
|---|---|
src/lib/streaming/types.ts |
All TypeScript interfaces |
src/lib/streaming/streaming-manager.ts |
Core logic, persistence, validation |
src/lib/streaming/providers/*.ts |
Provider adapters |
src/stores/useStreamingStore.ts |
Zustand state management |
src/components/streaming/StreamingPlayer.tsx |
Player component |
src/components/streaming/StreamingSection.tsx |
Entry page integration |
src/components/streaming/ServerSelector.tsx |
Server picker |
src/components/streaming/EpisodeNavigator.tsx |
Episode navigation |
Data Flow
- User clicks "Watch Now" / "Continue Watching" on Entry Details Page
StreamingSectiondetermines the request (movie or TV + season/episode)useStreamingStore.play()builds a URL via the active server's provider adapterStreamingPlayerrenders an iframe with the embed URL- Player events (postMessage) update localStorage progress
- On
endedevent: auto-mark-as-watched if enabled, or prompt user
Persistence (localStorage)
| Key | Purpose |
|---|---|
showy_preferred_server |
Last selected server ID |
showy_watch_progress |
Per-entry playback progress |
showy_auto_mark_watched |
Auto-mark config { enabled, threshold } |
showy_auto_mark_prompt_shown |
Whether prompt was shown |
showy_watch_logs |
Completed watch events (for future DB backup) |
Security
- Embed URLs validated against allowlist of origins
- postMessage origins checked before processing events
- iframe sandbox:
allow-scripts allow-same-origin allow-forms allow-popups allow-presentation - iframe allow:
autoplay; fullscreen; picture-in-picture; encrypted-media
Server Switching
- Users can switch servers at any time via the overlay dropdown
- Preference is persisted to localStorage
- On failure: error UI with "Try Another Server" button (cycles to next server)
tryNextServer()iterates through all servers before showing "all unavailable"
Continue Watching Logic
- Check
showy_watch_progresslocalStorage for TMDB ID - If TV: use
lastSeasonWatched/lastEpisodeWatched - Fallback: check
episodeSeensfrom database (last watched → suggest next) - Default: Season 1, Episode 1
Auto-Mark-as-Watched
- First time a movie/episode ends → prompt user to enable
- If enabled: automatically calls
useCreateEntrySeenoruseCreateEpisodeSeen - Threshold: 90% of duration (configurable)
- Decision stored in localStorage, prompt only shown once
Adding a New Provider
- Create
src/lib/streaming/providers/newprovider.ts - Implement
StreamingProviderinterface - Export from
providers/index.ts - Import in
streaming-manager.tsand add toprovidersarray
Related
- Backend — Future: watch logs backup endpoint
- Frontend — Component architecture
- Watch Tracking — Existing episode/entry seen system
- Settings Page — Potential streaming settings section