Commit graph

70 commits

Author SHA1 Message Date
dekzter
90a600b48f merged in dev 2026-03-26 12:17:43 -04:00
SergeantPanda
c44a3ad5f9 Bug Fix: Stream.last_seen and ChannelGroupM3UAccount.last_seen model defaults now use django.utils.timezone.now instead of datetime.datetime.now, eliminating spurious RuntimeWarning: DateTimeField received a naive datetime warnings emitted during test database creation and on new record creation when USE_TZ=True. 2026-03-15 16:59:51 -05:00
dekzter
f69a462253 merged in dev 2026-03-13 08:22:44 -04:00
dekzter
6f4665e6eb merged in dev 2026-02-26 08:20:20 -05:00
None
c69718b559 Fix: Make release_stream() idempotent to prevent double-DECR on rapid channel switching
Multiple code paths call release_stream() during channel shutdown (stream generator cleanup, _clean_redis_keys, ChannelService.stop_channel), causing
the profile_connections counter to be decremented multiple times for the same stream. The metadata hash fallback persisted longer than the primary keys, allowing subsequent calls to find stale stream_id/m3u_profile and DECR again.

Changes:
- Clear STREAM_ID and M3U_PROFILE metadata fields after decrementing in both the primary and fallback paths, making release_stream() safe to call multiple times
- Add metadata fallback when stream_profile:{id} key is missing but channel_stream:{id} exists, preventing a counter leak in that edge case
- Replace redundant get_stream() call in views.py with direct Redis reads to avoid side-effect INCR from a method that can allocate connection slots
2026-02-17 21:18:20 -06:00
None
837ba84768 fix(ts-proxy): Restore Stream.get_stream() with atomic slot reservation
Stream.get_stream() was incorrectly removed as dead code in commit
33f68a98. It is actually called get_stream_object()
in views.py when a stream hash (not channel UUID) is used, such as
during stream preview. The variable is named channel but holds a
Stream instance, which masked the dependency during analysis.

Restored with the INCR-first-then-check pattern applied, fixing the
same TOCTOU vulnerability the original method had.
2026-02-11 23:57:10 -06:00
None
6826e94921 Add boolean return to Stream.release_stream()
Stream.release_stream() now returns True on success and False when no
profile info could be found in stream_profile:{stream_id}. This allows
callers to detect and handle failed releases.

Enhanced logging to include stream ID for better traceability.

Based on PR #838 by patchy8736
2026-02-11 19:27:45 -06:00
None
56719d93fe Add boolean return and metadata fallback to Channel.release_stream()
Channel.release_stream() now returns True on success and False when no
stream/profile info could be found for cleanup. This allows callers to
detect and handle failed releases.

When the primary Redis keys (channel_stream/stream_profile) are already cleaned up by the proxy, the method falls back to the channel metadata hash (ts_proxy:channel:{uuid}:metadata) to recover stream_id and profile_id for proper connection counter cleanup.

Uses str(self.uuid) for metadata key lookup - fixes a bug in PR #838
which used self.id (integer PK), but metadata is keyed by UUID.

Enhanced logging now includes channel UUID for better traceability.

Based on PR #838 by patchy8736
2026-02-11 19:16:01 -06:00
None
33f68a9808 Remove unused Stream.get_stream() with TOCTOU vulnerability
Remove the Stream.get_stream() method which had the same TOCTOU race condition as Channel.get_stream()

All stream acquisition goes through
Channel.get_stream(), making this dead code. Removing it eliminates
a potential source of connection capacity leaks

Based on PR #838 by patchy8736
2026-02-11 19:11:28 -06:00
None
5a4b51b60a Fix TOCTOU race condition in Channel.get_stream() with atomic slot reservation
Add _check_and_reserve_profile_slot() method that uses an INCR-first-then-check pattern to atomically reserve connection slots. This eliminates the TOCTOU race condition where separate GET > check > INCR operations allowed concurrent requests to both pass the capacity check, exceeding max_streams.

For profiles with max_streams=0 (unlimited), INCR is skipped entirely. If over capacity, the increment is rolled back with DECR.

Based on PR #838 by patchy8736, adapted from Lua script to native Redis commands for consistency with project style and easier debugging.
2026-02-11 18:08:24 -06:00
None
15d67c7f65 Atomize profile counter swap in update_stream_profile to prevent counter drift
DECR/SET/INCR during stream profile switches are now executed in a Redis
pipeline, preventing partial updates if an exception occurs mid-operation
2026-02-10 18:30:43 -06:00
SergeantPanda
9ffd595c96 Enhancement: Added stream_id (provider stream identifier) and stream_chno (provider channel number) fields to Stream model. For XC accounts, the stream hash now uses the stable stream_id instead of the URL when hashing, ensuring XC streams maintain their identity and channel associations even when account credentials or server URLs change. Supports both XC num and M3U tvg-chno/channel-number attributes. 2026-01-31 17:47:46 -06:00
dekzter
dba70b3c58 outstanding commits, may revisit later 2026-01-27 15:23:07 -05:00
SergeantPanda
d33d047a94 Enhancement: - Mature content filtering support:
- Added `is_adult` boolean field to both Stream and Channel models with database indexing for efficient filtering and sorting
  - Automatically populated during M3U/XC refresh operations by extracting `is_adult` value from provider data
  - Type-safe conversion supporting both integer (0/1) and string ("0"/"1") formats from different providers
  - UI controls in channel edit form (Switch with tooltip) and bulk edit form (Select dropdown) for easy management
  - XtreamCodes API support with proper integer formatting (0/1) in live stream responses
  - Automatic propagation from streams to channels during both single and bulk channel creation operations
  - Included in serializers for full API support
  - User-level content filtering: Non-admin users can opt to hide mature content channels across all interfaces (web UI, M3U playlists, EPG data, XtreamCodes API) via "Hide Mature Content" toggle in user settings (stored in custom_properties, admin users always see all content)
2026-01-17 15:00:28 -06:00
SergeantPanda
a84553d15c Enhancement: Stale status indicators for streams and groups: Added is_stale field to both Stream and ChannelGroupM3UAccount models to track items in their grace period (seen in previous refresh but not current). 2026-01-09 13:53:01 -06:00
SergeantPanda
cc9d38212e Enhancement: Groups now follow the same stale retention logic as streams, using the account's stale_stream_days setting. Groups that temporarily disappear from an M3U source are retained for the configured retention period instead of being immediately deleted, preserving user settings and preventing data loss when providers temporarily remove/re-add groups. (Closes #809) 2026-01-09 12:03:55 -06:00
SergeantPanda
73956924f5 Enhancement: Stream group as available hash option: Users can now select 'Group' as a hash key option in Settings → Stream Settings → M3U Hash Key, allowing streams to be differentiated by their group membership in addition to name, URL, TVG-ID, and M3U ID 2025-12-18 15:26:08 -06:00
SergeantPanda
5c27bd2c10 Enhancement: Increase maximum URL length for Stream model to 4096 characters (from 2000) and add validation for URL length in processing tasks.
Fixes #585
2025-10-28 15:02:36 -05:00
SergeantPanda
0d987aae99 Enhancement: If a stream profile is set for a custom stream, when previewing the stream Dispatcharr will now use the assigned stream profile. Fixes #186 2025-10-18 16:24:47 -05:00
SergeantPanda
e01338f055 Enhancement: Properly track channel creation time and channel update times in the database. XC Get Live streams will now use this for the added field. 2025-10-06 18:07:51 -05:00
OkinawaBoss
8db9689999
Merge branch 'DVR-Update' into dev 2025-10-06 06:25:40 -07:00
SergeantPanda
a3e4f23891 Enhancement: Add m3u_id parameter to generate_hash_key and update related calls 2025-10-02 09:14:22 -05:00
Dispatcharr
eee4ab0725 Update for recurring rules 2025-09-19 16:21:28 -05:00
Dispatcharr
424a450654 DVR Features and bug fixes
Added ability to use custom comskip.ini
Added series recording without reliance on EPG
Fixed comskip bug
Fixed timezone mismatch when scheduling DVR recordings

No migrations completed yet
2025-09-18 10:23:16 -05:00
SergeantPanda
ed0b291237 Skip disabled m3u accounts when choosing streams during playback.
Closes #402
2025-09-15 17:36:31 -05:00
SergeantPanda
6f6c28ca7c Convert custom_properties to jsonb in the backend. 2025-09-02 09:41:51 -05:00
dekzter
a19bd14a84 added vod category filtering 2025-08-22 16:59:00 -04:00
SergeantPanda
6180b4ffef Save stream stats to database. 2025-07-28 21:40:29 -05:00
SergeantPanda
b91a2286e4 Add auto-created tracking to Channel model and related serializers
- Introduced `auto_created` and `auto_created_by` fields in the Channel model to track channels created via M3U auto channel sync.
- Updated ChannelSerializer to include these new fields and added a method to retrieve the name of the M3U account that created the channel.
- Modified sync_auto_channels task to set these fields when creating channels and to filter existing channels accordingly.
2025-07-13 16:32:52 -05:00
SergeantPanda
ea81cfb1af Add auto channel sync settings to ChannelGroupM3UAccount and update related components
- Introduced `auto_channel_sync` and `auto_sync_channel_start` fields in the ChannelGroupM3UAccount model.
- Added API endpoint to update M3U group settings.
- Updated M3UGroupFilter component to manage auto sync settings.
- Enhanced M3URefreshNotification and M3U components for better user guidance.
- Created a Celery task for automatic channel synchronization after M3U refresh.
2025-07-13 15:59:25 -05:00
dekzter
74d58515d0 user management, user levels, user level channel access 2025-05-18 11:19:34 -04:00
MooseOnTheLoose
88a7312397
Merge branch 'dev' into main 2025-05-08 19:16:49 -05:00
MooseyOnTheLoosey
5bae7997c0 Removing more debug 2025-05-08 09:50:19 -05:00
MooseyOnTheLoosey
88866cc905 Updated channel numbers from integer to float 2025-05-08 09:12:10 -05:00
Reggie Burnett
fcd1722d3a Add support for Channels DVR tvc-guide-stationid 2025-05-03 19:24:51 -05:00
dekzter
1a0d065eca ui settings with configurable table size, added setting to set / rehash stream hashes 2025-05-03 08:01:22 -04:00
dekzter
3ea8c05466 Merge remote-tracking branch 'origin/dev' into xtream 2025-04-30 15:10:59 -04:00
SergeantPanda
cd1da5a61c Added a new channel model to update m3u profile counts and utilize it during stream switches. 2025-04-28 17:25:03 -05:00
dekzter
f295ee219c removed db index here, I don't think it's needed 2025-04-27 10:54:39 -04:00
dekzter
3054cf2ae9 initial xtreamcodes support 2025-04-27 10:32:29 -04:00
dekzter
3e2f91abf8 hopefully finalizing table rewrite 2025-04-23 11:02:00 -04:00
dekzter
ccdb8ab00d more table bug fixes, query optimizations, re-added channel expansion stream table with reworked drag-and-drop 2025-04-19 08:37:43 -04:00
SergeantPanda
a463d06140 Fixes stream preview. 2025-04-13 10:02:30 -05:00
SergeantPanda
6ccc2b9a6d Enhance stream retrieval process with error handling and retry logic
- Updated `get_stream` method to return error reasons for better debugging.
- Improved `generate_stream_url` to handle errors and log specific issues.
- Implemented retry mechanism in `stream_ts` view for obtaining streams with exponential backoff.
- Added new configuration options for connection timeout and retry intervals.
2025-04-10 08:38:53 -05:00
dekzter
e31036079e allow null for channel_number so we auto assign 2025-04-08 17:24:38 -04:00
dekzter
e2850441ae basic DVR UI, custom properties for recordings 2025-04-07 15:01:44 -04:00
dekzter
00f6e7c1cd first run at recordings, among other things 2025-04-05 18:59:15 -04:00
dekzter
7351264e8a centralized and lazy-loaded redis client singleton, check for manage.py commands so we don't init proxyservers (redis connection), put manage commmands before starting uwsgi 2025-04-04 16:18:12 -04:00
dekzter
e7c4324b64 updated logo url field 2025-04-04 11:24:31 -04:00
dekzter
a41b205629 fully supported channel profiles 2025-04-03 08:59:06 -04:00