Commit graph

1499 commits

Author SHA1 Message Date
SergeantPanda
ab8e3f93c6 tests: Fix backend timeshift test.
Some checks failed
Backend Tests / Plan test groups (push) Has been cancelled
CI Pipeline / prepare (push) Has been cancelled
Build and Push Multi-Arch Docker Image / build-and-push (push) Has been cancelled
Backend Tests / (push) Has been cancelled
CI Pipeline / docker (amd64, ubuntu-24.04) (push) Has been cancelled
CI Pipeline / docker (arm64, ubuntu-24.04-arm) (push) Has been cancelled
CI Pipeline / create-manifest (push) Has been cancelled
2026-07-13 23:31:31 +00:00
SergeantPanda
ea9eaf4d0c fix(timeshift): enhance session handling and playback logic
Some checks failed
Backend Tests / Plan test groups (push) Has been cancelled
CI Pipeline / prepare (push) Has been cancelled
Build and Push Multi-Arch Docker Image / build-and-push (push) Has been cancelled
Frontend Tests / test (push) Has been cancelled
Backend Tests / (push) Has been cancelled
CI Pipeline / docker (amd64, ubuntu-24.04) (push) Has been cancelled
CI Pipeline / docker (arm64, ubuntu-24.04-arm) (push) Has been cancelled
CI Pipeline / create-manifest (push) Has been cancelled
Updated the session handling mechanism to improve user experience during reconnects. The first request without a `session_id` now receives a `301` redirect with a minted `session_id`, while reconnects that omit `session_id` but match an existing pool entry are served immediately without a redirect. Additionally, refined playback logic for plain GET requests to restart from byte 0, aligning with provider behavior. Updated tests to reflect these changes and ensure proper session reuse and playback anchoring.
2026-07-12 21:09:40 +00:00
SergeantPanda
2f60dc91ae fix(proxy): enhance stream switching logic and error handling
Some checks failed
Backend Tests / Plan test groups (push) Has been cancelled
CI Pipeline / prepare (push) Has been cancelled
Build and Push Multi-Arch Docker Image / build-and-push (push) Has been cancelled
Frontend Tests / test (push) Has been cancelled
Backend Tests / (push) Has been cancelled
CI Pipeline / docker (amd64, ubuntu-24.04) (push) Has been cancelled
CI Pipeline / docker (arm64, ubuntu-24.04-arm) (push) Has been cancelled
CI Pipeline / create-manifest (push) Has been cancelled
Updated the stream switching mechanism in the proxy server to ensure that the `stream_id` is persisted correctly and that the requesting worker waits for confirmation from the owning worker in multi-worker deployments. Improved error handling for stream switch failures, returning appropriate HTTP status codes (502/504) based on the confirmation status. Additionally, refined the metadata update process to handle cases where the requested URL is already in use, ensuring a successful response without unnecessary operations. This change addresses issues with stale metadata and enhances the robustness of the stream switching feature. (Fixes #1412)
2026-07-11 18:21:48 +00:00
SergeantPanda
c6e3f57e26 fix(timeshift): enhance session matching logic for fresh sessions
Updated the session matching logic to improve handling of fresh sessions. Introduced a new parameter, `fresh_session`, to skip adopting idle exact-media pools when a new session ID is provided. This prevents unnecessary reconnections to previously abandoned programme slots. Added tests to verify that fresh sessions correctly skip idle matches while retaining busy exact-media sessions and allowing channel hops. This change enhances the robustness of the timeshift feature and improves user experience during session transitions.
2026-07-11 17:32:07 +00:00
SergeantPanda
223dff33ed feat(timeshift): add catch-up playback, stats, and admin APIs
Add end-to-end catch-up support for XC clients and native apps: provider
proxy with failover and per-viewer session pooling, REST session minting
for tokenless playback URLs, catch-up admin stats, combined connection
stats, and Stats UI with dedicated cards plus websocket updates.

Includes Redis namespace consolidation under timeshift:* (dropping legacy
timeshift_ id prefixes), dedicated catch-up stop by session_id, and
cleaner channel/client metadata split for stats keys.

Closes #133
2026-07-11 17:14:31 +00:00
SergeantPanda
3c2c42ce66 fix(epg): prevent crashes for channels with null channel numbers in XMLTV export
Some checks failed
Backend Tests / Plan test groups (push) Has been cancelled
CI Pipeline / prepare (push) Has been cancelled
Build and Push Multi-Arch Docker Image / build-and-push (push) Has been cancelled
Backend Tests / (push) Has been cancelled
CI Pipeline / docker (amd64, ubuntu-24.04) (push) Has been cancelled
CI Pipeline / docker (arm64, ubuntu-24.04-arm) (push) Has been cancelled
CI Pipeline / create-manifest (push) Has been cancelled
Updated the EPG generation logic to ensure that channels without a channel number do not cause crashes in the XMLTV export. Implemented a deferred assignment mechanism for channels with null numbers, allowing them to receive valid integers during processing. Added tests to verify that the XMLTV output remains stable and valid even when channels are unnumbered.
2026-07-10 02:42:50 +00:00
SergeantPanda
5c5b866bcf fix(vod): prevent group selection loss on empty category fetch
Implemented logic to abort the VOD refresh process when the provider returns no categories, preserving existing group selections. This change prevents unintended deletions of category relations and ensures that accounts retain their current settings during transient provider outages or API issues. Updated logging to reflect the abort condition for better traceability.
2026-07-09 21:26:36 +00:00
SergeantPanda
9ad198beb3 fix(live-streams): prevent crashes for channels with null channel numbers
Updated the handling of channels in the live streams setup to ensure that channels without a channel number do not cause crashes. Implemented logic to assign a valid number to these channels during processing. Added tests to verify that the system correctly assigns numbers to channels with null values, ensuring stability in the live streams feature.
2026-07-09 20:02:57 +00:00
SergeantPanda
c1c32686bd fix(timeshift): ensure database connections are closed before returning responses
Some checks are pending
Backend Tests / Plan test groups (push) Waiting to run
Backend Tests / (push) Blocked by required conditions
CI Pipeline / prepare (push) Waiting to run
CI Pipeline / docker (amd64, ubuntu-24.04) (push) Blocked by required conditions
CI Pipeline / docker (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
CI Pipeline / create-manifest (push) Blocked by required conditions
Build and Push Multi-Arch Docker Image / build-and-push (push) Waiting to run
Added a helper function to close old database connections in the `timeshift_proxy` view before returning any HTTP responses. This change prevents potential database connection leaks and ensures that connections are properly managed during the request lifecycle. Updated tests to verify that connections are closed appropriately in various response scenarios.

Also stores provider_tz_name with session pool in redis to avoid an extra database call.
2026-07-09 17:03:53 +00:00
SergeantPanda
6f2e99f47d
Merge pull request #1425 from cedric-marcoux:fix/timeshift-seek-position
fix(timeshift): serve the requested position when reusing a session (FF/RW snaps back to rewind anchor)
2026-07-09 11:51:57 -05:00
SergeantPanda
27deef9ad6 feat(epg): Improve performance during cold rebuilds by yielding to gevent hub
Enhanced the `/output/epg` cold rebuild process to prevent freezing of the gevent uWSGI worker. The `_stream_build` function now yields control to the gevent hub after processing each cached chunk, allowing other requests to be handled concurrently. This change improves responsiveness during CPU-bound XMLTV generation. Additionally, introduced a new utility function, `_cooperative_yield`, to facilitate yielding in CPU-bound loops.
2026-07-09 15:32:51 +00:00
Cédric Marcoux
35dce2b7f8 fix(timeshift): drop stale byte state and harden descriptor update on seek
Self-review follow-ups on the position fix:

- When the position actually moves, drop content_length/serving_range from
  the pool entry — they describe the PREVIOUS position's file, and keeping
  them would feed the near-EOF/displacement heuristics another programme's
  size (a metadata probe near the new file's EOF could displace live
  playback, or a genuine scrub could be misjudged as a probe). The next
  successful open repopulates both.
- Guard the update under the pool lock and skip it when the entry has
  vanished (Redis restart/eviction) — a bare HSET would resurrect a
  partial, TTL-less hash that answers every later request for that
  session_id with 503.
- Align the reuse-path timezone lookup with the fresh path
  (is_active=True on the default-profile filter).

Three more tests: byte state dropped on move / kept on same-position
update, vanished entry never resurrected, tz fallback to the reserved
profile when no active default exists.
2026-07-09 08:40:31 +02:00
Cédric Marcoux
7655060149 fix(timeshift): serve the requested position when reusing a session
Clients (TiviMate) keep the ?session_id= query when they rebuild the seek
URL with a new start timestamp, so every timestamp-jump FF/RW landed on
the reused session's STORED provider_timestamp — playback snapped back to
the position the session was created for (the rewind anchor), 100%
reproducible: two requests with different start values on one session
returned byte-identical streams.

The reuse path now always recomputes the provider timestamp from the
REQUESTED one (the provider zone is a property of the account — read from
the default profile's server_info, same as the fresh path) and moves the
pool descriptor (media_id + provider_timestamp) to the position actually
served, so fingerprint matching and same-channel displacement keep
comparing against reality. Slot continuity is unchanged.

Regression tests: reused session serves the requested timestamp (unit),
descriptor follows the seek (unit), and an end-to-end timestamp-jump with
the same session_id reaches the new position through timeshift_proxy.
2026-07-09 07:42:19 +02:00
Curt LeCaptain
c0d6e951a3 feat(m3u): add native xz decompression support for uploaded M3U playlists
Extends _open_m3u_text_source() and fetch_m3u_lines() to treat an
uploaded .xz playlist the same way as the existing .m3u.gz path: it is
streamed lazily via lzma.open() rather than loaded fully into memory
(unlike the .zip path, which must read archive members). Uses stdlib
lzma, no new dependency.

Companion to the EPG xz support added for Dispatcharr/Dispatcharr#1414 -
the M3U upload path has the same gzip/zip dispatch structure and would
otherwise hit the same gap for an xz-compressed playlist.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 19:48:44 -05:00
Curt LeCaptain
408c3c6bea feat(epg): add native xz decompression support for EPG sources
Adds .xz to the set of compressed formats detect_file_format(),
extract_compressed_file(), fetch_xmltv(), and EPGSource.get_cache_file()
recognize, mirroring the existing gzip handling. Uses stdlib lzma, no new
dependency. Detection works via LZMA magic bytes (fd 37 7a 58 5a 00),
the .xz extension (including compound extensions like .xml.xz), and the
application/x-xz mimetype fallback.

Widened the magic-byte read in get_cache_file() from 4 to 6 bytes since
the xz signature is 6 bytes (the previous 4-byte read was sufficient
only for the 2-byte gzip/zip signatures it originally supported). That
widening silently broke the bare-<tv> raw-XML detection: the
fixed-length slice comparison header[:5] == b'<tv>' can never match a
5-byte slice of a 6-byte header against a 4-byte literal. Replaced the
fixed-length slice comparisons with header.startswith(...), which is
correct regardless of how many bytes are read - this also fixes the
adjacent <?xml declaration check, which was silently dead before this
change (a 4-byte read could never equal the 5-byte b'<?xml' literal
either).

Fixes Dispatcharr/Dispatcharr#1414

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 19:48:44 -05:00
SergeantPanda
35ac9ea987 test: Refactor collision avoidance tests to use a fixed timestamp and improve suffix collision checks. Introduced helper function for clearer logic in assertions regarding MKV file naming conventions. 2026-07-07 21:08:45 +00:00
SergeantPanda
af71dc929f tests: Move tests to under tests folder. 2026-07-07 18:51:35 +00:00
SergeantPanda
2a09ce49da Enhancement: Update changelog to reflect changes in ChannelPagination, ensuring pagination works correctly with only page_size provided. Refactor tests to improve reliability and consistency, including adjustments to database connection management in various test cases. Modify EPG name normalization tests for accuracy and clarity, and enhance program data serializer tests to utilize precomputed season and episode values. 2026-07-07 18:30:06 +00:00
SergeantPanda
ae58fdb980 Enhancement: Add release_connections parameter to PluginManager, allowing for conditional database connection closure during plugin discovery, improving resource management. 2026-07-07 18:27:15 +00:00
SergeantPanda
dff97d9067 Enhancement: Ensure proper DB connection management in Celery tasks by checking for worker context before releasing connections, preventing potential ORM errors. 2026-07-07 18:26:09 +00:00
SergeantPanda
810a7a93a1 Enhancement: Update plugin discovery logic to include release_connections parameter, improving resource management during event triggering. 2026-07-07 18:25:52 +00:00
SergeantPanda
553bfc135c Enhancement: Modify pagination logic in ChannelPagination to disable pagination when both page and page size parameters are absent, ensuring full queryset is returned in such cases. 2026-07-07 18:23:46 +00:00
SergeantPanda
7649bfc88a Enhancement: Prevent 500 errors in live proxy preview when joining active channels on non-owner workers by ensuring proper client registration and cleanup. Update changelog to reflect this fix.
Some checks failed
CI Pipeline / prepare (push) Has been cancelled
Build and Push Multi-Arch Docker Image / build-and-push (push) Has been cancelled
CI Pipeline / docker (amd64, ubuntu-24.04) (push) Has been cancelled
CI Pipeline / docker (arm64, ubuntu-24.04-arm) (push) Has been cancelled
CI Pipeline / create-manifest (push) Has been cancelled
2026-07-06 21:05:09 -05:00
SergeantPanda
a90872079b Enhancement: Update session management details and improve stream limit handling in timeshift proxy. Enhance tests for decisive account failover and session probe logic. 2026-07-06 19:49:19 -05:00
SergeantPanda
4d4cc92bc9 Enhancement: Improve live proxy failover logic by resetting connection retries after a specified period of stability and ensuring backup streams are rotated in channel order. Update changelog to reflect these changes. 2026-07-06 19:11:32 -05:00
SergeantPanda
96db4f92c7 Enhancement: Implement live proxy failover for VLC stream profile, ensuring proper handling of upstream URL failures. Update changelog to reflect changes in stream management and VLC profile parameters. 2026-07-06 16:45:56 -05:00
SergeantPanda
9c3ace6146 Enhancement: Introduce 'Only Catch-up' filter in Channels and Streams tables, allowing users to easily narrow down to catch-up entries. Update changelog to reflect this new feature.
Some checks failed
CI Pipeline / prepare (push) Has been cancelled
Build and Push Multi-Arch Docker Image / build-and-push (push) Has been cancelled
Frontend Tests / test (push) Has been cancelled
CI Pipeline / docker (amd64, ubuntu-24.04) (push) Has been cancelled
CI Pipeline / docker (arm64, ubuntu-24.04-arm) (push) Has been cancelled
CI Pipeline / create-manifest (push) Has been cancelled
2026-07-03 09:09:59 -05:00
SergeantPanda
4b0066f6e7 Enhancement: Add catch-up indicators to Channels and Streams tables, enhancing UI with new serializers for catch-up data. 2026-07-03 09:03:28 -05:00
SergeantPanda
259db1196d Update tests and changelog. 2026-07-02 14:03:29 -05:00
SergeantPanda
2dcae97d01 Merge branch 'dev' of https://github.com/Dispatcharr/Dispatcharr into pr/francescodg89-crypto/1398 2026-07-02 13:55:27 -05:00
SergeantPanda
3a81a34e4a fix(epg): Enhance EPG data refresh and parsing logic to prevent data loss and improve concurrency handling. Implement deferred processing for ongoing tasks, ensuring stability during refresh operations. Update changelog with significant fixes and improvements. 2026-07-02 13:34:53 -05:00
francescodg89-crypto
72c0a4e69a
Refactor VOD failover tests and enhance coverage
Refactor tests for VOD provider failover logic to improve clarity and remove unnecessary components. Introduce new tests for order candidates and ensure no database access occurs during processing.
2026-07-02 00:17:13 +02:00
francescodg89-crypto
c824f7a17f
Refactor content relation handling for efficiency
Refactor content relation retrieval to use a single DB query for active relations, improving efficiency. Update return values to include candidates for failover handling.
2026-07-02 00:16:25 +02:00
SergeantPanda
12f094cbc0 feat(epg): Implement channel parsing progress tracking and update progress reporting logic in parse_channels_only function
Some checks are pending
CI Pipeline / prepare (push) Waiting to run
CI Pipeline / docker (amd64, ubuntu-24.04) (push) Blocked by required conditions
CI Pipeline / docker (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
CI Pipeline / create-manifest (push) Blocked by required conditions
Build and Push Multi-Arch Docker Image / build-and-push (push) Waiting to run
2026-07-01 17:07:47 -05:00
SergeantPanda
617eeae42a docs: Update changelog and reduce code comment length. 2026-06-30 12:22:55 -05:00
SergeantPanda
49a40ba7ed Merge branch 'dev' of https://github.com/Dispatcharr/Dispatcharr into pr/Jacob-Lasky/1378 2026-06-30 12:08:17 -05:00
SergeantPanda
827e18a3fd Merge remote-tracking branch 'origin/dev' into pr/CodeBormen/1367 2026-06-30 11:54:31 -05:00
francescodg89-crypto
6ddbf2ccd4
Rename test vod failover.py to test_vod_failover.py 2026-06-30 13:34:20 +02:00
francescodg89-crypto
5c43f14c19
Add files via upload 2026-06-30 13:32:40 +02:00
francescodg89-crypto
502ca5bfc8
Add VOD failover logic for M3U relations
Implemented VOD failover logic to iterate over all active M3U relations, selecting the first account with spare capacity instead of relying on a single highest-priority relation. This change enhances reliability by allowing for provider failover in case of account saturation.
2026-06-29 13:15:52 +02:00
SergeantPanda
5c5a79962d refactor(proxy): Add new client connect grace period setting and update channel initialization grace period defaults. The channel_client_wait_period is introduced to manage channel lifetimes before client connections, while the channel_init_grace_period default is increased to improve failover handling.
Some checks failed
CI Pipeline / prepare (push) Has been cancelled
Build and Push Multi-Arch Docker Image / build-and-push (push) Has been cancelled
Frontend Tests / test (push) Has been cancelled
CI Pipeline / docker (amd64, ubuntu-24.04) (push) Has been cancelled
CI Pipeline / docker (arm64, ubuntu-24.04-arm) (push) Has been cancelled
CI Pipeline / create-manifest (push) Has been cancelled
2026-06-28 11:34:44 -05:00
SergeantPanda
fc4ced9043 feat(m3u): Add stream count summary and parsing result handling to M3U refresh process. Introduce helper functions for better readability and maintainability. Update frontend notification to display detailed stream processing outcomes, including counts for created, updated, stale, and removed streams.
Some checks are pending
CI Pipeline / prepare (push) Waiting to run
CI Pipeline / docker (amd64, ubuntu-24.04) (push) Blocked by required conditions
CI Pipeline / docker (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
CI Pipeline / create-manifest (push) Blocked by required conditions
Build and Push Multi-Arch Docker Image / build-and-push (push) Waiting to run
Frontend Tests / test (push) Waiting to run
2026-06-28 09:54:09 -05:00
None
40ec6b6339 fix(channels): align the auto-sync rename preview and live rename on the regex module
The Find and Replace preview did not correctly reflect the rename the sync performs, and the rename engine differed from the preview engine.

- The preview rendered the literal $1 instead of the substituted capture group, because the replacement was passed straight into the regex engine, which honors \1, not the JS-style $1 the field accepts.
- The preview compiled patterns with the regex module while the live rename used stdlib re, so patterns valid in regex but not re (for example ^*) previewed a transform the sync silently skipped.
- A rename that expanded a name past the Channel.name column length aborted the whole bulk_create sync, while the preview showed the full name.
- Convert JS-style $1 backreferences to \1 via a shared helper used by both the preview and the live rename.
- Switch the live rename from re.sub to regex.sub, matching the preview engine and the sync's own include/exclude filters, with a timeout to bound catastrophic backtracking on user patterns.
- Cap the rename result at the Channel.name column length in both paths, so an over-length result cannot abort the sync.
- Add unit, integration, and differential parity tests covering the above.
2026-06-27 17:45:42 -05:00
SergeantPanda
269acc2dda refactor(timeshift): Replace random session ID generation with secure secrets for timeshift sessions. Introduce helper functions for session management and enhance session validation to prevent foreign session reuse. Update tests to cover new session handling logic and ensure proper user ownership checks. 2026-06-27 16:50:44 -05:00
SergeantPanda
6d17663f84 refactor(tasks): Optimize XC stream collection by avoiding redundant work during catalog filtering. Introduce a shared URL prefix for stream URLs and enhance memory management by releasing per-group caches after processing. Update changelog to reflect these improvements. 2026-06-27 13:33:26 -05:00
SergeantPanda
6456d11795 refactor(tasks): Enhance M3U refresh process by introducing a line-by-line parsing method for on-disk files, improving memory efficiency. Update error handling to return None for failures, and streamline the fetching logic for better clarity and performance. 2026-06-27 12:48:02 -05:00
SergeantPanda
f01c6563c1 refactor(tasks): Optimize M3U stream processing by pre-compiling filters for batch workers, reducing redundant regex evaluations. Update related functions to improve performance and memory management during account refreshes. 2026-06-27 11:52:00 -05:00
SergeantPanda
96a39ce5d2 refactor(tasks): Improve stream processing logic by adding bulk update functionality for unchanged streams. Enhance memory management and error handling in database queries, and update cleanup functions to optimize memory usage. 2026-06-27 11:13:17 -05:00
SergeantPanda
ec8594cd0a refactor(tasks): Add is_catchup and catchup_days fields to Stream processing logic. Update existing stream queries and conditions to handle new catch-up properties, ensuring accurate updates and memory management for bulk operations. 2026-06-27 10:11:49 -05:00
SergeantPanda
931f4dc50f refactor(tasks): Enhance rollup_channel_catchup_fields function to limit updates to channels linked to the specified account. Update SQL queries for clarity and efficiency, and improve docstrings for better understanding of the self-heal logic related to catch-up flags. 2026-06-27 09:28:24 -05:00