M3U playlist import and state
M3U playlist import turns a URL, local file, pasted playlist, or detected provider source into a saved channel source. The import path preserves channel and provider data so the player can show live channels, groups, favorites, recent channels, guide data, and suitable playback views. This page is a child of Playlist management and relates to Self-hosted source synchronization.
Import lifecycle
An import moves from a user-provided source to a normalized playlist and then to saved application state. The add flow presents direct M3U methods alongside provider connection methods and an auto-detect path. The same playlist shape supports browser and desktop flows. The desktop runtime can read local files and fetch remote sources for the app.
The import path connects source choice to parsing or provider discovery, normalization, persistence, and player navigation.
flowchart LR
A[URL, file, text, or provider details] --> B[Acquire or identify source]
B --> C[Parse M3U or validate provider]
C --> D[Normalize playlist]
D --> E[Save playlist state]
E --> F[Load channel views]
F --> G[Select and play channel]
Source acquisition
The add-playlist flow offers six methods: a remote M3U URL, a local file, raw M3U text, auto-detected source details, Xtream credentials, and a Stalker portal. URL input requires an HTTP or HTTPS address. File input accepts .m3u and .m3u8 names. Raw text goes straight to the parse step. The dialog keeps each method's unfinished form as a draft when the user changes methods. The M3U guide-import choice stays with the dialog and is hidden for provider methods or during a global guide opt-out without being reset. libs/…/add-playlist-dialog.component.ts• L117-194, libs/…/add-playlist-dialog.component.html• L10-110, libs/…/add-playlist-dialog.component.render.spec.ts• L76-194, libs/…/playlist-file-import.service.ts• L31-131
Auto-detect accepts pasted source details and presents possible source types with a confidence level. Candidate cards show safe summaries with passwords masked, including password values in URL queries and URL userinfo. The selected candidate keeps its original values for prefill. A selected result only prefills the matching normal form. The user still submits that form, so the usual validation, portal discovery, or connection test controls the source that is saved. libs/…/auto-import.component.ts• L61-145, libs/…/auto-import.component.ts• L193-268, libs/…/auto-import.component.html• L1-65, libs/…/add-playlist-dialog.component.ts• L186-264
The URL form can offer an optional handoff to Xtream when the entered M3U link has that provider shape. The handoff prefills the Xtream form, keeps the URL draft for a return to M3U, and leaves the final connection test or add action with the normal Xtream form. libs/…/add-playlist-dialog.component.ts• L248-265, libs/…/add-playlist-dialog.component.render.spec.ts• L220-285
For a remote source, the desktop path fetches the content with a bounded idle timeout and follows validated redirects. A local source is read as text. Both paths then use the M3U parser before the app creates its saved playlist object. A source that cannot be read or parsed does not become a playlist. apps/…/playlist-source.ts• L19-30, apps/…/playlist-source.ts• L85-163, libs/…/playlists.service.ts• L1165-1190
The import is asynchronous. A text or browser-file import first dispatches a parse request. The parse effect creates the playlist and dispatches an add request. Parse requests may run at the same time, but add and navigation work is serialized so a later import cannot cancel an earlier save. A temporary URL import can instead expose channel content only in memory when the caller does not want a saved playlist. libs/…/actions.ts• L25-65, libs/…/effects.ts• L399-481, libs/…/playlist.reducers.ts• L313-331
References: libs/…/add-playlist-dialog.component.ts• L117-194 libs/…/add-playlist-dialog.component.ts• L186-264 libs/…/add-playlist-dialog.component.html• L10-110 libs/…/add-playlist-dialog.component.render.spec.ts• L76-285 libs/…/auto-import.component.ts• L61-268 libs/…/auto-import.component.html• L1-65 libs/…/playlist-file-import.service.ts• L31-131 apps/…/playlist-source.ts• L85-163 libs/…/actions.ts• L25-65 libs/…/effects.ts• L399-481
Portal source validation
A Stalker portal import creates a provider-backed playlist through portal discovery rather than M3U parsing. Discovery checks the entered portal with the submitted MAC identity and optional credentials, then classifies the result as a validated portal, an authentication refusal, or an unreachable panel. A panel-style source can still be saved with a fallback endpoint when it cannot be reached, while a canonical full portal that cannot complete its handshake remains unvalidated. libs/…/stalker-portal-import.component.ts• L366-519, libs/…/stalker-portal-import.component.spec.ts• L304-434
The form keeps the portal identity consistent across the async discovery step. It canonicalizes the MAC address and can derive the two device IDs from it. A derived pair is tied to that MAC and is saved as literal identity data, so a late edit cannot send one MAC with another MAC's IDs. The form also keeps portal credentials, session identity, token cadence, and account information needed for later reuse. libs/…/stalker-portal-import.component.ts• L217-336, libs/…/stalker-portal-import.component.ts• L379-561, libs/…/stalker-portal-import.component.spec.ts• L657-714
Portal feedback stays beside the source fields when the portal refuses the request. The form exposes the portal's reason, keeps the user able to correct the source, and waits for abandoned authentication work before allowing another attempt. Successful imports use a notice for validation or account expiry because the dialog closes after the playlist is saved. libs/…/stalker-portal-import.component.html• L8-32, libs/…/stalker-portal-import.component.ts• L473-518, libs/…/stalker-portal-import.component.spec.ts• L371-463
References: libs/…/stalker-portal-import.component.ts• L366-519 libs/…/stalker-portal-import.component.ts• L217-336 libs/…/stalker-portal-import.component.ts• L521-575 libs/…/stalker-portal-import.component.html• L8-32 libs/…/stalker-portal-import.component.spec.ts• L304-434
Playlist normalization
The normalized playlist keeps the parser header and item list as the source content, then adds application identity and usage data. Each channel receives an app ID. The playlist receives a title, item count, import time, last-use time, an empty favorite set, and the original URL or file path when one exists. libs/…/playlist.utils.ts• L369-417
The channel record carries the fields that later features need: name, group, guide identifiers, logo, request headers, stream URL, radio flag, catch-up data, and preserved raw M3U text. Raw text also lets the app recover supported DRM settings from KODIPROP lines. The parser accepts long stream URLs and keeps HTTP parameters separate from the stream URL. libs/…/parsed-playlist.interface.ts• L3-38, libs/…/channel.interface.ts• L7-37, docs/…/m3u-playlist-module.md• L45-57
After normalization, the playlist is persisted and the app navigates to it. The save flow also starts playlist-scoped guide loading. The active playlist content is not kept only on the screen. It remains available for reload, refresh, favorite hydration, and recent-channel presentation. libs/…/effects.ts• L371-425, libs/…/playlist.reducers.ts• L75-143
References: libs/…/playlist.utils.ts• L369-417 libs/…/channel.interface.ts• L7-37 libs/…/playlists.service.ts• L1165-1190 libs/…/effects.ts• L371-425 libs/…/playlist.reducers.ts• L75-143
Playlist utility behavior
Shared playlist utilities define the rules that turn parsed M3U data into useful application features. They keep source data stable while deriving names, guide sources, favorites, stream hints, and content type signals in one place.
Playlist-scoped guide sources
The importer reads remote XMLTV links from the M3U header attributes x-tvg-url, url-tvg, and tvg-url. It trims and de-duplicates the links. A small list is enabled as-is. A larger provider catalog is kept in full but only a bounded set is enabled automatically. The selection uses channel country and language hints when available, then falls back to the first five links when no match is possible. Header-declared local file links are not accepted as provider input. libs/…/playlist.utils.ts• L22-29, libs/…/playlist.utils.ts• L114-180
The playlist stores four related guide lists with distinct roles:
detectedEpgUrlsrecords remote links found in the source.epgUrlsrecords links enabled for playlist-local guide fetch and lookup.manualEpgUrlsrecords links that the user enabled. This list may include a local XMLTV path entered by the user.disabledEpgUrlsrecords detected links that the user turned off.
The state resolver combines enabled and manual links, removes disabled links, and avoids fetching a playlist-local link when the same link already exists in global settings. This lets a refresh preserve user choices instead of silently restoring provider defaults. Playlist load and playlist changes use the same fetch plan. The fetch plan skips playlists backed by server or MAC sources and avoids repeating URLs that were already fetched unless a forced refresh is requested. libs/…/playlist.utils.ts• L63-112, libs/…/playlist.interface.ts• L36-43, libs/…/playlist-scoped-epg-fetch.util.ts• L14-53, libs/…/playlist.reducers.ts• L88-103, libs/…/effects.ts• L485-518, libs/…/effects.ts• L627-682
The playlist information view lets users refresh a guide source, add one to global settings, remove it from the playlist, or add a local or remote source. It applies these changes as one resolved source state, so detected, enabled, manual, and disabled lists remain consistent. The editor normalizes and de-duplicates source values, clears cached data before completing a removal, and waits for pending removals before saving new inputs. Global guide opt-out hides management controls without discarding the saved source lists. Server-backed and MAC-backed playlists do not expose playlist-local source management. libs/…/playlist-epg-source-editor.ts• L52-126, libs/…/playlist-epg-source-editor.ts• L129-173, libs/…/playlist-epg-source-editor.ts• L186-256, libs/…/playlist-epg-source-editor.ts• L290-363, libs/…/playlist-info.component.spec.ts• L318-600
References: libs/…/playlist.utils.ts• L22-29 libs/…/playlist.utils.ts• L63-180 libs/…/playlist.interface.ts• L36-43 libs/…/playlist-scoped-epg-fetch.util.ts• L14-53 libs/…/playlist.reducers.ts• L88-103 libs/…/effects.ts• L485-518 libs/…/effects.ts• L627-682 libs/…/playlist-epg-source-editor.ts• L52-363 libs/…/playlist-info.component.spec.ts• L318-600
Favorite and stream derivation
M3U favorites are stored as channel URL strings. Utility code also accepts channel IDs when it rebuilds favorite channel objects, which supports older or mixed saved data. A global favorites view is a derived playlist-like object that combines matching channels from all saved playlists. It does not replace the source playlists. libs/…/playlist.utils.ts• L11-56
Stream type hints come from the URL path or from an extension query value. The query value takes priority because many IPTV stream endpoints do not expose a useful file extension. These hints help downstream playback choose media handling without changing the saved channel URL. libs/…/playlist.utils.ts• L420-454, libs/…/playback-media-extension.util.ts• L63-90
M3U entries can also signal finished video content rather than a live stream. A VOD signal comes from a known video container or a movie, movies, or VOD path segment. Radio entries and DASH entries are excluded from this signal. Episode markers in the name or a series path keep the entry out of movie metadata handling, while the player can still provide VOD playback controls for an episode. This decision is synchronous and conservative so the player can choose its initial layout before it requests movie metadata. libs/…/m3u-vod-detection.util.ts• L20-43, libs/…/m3u-vod-detection.util.ts• L46-61, libs/…/m3u-vod-detection.util.ts• L107-136
References: libs/…/playlist.utils.ts• L11-67 libs/…/playlist.utils.ts• L420-454 libs/…/playback-media-extension.util.ts• L63-90 libs/…/m3u-vod-detection.util.ts• L107-136 libs/…/dash.utils.ts• L5-17
Player-facing playlist features
The M3U player presents one channel source through several related views. The views share the same channel records and selection events, so choosing a channel from a group, favorite list, recent list, fullscreen panel, or guide leads to the same active playback state.
Playlist source switching
The playlist switcher gives the user a fast way to move between saved sources without leaving the workspace. It groups recent sources separately from the full source list and supports search, source-type filters, keyboard selection, source details, refresh, add, and removal. libs/…/playlist-switcher-panel.component.ts• L57-80, libs/…/playlist-switcher-panel.component.html• L83-169
The switcher keeps its search, type filter, empty state, and actions visible while only the source list scrolls. This preserves access to source controls when a user has many saved sources. On small screens, non-essential keyboard hints are hidden while the source actions remain available. libs/…/playlist-switcher-panel.component.scss• L21-33, libs/…/playlist-switcher-panel.component.scss• L128-165, libs/…/playlist-switcher-panel.component.scss• L197-202
Removing a source first hides it from source lists and offers a four-second Undo window. If the removed source was active, the app can move to a usable neighbor. Undo restores the source and the prior route when the user has not selected another source. Closing the message commits the removal at once. libs/…/source-removal.service.ts• L24-65, libs/…/source-removal.service.ts• L105-178, libs/…/source-removal-toast.component.ts• L19-35, libs/…/source-removal-toast.component.scss• L1-9
References: libs/…/playlist-switcher-panel.component.ts• L57-80 libs/…/playlist-switcher-panel.component.html• L83-169 libs/…/playlist-switcher-panel.component.scss• L21-33 libs/…/playlist-switcher-panel.component.scss• L128-165 libs/…/source-removal.service.ts• L105-178 libs/…/source-removal-toast.component.ts• L19-35 libs/…/source-removal-toast.component.scss• L1-9
Channel views
The main channel view supports all channels, groups, favorites, and recent channels. Search narrows the current view. All-channel and group views can sort by original playlist order or by name. The groups view can hide selected group titles while retaining the full source data for later management. The channel rail can also collapse and restore through shared M3U surface state. libs/…/channel-list-container.component.ts• L183-221, libs/…/all-channels-view.component.ts• L111-127, libs/…/groups-view.component.ts• L248-343, libs/…/video-player.component.ts• L717-723, libs/…/video-player.component.ts• L1129-1153
Large lists use virtual rendering so the player can present very large M3U sources without requiring every row to be visible at once. Guide progress and logos are added as side data for visible rows. This keeps presentation data separate from the saved channel array. libs/…/all-channels-view.component.ts• L62-75, libs/…/all-channels-view.component.ts• L129-154
The fullscreen channel panel reuses these views without changing the page route. It opens on the routed view, then lets the user switch locally among all channels, groups, favorites, and recent channels while playback remains in fullscreen. The panel offers only entries that can keep the fullscreen-owning web player mounted. Radio entries and recognized movie entries are left out when they would replace that player. DASH entries remain available even when an external player is selected because they must play inline. libs/…/m3u-fullscreen-channel-list.component.ts• L20-86, libs/…/video-player.component.ts• L287-321, libs/…/video-player.component.ts• L1545-1568
The player also supports number entry and PageUp/PageDown channel changes. These controls use the same channel playback request as list selection. They avoid changing channels while a menu, dialog, or scrollable list owns the key. In fullscreen, they apply the same inline-player filter as the panel. libs/…/video-player.component.ts• L1407-1543, libs/…/video-player.component.fullscreen-panel.spec.ts• L388-623
References: libs/…/channel-list-container.component.ts• L183-221 libs/…/all-channels-view.component.ts• L111-154 libs/…/groups-view.component.ts• L248-343 libs/…/m3u-fullscreen-channel-list.component.ts• L20-86 libs/…/video-player.component.ts• L287-321 libs/…/video-player.component.ts• L1407-1568
Guide channel views
The M3U guide presents guide-eligible channels in all-channel, favorite, or group scopes. It derives each guide key from the channel's tvg-id, then its tvg-name, then its display name. Selecting an active channel also loads its schedule with the channel's advertised archive-day window. A channel without a guide key clears the old schedule so the panel cannot show another channel's data. libs/…/m3u-epg-guide-source.service.ts• L45-57, libs/…/m3u-epg-guide-source.service.ts• L145-153, libs/…/effects.ts• L208-226, libs/…/active-channel-epg.effect.spec.ts• L14-78
The guide opens on the sidebar's current scope when that scope is a group or favorites view. A playing channel supplies the fallback group. Each displayed row has a scope-local identity with its position, so repeated channels can still show distinct rows and activate the row the user selected. Search results map back to the first matching row when several rows share one guide key. libs/…/m3u-epg-guide-source.service.ts• L68-181, libs/…/m3u-epg-guide-source.service.ts• L187-229, libs/…/m3u-epg-guide-source.service.ts• L274-307
The guide marks live playback separately from catch-up playback. Selecting a guide row dispatches the same M3U playback request used by the channel list, so guide navigation and list navigation update one active channel state. libs/…/m3u-epg-guide-source.service.ts• L180-181, libs/…/m3u-epg-guide-source.service.ts• L274-283
Guide mode hides the channel sidebar instead of removing it. This keeps the active channel mounted while the guide takes over the main view. The player remains in a compact dock when inline playback is available. The guide cannot open for radio or movie-detail entries, while fullscreen surfaces and open dialogs also block it. It closes when the active playlist changes. libs/…/video-player.component.html• L1-20, libs/…/video-player.component.html• L138-165, libs/…/video-player.component.ts• L331-355, libs/…/video-player.component.ts• L1341-1439
The live guide area can present either a timeline or a list view. Both views use the same programme data and actions for date changes, catch-up selection, return to live playback, guide settings, and guide opening. The player keeps the now-playing strip beside inline playback and uses an external dock when an external player owns the stream. libs/…/video-player.component.html• L138-255, libs/…/video-player.spec-stubs.ts• L13-50
References: libs/…/m3u-epg-guide-source.service.ts• L45-57 libs/…/m3u-epg-guide-source.service.ts• L68-181 libs/…/m3u-epg-guide-source.service.ts• L232-307 libs/…/effects.ts• L208-226 libs/…/active-channel-epg.effect.spec.ts• L14-78 libs/…/video-player.component.html• L1-20 libs/…/video-player.component.html• L138-255 libs/…/video-player.component.ts• L1341-1439
Playback navigation
Selecting a row makes that channel active. A playback request uses the same action with an explicit start flag, which lets one player surface handle both selection and immediate playback. The player also moves to adjacent channels for remote-control up and down actions. libs/…/channel-list-container.component.ts• L451-465, libs/…/actions.ts• L68-83, libs/…/m3u-channel-playback-actions.ts• L1-8, libs/…/video-player.component.ts• L1070-1114
The active channel can render as a video stream, an audio stream when the M3U radio flag is true, or a detail view for supported movie entries. Series episodes can use the VOD playback path without receiving movie metadata treatment. The player-facing view also includes the channel's guide when the runtime and playlist provide guide data. libs/…/video-player.component.html• L80-195, libs/…/m3u-vod-detection.util.ts• L126-136
Catch-up playback changes the effective stream URL and marks playback as non-live. When the archive URL includes a lower and upper time bound, the player turns the matching guide programmes into seek-bar segments. Live playback has no such segments. libs/…/video-player.component.ts• L373-435, libs/…/video-player-catchup-timeline.spec.ts• L209-245
The player workspace keeps channel navigation beside playback on wide screens and moves it to a bottom drawer on phone widths. When the guide is open, the channel list stays mounted but becomes hidden, while playback moves into a compact dock above the guide. This keeps the active channel and playback session in place as the user moves between channel browsing and guide views. libs/…/video-player.component.scss• L11-150, libs/…/video-player.component.html• L1-20
Playback state also carries the effective stream URL and request data for the active channel. Playlist-level and entry-level request headers are combined for playback. Preserved raw M3U text can supply DRM data for older imports. DASH streams stay inline and use a compatible player even when the user selected an external player. libs/…/video-player.component.ts• L489-567, libs/…/video-player.component.ts• L1662-1714, libs/…/effects.ts• L208-278
The player records a recent channel only after inline playback starts, while external playback records it at selection because the app cannot observe the external stream. The same player state also keeps the shared volume value current when a channel or VOD view mounts again. libs/…/video-player.component.ts• L1252-1313, libs/…/video-player.component.ts• L1620-1653
References: libs/…/channel-list-container.component.ts• L451-465 libs/…/actions.ts• L68-83 libs/…/m3u-channel-playback-actions.ts• L1-8 libs/…/video-player.component.html• L80-195 libs/…/video-player.component.ts• L373-435 libs/…/video-player.component.ts• L489-567 libs/…/video-player.component.ts• L1252-1313 libs/…/video-player-catchup-timeline.spec.ts• L209-245
M3U VOD detail views
An M3U entry recognized as a movie can open a detail view when TMDB enrichment is available and M3U movie details are enabled. The view uses a shared detail shell that combines the provider's channel facts with optional TMDB metadata. It starts with the entry name and logo, then adds title, artwork, summary, tags, rating, runtime, cast, and director data when the metadata lookup returns them. A missing match leaves the provider facts in place. libs/…/video-player.component.ts• L399-420, libs/…/m3u-vod-detail.component.ts• L43-57, libs/…/m3u-vod-detail.component.ts• L122-182, libs/…/m3u-vod-detail.component.html• L1-67
The detail view follows the player's watch-first behavior. Inline playback uses the playback payload already resolved by the parent. The user can close it to return to the browse view or start it again from the detail action. Users of MPV or VLC keep the browse layout because external playback is handled outside the inline player. libs/…/m3u-vod-detail.component.ts• L81-107, libs/…/m3u-vod-detail.component.ts• L201-231, libs/…/m3u-vod-detail.component.html• L36-57, libs/…/video-player.component.html• L80-93
The detail presentation keeps metadata separate from playback source identity. This prevents a later metadata result from restarting playback. A new channel still resets the detail state and starts a new metadata lookup. Starting playback also refreshes the shared volume state so a Browse-to-Play remount uses the user's latest volume. libs/…/m3u-vod-detail.component.ts• L109-129, libs/…/m3u-vod-detail.component.ts• L193-223, libs/…/video-player.component.ts• L1620-1627
The fullscreen panel is withheld while the VOD detail view owns playback. This avoids replacing the fullscreen-owning web player with a movie detail shell. libs/…/video-player.component.ts• L287-301, libs/…/video-player.component.fullscreen-panel.spec.ts• L322-334
References: libs/…/video-player.component.ts• L399-420 libs/…/m3u-vod-detail.component.ts• L43-57 libs/…/m3u-vod-detail.component.ts• L81-129 libs/…/m3u-vod-detail.component.ts• L193-231 libs/…/m3u-vod-detail.component.html• L1-67 libs/…/video-player.component.ts• L287-301
Favorites and recent channels
Favorites are toggled against the active playlist and can be reordered when the favorites view is not filtered. The saved order is represented by the URL list, while visible rows are rebuilt from current channel records. Favorite changes update both active store state and the durable playlist when a playlist is selected. libs/…/channel-list-container.component.ts• L467-499, libs/…/favorites-view.component.ts• L192-200, libs/…/actions.ts• L100-106, libs/…/effects.ts• L88-144
When playback selects a channel, the player records a compact M3U recent item. It keeps the channel URL and enough display and guide metadata to find the channel again. Inline playback records the item after playback starts. External playback records it on selection because the app cannot observe the external stream. Recent items are sorted by view time, de-duplicated by URL, and resolved back to the full current channel before display. Users can remove one item or clear the playlist's recent list. libs/…/video-player.component.ts• L1252-1313, libs/…/channel-list-container.component.ts• L277-318, libs/…/playlist-recently-viewed.interface.ts• L3-32
The recent-playlists information view presents saved playlist metadata and provides the playlist-level actions that affect later sessions. It can export the raw M3U source and edit playlist settings. Its guide-source controls update the same durable metadata used by import and refresh. Provider passwords stay masked until the user reveals them. Stalker edits load the complete saved connection before exposing advanced identity fields, then resolve a changed connection before the metadata update is applied. Shared-source edits also retain the source revision captured when the editor opened. The save must succeed before the in-memory state reports the change; a rejected revision leaves the editor open. libs/…/playlist-info.component.ts• L328-404, libs/…/playlist-info.component.ts• L428-535, libs/…/playlist-info.component.ts• L573-612, libs/…/playlist-info.component.html• L11-40, libs/…/playlist-info.source-sync.spec.ts• L105-186, libs/…/playlist-info-password.component.spec.ts• L95-127
Favorites and recent channels also have dedicated playlist routes. Those routes use the current playlist as their default scope, so a link opened from one playlist does not unexpectedly show a global collection. libs/…/m3u-workspace.routes.ts• L6-37, libs/…/m3u-collection-route.component.ts• L14-37
References: libs/…/favorites.reducers.ts• L5-61 libs/…/actions.ts• L100-106 libs/…/effects.ts• L88-144 libs/…/video-player.component.ts• L1252-1313 libs/…/playlist-recently-viewed.interface.ts• L3-32 libs/…/playlist-info.component.ts• L428-612 libs/…/playlist-info.source-sync.spec.ts• L105-186 libs/…/playlist-info-password.component.spec.ts• L95-127
Playlist state and content preservation
M3U state has two connected layers. Persisted playlist data holds the full channel source and user choices. The in-memory store holds the active playlist metadata plus the channel and playback state needed by the current route.
Persisted playlist data
The playlist record is the durable source for later sessions. Its M3U fields include the source location, parsed playlist payload, count, import and use dates, favorites, recent channels, guide source choices, refresh settings, and hidden group titles. A metadata projection carries the fields needed for playlist lists and route selection without carrying the full channel array. Shared sources also use a source revision to protect edits made from an older view. libs/…/playlist.interface.ts• L16-54, libs/…/playlist-meta.type.ts• L3-37, libs/…/playlist-info.component.ts• L450-461
Refresh replaces source content but preserves user-owned fields such as the playlist ID, refresh setting, favorites, and request user agent. Before a refresh replaces state, it must still match the current source identity. This rejects a delayed result captured before a URL, file path, or user-agent edit. Authoritative shared-source hydration can apply a changed source identity because it represents the accepted saved record. libs/…/playlist-refresh-source.util.ts• L3-37, libs/…/playlist.reducers.ts• L75-143, libs/…/playlist.reducers.spec.ts• L11-43, libs/…/playlist.reducers.spec.ts• L513-540
Refresh also reconciles detected, enabled, manual, and disabled guide sources instead of replacing those choices with new source defaults. It keeps the saved request user agent and auto-refresh choice when the new parser payload omits them or supplies only a default. The reducer tests treat these fields as user-owned refresh state, alongside hidden group titles. libs/…/playlist.reducers.ts• L88-137, libs/…/playlist.reducers.spec.ts• L482-640
State-only metadata updates can skip a second persistence call when another owner already saved the same change. Full playlist updates can request a guide refresh after persistence. The update action also carries an optional operation ID for tracing without sending that value to the database. A refresh publishes the persisted result rather than the downloaded candidate, so accepted server changes become the source for in-memory channel state. Shared-source edits use the same separation: the storage update resolves first, then the store receives the saved result without repeating the write. libs/…/actions.ts• L15-47, libs/…/effects.ts• L371-397, libs/…/effects.ts• L485-518, libs/…/playlist-update.effect-handler.ts• L3-28, libs/…/playlist-refresh.effect.spec.ts• L12-88, libs/…/playlist-info.source-sync.spec.ts• L139-186
The state entity map stores metadata only. Full playlist payloads stay in action and service boundaries, while the selected playlist's channel array is published into the separate active channel state. This prevents the channel list from being stored twice and keeps inventory reads light. libs/…/playlist.reducers.ts• L12-19, libs/…/playlist.reducers.spec.ts• L643-702
References: libs/…/playlist.interface.ts• L16-54 libs/…/playlist-meta.type.ts• L3-37 libs/…/playlist-refresh-source.util.ts• L3-37 libs/…/actions.ts• L15-47 libs/…/effects.ts• L371-397 libs/…/playlist-update.effect-handler.ts• L3-28 libs/…/playlist-refresh.effect.spec.ts• L12-88 libs/…/playlist.reducers.ts• L75-143 libs/…/playlist.reducers.spec.ts• L11-43 libs/…/playlist.reducers.spec.ts• L482-702 libs/…/playlist-info.source-sync.spec.ts• L139-186
In-memory route state
The store tracks the selected playlist ID, all loaded playlist metadata, the current channel array, the active channel, its playback URL, guide program state, guide availability, and channel loading status. The selected playlist identifies which durable record supplies the current channel content. Selectors expose the active playlist, its title, its favorites, its channels, and playback state as separate views for player and route consumers. libs/…/state.ts• L6-25, libs/…/playlists.state.ts• L4-20, libs/…/selectors.ts• L15-115
The route session loads channel data only for the all-channel and group routes. It marks the list as loading, reads the selected playlist, publishes its channel items, and hydrates saved favorites without issuing a second persistence write. Collection routes such as favorites and recent use their own views and do not drive the shared channel-list load. libs/…/m3u-workspace-route-session.service.ts• L60-104, libs/…/m3u-workspace-route-session.service.ts• L133-152, libs/…/m3u-workspace-route-session.service.spec.ts• L142-155, libs/…/m3u-workspace-route-session.service.spec.ts• L195-218
Before channel publication, the route session hydrates hidden group titles from the full playlist read because startup metadata may not include them. It waits for the playlist entity to exist in the store, and it does not overwrite a newer hidden-group edit that arrived while the read was pending. The update is state-only, so route hydration does not create a second database write. libs/…/m3u-workspace-route-session.service.ts• L106-122, libs/…/m3u-workspace-route-session.service.ts• L165-205, libs/…/m3u-workspace-route-session.service.spec.ts• L220-333
Loading also applies playlist-level request headers before it publishes channels. A playlist with no saved user agent or referrer clears an older Electron override, so a previous playlist cannot affect the next one. Channel publication records only the imported item count in renderer performance data and excludes channel names, URLs, titles, and credentials. libs/…/m3u-workspace-route-session.service.ts• L124-143, libs/…/m3u-workspace-route-session.service.spec.ts• L157-193, libs/…/m3u-workspace-route-session.performance.spec.ts• L91-127
Load request identity protects the store from a slow result for an old playlist or route. When the active playlist changes, the prior active channel is cleared. When loading fails, the current list and in-memory favorites are cleared rather than showing content from the wrong source. libs/…/m3u-workspace-route-session.service.ts• L60-89, libs/…/m3u-workspace-route-session.service.ts• L101-162, libs/…/m3u-workspace-route-session.service.spec.ts• L335-405
The playlist metadata state also records whether the playlist inventory has loaded, whether loading failed, and which source types are selected for the playlist list. Loading keeps failure visible instead of treating a failed inventory read as an empty playlist set. The reducer tests cover both initial failure and the reset of readiness when a backup replaces an already loaded inventory. libs/…/playlists.state.ts• L9-22, libs/…/playlist.reducers.ts• L21-55, libs/…/playlist.reducers.spec.ts• L233-270
References: libs/…/state.ts• L6-25 libs/…/playlists.state.ts• L9-22 libs/…/playlist.reducers.ts• L21-55 libs/…/selectors.ts• L45-115 libs/…/m3u-workspace-route-session.service.ts• L60-223 libs/…/m3u-workspace-route-session.service.spec.ts• L142-405 libs/…/m3u-workspace-route-session.performance.spec.ts• L91-127 libs/…/playlist.reducers.spec.ts• L233-270
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the accepted M3U source forms aligned between the add-playlist dialog, auto-detect prefill, file import service, desktop file bridge, and parser action.
- Preserve each import method's draft when changing method selection. A candidate handoff must replace only its target form and must not prefill a later unrelated visit.
- Keep the optional M3U guide-import choice aligned with the global guide preference. Hiding the control must not clear the current choice.
- Preserve channel identity and URL matching rules when changing the normalized channel shape. Favorites, recent records, and guide row activation depend on these values.
- Keep
detectedEpgUrls,epgUrls,manualEpgUrls, anddisabledEpgUrlsdistinct. A refresh must not re-enable a source that the user disabled. - Keep header-detected guide links remote-only. Local XMLTV paths are user input and must not enter through downloaded playlist headers.
- Keep playlist-scoped guide plans aligned with server and MAC playlist behavior. Do not fetch those sources as if they were ordinary M3U playlists.
- Keep guide fetch keys stable when changing URL filtering. A changed key controls whether the same guide source is fetched again.
- Ensure guide-source removal clears source data before the playlist leaves the enabled set. A cleanup failure must leave the source usable.
- Keep metadata-only updates separate from full playlist updates. The
persistflag is a state synchronization contract and must not cause an already-saved change to be written twice. - Keep shared-source edits tied to the source revision captured when the editor opens. Persist the accepted change before dispatching the state-only result, and keep a rejected revision visible in the editor.
- Hydrate the complete shared source before editing connection fields. A summary record must not replace the source baseline or clear fields that are absent from the summary.
- Keep operation IDs out of database payloads and persisted playlist data when changing update instrumentation.
- Publish the accepted persisted playlist after a refresh. Do not let the downloaded candidate replace a result changed or normalized by the persistence layer.
- Keep refresh-source matching aligned with URL, file path, and user-agent edits. A delayed result from an older source must not replace current playlist state, while authoritative shared hydration must still accept the saved source.
- Keep full playlist payloads out of the metadata entity map. Publish the selected channel array through active channel state instead of storing it a second time.
- Preserve serialized add behavior. Replacing it with canceling work can drop a rapid import's save, guide fetch, or navigation.
- Keep temporary URL imports out of durable playlist state unless the caller explicitly requests a saved playlist.
- Keep source-switcher search, type filters, recent grouping, and source actions usable when the source list grows. Only the list should consume the panel's scroll space.
- Keep source removal's pending state separate from committed deletion. The switcher must not reopen or remove a source during its Undo or long-delete window.
- Keep route load cancellation and active-playlist checks in place when changing channel publication. A late read must not overwrite a newer route.
- Keep hidden-group hydration before channel publication. Do not replace newer store metadata with an older queued playlist read.
- Keep playlist-level request-header reset behavior aligned with route changes. A missing override must clear the prior Electron value.
- Keep renderer performance metadata limited to safe aggregate values. Channel URLs, names, titles, and credentials must not enter performance events.
- Keep recent-item fields compatible with the URL-based lookup used to rebuild full M3U channel rows.
- Keep fullscreen row filters aligned with
keepsInlinePlayer. Radio and movie-detail rows must not replace the fullscreen-owning player, while DASH rows must remain available for inline playback. - Keep fullscreen number and adjacent-channel navigation aligned with the panel row filter and parental-lock checks.
- Keep guide row identity tied to the current guide scope when changing group, favorite, or duplicate-channel handling. Activation must resolve to the row that the guide rendered.
- Keep guide opening gated by fullscreen surfaces and dialogs. The guide must not open behind a surface that owns the screen or keyboard.
- Keep active-channel guide lookup tied to the channel's guide key and archive-day value. A channel without a key must clear the prior schedule.
- Keep catch-up timeline segments tied to the effective archive URL and its time bounds. Live playback must not show archive segments.
- Keep VOD, movie, series, radio, and DASH signals separate when changing media detection. A change that improves movie recognition must not route live or audio content to the movie view.
- Keep guide mode mounted around the active channel. Hiding the sidebar must not destroy the channel list or reset the active channel.
- Keep timeline and list EPG views aligned. Both must accept the same programme state and activation actions.
- Preserve user-owned refresh fields such as
userAgent,autoRefresh, and hidden group titles when parser output supplies only defaults or omits them. - Keep M3U VOD metadata separate from the playback source payload. A late metadata result must not recreate an active player or restart playback.
- Keep the external-player path separate from inline VOD playback. MPV and VLC users must not receive an unnecessary inline player mount.
- Keep the shared volume value fresh when VOD Browse-to-Play remounts the inline player.
- Keep Stalker MAC, device IDs, credentials, session identity, and portal endpoint as one authenticated connection. An edit must not persist a different identity from the one used for discovery.
- Keep Stalker refusal feedback inline until the user can correct the form. Do not replace a useful portal reason with a generic notice.
- Keep the playlist editor's full Stalker hydration before save. A metadata projection must not clear identity fields that exist only in the saved playlist record.
- Keep provider password fields masked by default in both add and edit flows. Visibility controls must not submit the surrounding form.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A source accepts a connection but stops sending data | URL import or unattended refresh can remain pending | Bound each playlist fetch hop with the playlist fetch timeout. |
| A non-M3U file reaches the import service | The user receives a read or unsupported error instead of a parsed playlist | Check the .m3u or .m3u8 suffix before reading. |
| A method switch discards an unfinished form | Returning to the method loses credentials or source details | Capture and restore drafts per method, and clear only the method the user clears. |
| Global guide settings are disabled by resetting the import choice | Re-enabling guide support silently changes the user's next M3U import | Hide the option while disabled but retain its value. |
| Auto-detect submits a candidate without using the target form | A source can skip the validation or provider probe that makes its saved data safe | Use auto-detect only to prefill the regular import form. |
| A downloaded header contains a local XMLTV path | Import can direct guide loading to a file on the user's disk | Accept only remote URLs from provider-controlled M3U header attributes. |
| A disabled detected guide URL is merged back without the disabled set | Refresh silently restores a guide source the user removed | Resolve enabled and manual URLs through the disabled URL set. |
| A full playlist update omits the current playlist's user fields | Refresh loses favorites, guide choices, refresh settings, request headers, or hidden groups | Merge user-owned fields from current metadata before publishing the updated source. |
| A refresh result was captured before a URL, file path, or user-agent edit | Old channel content replaces the source the user now owns | Match the refresh source to current identity fields before applying it. |
| A refresh publishes the downloaded candidate instead of the accepted saved result | The player can show channels that persistence rejected or changed | Publish the playlist returned by the persistence step. |
| A full playlist payload is retained in the metadata entity map | The channel list exists twice and can diverge from active channel state | Strip source payload fields from metadata entities and publish channels separately. |
| A metadata action is persisted after its owner already saved the change | The same update is written twice or triggers duplicate guide work | Use persist: false for state-only synchronization. |
| A rapid import uses canceling rather than serial add work | An earlier playlist can lose its save, guide fetch, or navigation | Serialize playlist add effects and let each add finish. |
| A temporary URL import is treated as a normal saved add | Unsaved channel content creates an unwanted playlist record | Keep temporary content in channel state and skip the durable add effect. |
| A channel without a guide key leaves the prior schedule active | The guide panel shows programmes for another channel | Clear the schedule when active-channel lookup cannot produce a key. |
| An EPG view changes its input or output contract alone | One guide presentation fails to compile or loses catch-up and live actions | Keep the timeline and list view contracts identical. |
| A fullscreen shortcut acts inside a dialog or scrollable list | The player changes channel while another surface owns the key | Ignore overlay and scrollable-region events before handling guide or channel keys. |
Key files
| File | Why to read it |
|---|---|
| libs/…/add-playlist-dialog.component.ts | Shows the user-facing source methods, method drafts, M3U guide choice, and auto-detect handoff to normal import forms. |
| libs/…/add-playlist-dialog.component.html | Shows the source selection surface, guide option, and form-specific save actions. |
| libs/…/add-playlist-dialog.component.render.spec.ts | Captures draft preservation, guide-option visibility, and the URL-to-Xtream handoff contract. |
| libs/…/auto-import.component.ts | Defines candidate detection, safe candidate summaries, and the handoff to normal import forms. |
| libs/…/auto-import.component.html | Shows how pasted source details become reviewable import candidates. |
| libs/…/playlist-file-import.service.ts | Defines local file checks and the browser-to-store file import boundary. |
| apps/…/playlist-source.ts | Shows desktop URL and file acquisition plus source-to-playlist normalization. |
| libs/…/playlists.service.ts | Shows parser invocation and the persistence-facing playlist service. |
| libs/…/stalker-portal-import.component.ts | Explains portal discovery, identity handling, fallback imports, and provider session data. |
| libs/…/stalker-portal-import.component.html | Shows the portal fields, advanced identity options, and inline refusal feedback. |
| libs/…/playlist.utils.ts | Defines shared playlist, favorite, stream hint, and playlist-local guide rules. |
| libs/…/playlist-refresh-source.util.ts | Defines how refreshes reject stale source results and retain user-owned source fields. |
| libs/…/m3u-vod-detection.util.ts | Defines the boundary between VOD playback signals and movie metadata treatment. |
| libs/…/playback-media-extension.util.ts | Defines the shared media hint rules used by routing and playback selection. |
| libs/…/playlist.interface.ts | Defines the durable playlist shape and its user-owned M3U fields. |
| libs/…/actions.ts | Defines the contracts for import, playlist updates, channel selection, guide state, and favorites. |
| libs/…/playlist-scoped-epg-fetch.util.ts | Defines when playlist-local guide sources should be fetched again. |
| libs/…/effects.ts | Shows how parse and add actions become persistence, guide fetch, active-channel schedule loading, external playback, and navigation. |
| libs/…/active-channel-epg.effect.spec.ts | Captures the schedule lookup and clearing rule for active M3U channels. |
| libs/…/playlist-update.effect-handler.ts | Shows how playlist update actions pass the chosen ID and diagnostic operation ID to persistence. |
| libs/…/playlist-refresh.effect.spec.ts | Captures the rule that accepted persisted refresh data becomes the published playlist state. |
| libs/…/playlists.state.ts | Defines the metadata inventory state and its load and filter status. |
| libs/…/playlist.reducers.ts | Shows how full source updates preserve playlist identity, user choices, active channel content, and inventory readiness. |
| libs/…/playlist.reducers.spec.ts | Shows the state guarantees for stale refresh rejection, payload separation, inventory recovery, refresh preservation, and active channel replacement. |
| libs/…/selectors.ts | Shows the state views used by playlist routes and player features. |
| libs/…/state.ts | Defines the in-memory channel, active playback, guide, and playlist state. |
| libs/…/playlist-switcher-panel.component.ts | Explains source search, type filtering, recent-source grouping, source actions, and source selection. |
| libs/…/playlist-switcher-panel.component.scss | Shows how the switcher keeps controls usable while only the source list scrolls. |
| libs/…/source-removal.service.ts | Defines the Undo window, active-source handoff, and committed source removal flow. |
| libs/…/source-removal-toast.component.ts | Shows how Undo and immediate commit are exposed to the user. |
| libs/…/source-removal-toast.component.scss | Defines the toast action and close-button presentation. |
| libs/…/m3u-workspace-route-session.service.ts | Explains route-driven channel loading, hidden-group hydration, request-header setup, and favorite hydration. |
| libs/…/m3u-workspace-route-session.service.spec.ts | Captures collection-route behavior, stale-load protection, metadata hydration, favorite hydration, and failure clearing. |
| libs/…/m3u-workspace-route-session.performance.spec.ts | Captures the safe aggregate data exposed by channel publication performance events. |
| libs/…/channel-list-container.component.ts | Coordinates the shared channel views, guide context, favorites, groups, and recent actions. |
| libs/…/m3u-epg-guide-source.service.ts | Defines guide scopes, channel identity, XMLTV lookups, search, and guide-to-playback activation. |
| libs/…/m3u-fullscreen-channel-list.component.ts | Defines the local fullscreen channel views that reuse the shared channel list. |
| libs/…/video-player.component.ts | Shows active playback, guide gating, fullscreen channel eligibility, keyboard zapping, recent-channel capture, active-channel schedule loading, and guide state. |
| libs/…/video-player.component.html | Shows the player-facing relationship between the active channel, media player, EPG list or timeline, VOD detail, and guide panel. |
| libs/…/video-player.component.scss | Defines the player workspace behavior across wide screens, phone drawers, and guide mode. |
| libs/…/video-player.spec-stubs.ts | Keeps the shared contract for the timeline and list EPG presentations visible to host tests. |
| libs/…/video-player-catchup-timeline.spec.ts | Captures the relationship between archive URLs and seek-bar programme segments. |
| libs/…/video-player.component.fullscreen-panel.spec.ts | Captures fullscreen panel eligibility and keyboard navigation guarantees. |
| libs/…/m3u-vod-detail.component.ts | Defines the M3U movie detail state, metadata presentation, inline playback boundary, and volume handoff. |
| libs/…/m3u-vod-detail.component.html | Shows how M3U movie metadata and playback actions appear in the detail view. |
| libs/…/playlist-epg-source-editor.ts | Defines playlist-local guide source normalization, cleanup, global promotion, and save behavior. |
| libs/…/playlist-info.component.ts | Defines playlist metadata editing, shared-source revision handling, Stalker connection hydration, guide-source management, and raw M3U export for saved playlists. |
| libs/…/playlist-info.component.spec.ts | Captures guide-source state handling, source cleanup, provider edit safety, and raw playlist export behavior. |
| libs/…/playlist-info.source-sync.spec.ts | Captures complete source hydration, revision-aware saves, and conflict handling for shared playlist edits. |
| libs/…/playlist-info.component.html | Shows provider credential protection, advanced Stalker fields, and playlist guide-source controls. |
| libs/…/playlist-info-password.component.spec.ts | Captures the password masking and non-submit behavior in playlist editing. |