Commit graph

90 commits

Author SHA1 Message Date
SergeantPanda
36967c10ce Refactor CoreSettings to use JSONField for value storage and update related logic for proper type handling. Adjusted serializers and forms to accommodate new data structure, ensuring seamless integration across the application. 2026-01-13 12:18:34 -06:00
SergeantPanda
c03ddf60a0 Fixed verbiage for epg parsing status. 2025-12-07 21:28:04 -06:00
SergeantPanda
3b34fb11ef Fix: Fixes bug where Updated column wouldn't update in the EPG table without a webui refresh. 2025-12-04 15:43:33 -06:00
SergeantPanda
5693ee7f9e perf: optimize EPG program parsing and implement atomic database updates to reduce I/O overhead and prevent partial data visibility 2025-12-04 14:57:57 -06:00
SergeantPanda
256ac2f55a Enhancement: Clean up orphaned programs for unmapped EPG entries 2025-12-04 14:25:44 -06:00
SergeantPanda
2a8ba9125c perf: optimize EPG program parsing for multi-channel sources
Dramatically improve EPG refresh performance by parsing the XML file once
per source instead of once per channel. The new implementation:

- Pre-filters to only process EPG entries mapped to actual channels
- Parses the entire XML file in a single pass
- Uses O(1) set lookups to skip unmapped channel programmes
- Skips non-mapped channels entirely with minimal overhead

For EPG sources with many channels but few mapped (e.g., 10,000 channels
with 100 mapped to channels), this provides approximately:
- 99% reduction in file open operations
- 99% reduction in XML file scans
- Proportional reduction in CPU and I/O overhead

The parse_programs_for_tvg_id() function is retained for single-channel
use cases (e.g., when a new channel is mapped via signals).

Fixes inefficient repeated file parsing that was occurring with large
EPG sources.
2025-12-04 14:07:28 -06: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
SergeantPanda
e6146e5243 Bug fix: Reduce websocket message size when processing epgs. Also remove unnecessary console logging during epg refresh. Fixes [Bug]: Page goes blank if sending too many requests / responses
Fixes #327
2025-11-04 18:23:45 -06:00
SergeantPanda
22fb0b3bdd Enhancement: Add Custom Dummy EPG with Dynamic Pattern Matching and Name Source Selection
This enhancement introduces a powerful custom dummy EPG system that allows users to generate EPG programs on-demand by parsing channel or stream names using configurable regex patterns.

Key Features:
- Custom Pattern Matching: Define regex patterns to extract information from channel/stream names (teams, leagues, times, dates, etc.)
- Flexible Name Source: Choose to parse either the channel name or a specific stream name (by index)
- Timezone-Aware Scheduling: Automatic DST handling using pytz timezone names (e.g., 'US/Eastern', 'Europe/London')
- Time Format Support: Parse both 12-hour (AM/PM) and 24-hour time formats
- Date Parsing: Extract dates from names with flexible month/day/year patterns
- Custom Templates: Format EPG titles and descriptions using captured groups with {placeholder} syntax
- Upcoming/Ended Customization: Define custom titles and descriptions for programs before and after scheduled events
- Live Preview: Test patterns and templates in real-time with sample input
- Smart Program Generation: Automatically creates "Upcoming" and "Ended" programs around scheduled events

Use Cases:
- Sports channels with event details in stream names (e.g., "NHL 01: Bruins VS Leafs @ 8:00PM ET")
- Movie channels with genre/title/year information
- Racing events with driver/track/series details
- Any scenario where EPG data is embedded in channel/stream naming conventions

Technical Implementation:
- Backend: Pattern matching engine with timezone conversion and program scheduling logic
- Frontend: Interactive form with validation, pattern testing, and visual group preview
- Name Source Options: Parse from channel name or selectable stream index (1-based)
- Fallback Behavior: Uses standard dummy EPG if patterns don't match
- Custom Properties: Stores all configuration in EPGSource.custom_properties JSON field

Configuration Options:
- Title Pattern: Extract primary information (required)
- Time Pattern: Extract hour/minute/AM-PM (optional)
- Date Pattern: Extract month/day/year (optional)
- Timezone: Event timezone with automatic DST support
- Program Duration: Length of generated programs in minutes
- Title Template: Format EPG title using captured groups
- Description Template: Format EPG description using captured groups
- Upcoming Title Template: Custom title for programs before event starts (optional)
- Upcoming Description Template: Custom description for programs before event starts (optional)
- Ended Title Template: Custom title for programs after event ends (optional)
- Ended Description Template: Custom description for programs after event ends (optional)
- Name Source: Channel name or stream name
- Stream Index: Which stream to use when parsing stream names (1, 2, 3, etc.)

Closes #293
2025-10-18 12:08:56 -05:00
SergeantPanda
29ee837b24 Add recover=True to iterparse for parse_programs_for_tvg_id as well to fix cloudflare script injection. 2025-10-04 16:36:49 -05:00
SergeantPanda
94f966e027 Reverted to old method for parsing xml. Still will not break if Cloudflare adds a new root element. 2025-10-04 16:25:35 -05:00
SergeantPanda
0a15e09805 Refactor XMLTV parsing to use iterparse for <tv> element. This fixes issues where Cloudflare is adding a root element and breaking the xml.
Fixes #497: Cloudflare hosted EPG not supported in dispatcharr
2025-10-03 13:30:20 -05:00
SergeantPanda
d06c5bfdf3 Add recover to xmltv parser if there are errors. 2025-10-03 10:15:24 -05:00
SergeantPanda
6f79845b21 Enhancement: Only grab first display name for a channel during epg scanning. 2025-09-21 12:40:20 -05:00
SergeantPanda
99122cac7c Bug fix: If URL for Channel element in EPG is longer than 500 characters parsing would fail. Added validation during scanning. 2025-09-21 12:23:48 -05:00
SergeantPanda
f4f29a0e27 Break out of channel child elements once required data is acquired. 2025-09-18 10:34:51 -05:00
SergeantPanda
d2d1984797 Switch bulk epg name and logo to backend celery tasks for efficiency and scrape epg channel logo during epg scanning. 2025-09-16 17:17:07 -05:00
Dispatcharr
00cc83882a DVR update 2025-09-03 21:35:45 -05:00
SergeantPanda
6f6c28ca7c Convert custom_properties to jsonb in the backend. 2025-09-02 09:41:51 -05:00
Jordan
72fee02ec4
ensure chunk is either null or empty to exit loop 2025-08-12 11:26:50 +01:00
Jordan
429b01b569
prevent memory issues by implementing a chunked extractor 2025-08-11 16:28:23 +01:00
SergeantPanda
d24520d3d8 Enhance EPG XML generation with additional metadata extraction and improved handling for keywords, languages, ratings, and credits. 2025-07-10 13:22:42 -05:00
SergeantPanda
e7bf8cbede Added support for LIVE tag and dd_progrid numbering systems for epg. 2025-06-03 22:00:17 -05:00
SergeantPanda
67663e2946 Add remove_blank_text=True to lxml parser. Fixes crashes related to poorly formatted xmltv files. 2025-05-30 10:25:47 -05:00
SergeantPanda
906fbef9c2 Output errors from parser if found. 2025-05-29 13:56:20 -05:00
SergeantPanda
4dbb363211 Removed display-name from logging as it may not exist. 2025-05-27 18:00:35 -05:00
SergeantPanda
3fa5301894 If cached file doesn't exist for compressed mapped file, properly re-exctract. 2025-05-27 09:54:28 -05:00
SergeantPanda
5d2c604a4a Peak inside gz files to see if they contain xml files. Check file list for zip files to see if they contain xml files. 2025-05-26 15:49:51 -05:00
SergeantPanda
8f4e05b0b8 Add extracted_file_path to EPGSource model and update extraction logic 2025-05-26 15:10:54 -05:00
SergeantPanda
182a009d69 Track extracted files for mapped epg files. 2025-05-25 18:14:27 -05:00
SergeantPanda
7dbd41afa8 Extract compressed files after downloading and delete original. 2025-05-25 17:39:41 -05:00
SergeantPanda
d270e988bd Greatly improve filetype detection. 2025-05-25 16:50:03 -05:00
SergeantPanda
0322a5c904 Smarter logging for file type. 2025-05-25 15:47:22 -05:00
SergeantPanda
c1eb3a6ecf Add Zip file support for EPG. 2025-05-25 14:05:59 -05:00
SergeantPanda
391a1d9707 A little more cleanup. 2025-05-25 13:29:39 -05:00
SergeantPanda
d7023bcdac Some more code cleanup 2025-05-25 13:19:49 -05:00
SergeantPanda
6c3102a60c Removed sleep from debugging. 2025-05-24 17:46:17 -05:00
SergeantPanda
f77b3b9756 Little more cleanup. 2025-05-24 17:40:45 -05:00
SergeantPanda
3f17c90a8b Cleaned up some old unneeded code. 2025-05-24 17:31:52 -05:00
SergeantPanda
759cbe2f7d Search entire epg for channels to accomodate non standard epg files. 2025-05-24 15:07:49 -05:00
SergeantPanda
48e76273d1 Attempt at fixing timezone issues. 2025-05-22 10:23:59 -05:00
SergeantPanda
500e0941e2 Fixed calling process when it may not exist (log level higher than debug) 2025-05-21 12:11:03 -05:00
SergeantPanda
72783090cd Delete all instead of using a loop. 2025-05-20 20:36:04 -05:00
SergeantPanda
55089044fa Cleaned up code and logging a bit more. 2025-05-20 20:07:10 -05:00
SergeantPanda
451c892457 Changed logging levels. 2025-05-20 19:49:55 -05:00
SergeantPanda
cfad5621ce Found the problem. I hate lxml. 2025-05-20 18:43:43 -05:00
SergeantPanda
ae823ae8ea Even more debug logging. 2025-05-20 15:48:21 -05:00
SergeantPanda
7d6ef38bce Added helpful comments. 2025-05-20 15:34:03 -05:00
SergeantPanda
d52ff40db1 More logging 2025-05-20 15:15:00 -05:00
SergeantPanda
cc060bbed6 More memory logging to debug. 2025-05-20 14:49:29 -05:00