Commit graph

136 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
759569b871 Enhancement: Add a priority field to EPGSource and prefer higher-priority sources when matching channels. Also ignore EPG sources where is_active is false during matching, and update serializers/forms/frontend accordingly.(Closes #603, #672) 2025-12-05 09:54:11 -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
28c211cd56 Enhancement: Add {endtime} as an available output for custom dummy epg. Convert {time} to {starttime}
Closes #590
2025-10-29 17:10:35 -05:00
SergeantPanda
57b99e3900 Enhancement: Change sub_title field in ProgramData model from CharField to TextField. This will allow for longer than 255 character sub titles. (Closes #579) 2025-10-22 17:02:40 -05: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
a12bfeab46 Enhancement: Increase max_length of URL field in EPGSource model to 1000 characters 2025-09-24 16:12:17 -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
SergeantPanda
eec53d5874
Merge pull request #294 from pantherale0/feat/chunked-extractor
Fix: Prevent memory exhaustion when extracting large compressed files
2025-08-14 09:50:52 -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
7b5a617bf8 Use custom validator for urls fields to allow for non fqdn hostnames.
Fixes #63
2025-08-01 11:28:51 -05: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
dekzter
a1576bd493 merged in dev 2025-06-10 08:55:14 -04:00
SergeantPanda
e7bf8cbede Added support for LIVE tag and dd_progrid numbering systems for epg. 2025-06-03 22:00:17 -05:00
dekzter
9f96529707 merged in main 2025-06-03 17:49:24 -04:00
dekzter
3f445607e0 looooots of updates for user-management, initial commit of access control 2025-05-31 18:01:46 -04: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
dekzter
6504db3bd4 merged in dev 2025-05-28 18:34:45 -04: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
45239b744c Delete cached files when deleting epg account. 2025-05-26 16:19:57 -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