Commit graph

32 commits

Author SHA1 Message Date
SergeantPanda
b629836b3d Bug Fix: Fixed stream switch metadata (url, user_agent, stream_id, m3u_profile) being written to Redis before the switch was confirmed to succeed 2026-04-12 12:02:20 -05:00
SergeantPanda
b671a72707 fix: resolve decode_responses migration bugs and user-limit regressions
Fix a wave of bugs introduced by the user-priority branch's migration
from manual .decode('utf-8') calls to decode_responses=True on the
metadata Redis client:

core/utils.py
- Rewrite _init_client: fix SyntaxError at line 138, missing
  redis_password/redis_user params, cls._client corruption when
  decode_responses=False was requested, and dead retry backoff logic

apps/proxy/utils.py
- Fix get_user_limit_settings() → get_user_limits_settings() (2 sites)
- Fix VOD scan key vod_persistent_connections:* → vod_persistent_connection:*
- Fix undefined channel_id in VOD loop (use content_uuid from Redis hash)
- Remove leftover print(active_connections) debug statement
- Refactor manual cursor SCAN while-loops to scan_iter()

apps/channels/tasks.py
- Fix closure bug in _d(): md.get(key) → md.get(bkey) (was reading
  the outer loop variable instead of the local bytes key)

apps/proxy/ts_proxy/server.py
- Replace stale b'init_time', b'total_bytes', b'state' byte-string
  key lookups and .decode() calls with plain string equivalents

apps/proxy/ts_proxy/services/channel_service.py
- Fix ChannelMetadataField.STATE.encode() / .OWNER.encode() →
  .STATE / .OWNER (pre-existing, broke under decoded client)

apps/proxy/ts_proxy/views.py
- Fix ChannelMetadataField.OWNER.encode("utf-8") → .OWNER

apps/proxy/ts_proxy/client_manager.py
- Fix cid.decode('utf-8') in remove_ghost_clients(): smembers()
  already returns str with decode_responses=True
2026-03-26 18:41:42 -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
51b5824737 Fix cleanup paths for stream preview
Fix exception handling in _clean_redis_keys() and stop_channel()
   where `except Channel.DoesNotExist` didn't catch ValidationError from invalid UUID format, bypassing the Stream fallback path.
2026-02-12 00:09:29 -06:00
None
fe17d0d585 Check release_stream() boolean return at all call sites
All 12 call sites for Channel.release_stream() and Stream.release_stream() now check the boolean return value and log warnings when release fails.

Files updated:
- server.py: 4 call sites (zombie cleanup + _clean_redis_keys)
- channel_service.py: 2 call sites (stop_channel)
- stream_generator.py: 1 call site (last client disconnect)
- views.py: 4 call sites (failed init, redirect, init failure, exception)
- url_utils.py: 1 call site (URL generation error)

Also fixed bare except clause in _clean_redis_keys and uncaught
Stream.DoesNotExist in channel_service.stop_channel.

Based on PR #838 by patchy8736
2026-02-11 19:49:11 -06:00
Seth Van Niekerk
aa5db6c3f4
Squash: Log Parsing Refactor & Enhancing 2025-12-22 15:14:46 -05:00
Seth Van Niekerk
bc72b2d4a3
Add VLC and streamlink codec parsing support 2025-12-15 20:09:54 -05:00
dekzter
4a23883d0c merged in upstream 2025-12-05 08:34:29 -05:00
SergeantPanda
89a23164ff Enhancement: Add system event logging and viewer with M3U/EPG endpoint caching
System Event Logging:
- Add SystemEvent model with 15 event types tracking channel operations, client connections, M3U/EPG activities, and buffering events
- Log detailed metrics for M3U/EPG refresh operations (streams/programs created/updated/deleted)
- Track M3U/EPG downloads with client information (IP address, user agent, profile, channel count)
- Record channel lifecycle events (start, stop, reconnect) with stream and client details
- Monitor client connections/disconnections and buffering events with stream metadata

Event Viewer UI:
- Add SystemEvents component with real-time updates via WebSocket
- Implement pagination, filtering by event type, and configurable auto-refresh
- Display events with color-coded badges and type-specific icons
- Integrate event viewer into Stats page with modal display
- Add event management settings (retention period, refresh rate)

M3U/EPG Endpoint Optimizations:
- Implement content caching with 5-minute TTL to reduce duplicate processing
- Add client-based event deduplication (2-second window) using IP and user agent hashing
- Support HEAD requests for efficient preflight checks
- Cache streamed EPG responses while maintaining streaming behavior for first request
2025-11-20 17:41:06 -06:00
dekzter
50e9075bb5 initial run of a binary and encoded redis client - no more encoding / decoding data into redis, huge PITA (still some outstanding spots I need to patch) 2025-10-25 08:15:39 -04:00
SergeantPanda
9b2ebf169b Better database connection cleanup. 2025-10-16 14:22:19 -05:00
SergeantPanda
9dc54fdcff Fix: Ensure channel_id and channel.uuid are converted to strings before processing. This fixes an issue where sending a stream switch event would fail if the event was sent from a non owning worker.
Fixes [Bug]: Manually switching active stream not working when using XC client.
Fixes #269
2025-10-09 19:10:38 -05:00
SergeantPanda
6180b4ffef Save stream stats to database. 2025-07-28 21:40:29 -05:00
SergeantPanda
838a373bea Use correct m3u_profile_id when changing streams. 2025-06-17 13:11:03 -05:00
SergeantPanda
f869daa37c Add stream type for stream (HLS/MPEGTS, ETC) 2025-06-10 09:51:56 -05:00
SergeantPanda
efaa64d00b Fix resolution not always parsing correctly. 2025-06-10 09:08:04 -05:00
SergeantPanda
47500daafa Moved some functions to channel_service 2025-06-09 19:10:52 -05:00
SergeantPanda
d59c8a9e33 Properly track current stream id during stream switches. 2025-04-27 15:52:10 -05:00
SergeantPanda
88f27d62f1 Adds current m3u profile to stats. 2025-04-27 14:43:09 -05: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
SergeantPanda
2f995b16fd Fixes stream switches not honouring user selected order. 2025-03-28 08:50:57 -05:00
SergeantPanda
ce6e019e6a Add m3u_profile (id) to redis when channel is initialized. 2025-03-27 19:24:43 -05:00
dekzter
bf0c50dab2 Merge branch 'epg-refactor' into stream-previews 2025-03-27 09:44:07 -04:00
dekzter
91a85020c3 modifications to allow previewing of a raw stream 2025-03-27 09:26:04 -04:00
SergeantPanda
4283162ba9 Switched profile to stream_profile in channel_service 2025-03-25 13:04:51 -05:00
SergeantPanda
4738d301d1 Fixed regression with buffer checks when clients should be disconnecting due to failure. 2025-03-20 21:03:01 -05:00
SergeantPanda
6d84821942 Adds better checks for a channel that is partially initialized and clears it. 2025-03-20 15:56:34 -05:00
SergeantPanda
d6a452548c Automatic stream switching is working. 2025-03-20 15:28:12 -05:00
SergeantPanda
dc43fb41b5 More refactoring. 2025-03-20 08:45:23 -05:00
SergeantPanda
86e6c942d7 Final refactoring and minor bug fix for transcode stream switching. 2025-03-19 20:22:13 -05:00
SergeantPanda
569846a687 Lots more refactoring. 2025-03-19 19:45:29 -05:00