Import, manage, and generate Electronic Program Guide data from multiple sources including XMLTV, Schedules Direct, and custom dummy EPG
Dispatcharr provides comprehensive EPG (Electronic Program Guide) management with support for multiple sources, automatic matching, and custom guide generation.
# From epg/tasks.pydef refresh_epg_data(source_id): # Download with progress tracking response = requests.get(url, stream=True) total_size = int(response.headers.get('content-length', 0)) # Send WebSocket updates during download for chunk in response.iter_content(chunk_size=8192): downloaded += len(chunk) progress = int((downloaded / total_size) * 100) send_epg_update(source_id, 'downloading', progress)
Real-time progress updates show download status in the UI.
Decompression Phase
Automatically detects and extracts:
Gzip files using Python’s gzip module
Zip archives using zipfile module
Stores extracted XML for parsing
Large XMLTV files can consume significant memory during decompression. The system uses chunked processing to minimize memory usage.
Parsing Phase
# Efficient streaming XML parser using lxmlfor event, elem in etree.iterparse(xml_path): if elem.tag == 'channel': # Extract channel metadata tvg_id = elem.get('id') name = elem.find('display-name').text icon_url = elem.find('icon').get('src') elif elem.tag == 'programme': # Extract program data channel_id = elem.get('channel') start = parse_datetime(elem.get('start')) end = parse_datetime(elem.get('stop')) title = elem.find('title').text # Clear element to free memory elem.clear()
Streaming parser handles files with 100k+ programs efficiently.
# From channels/tasks.pydef match_epg_channels(): """Match all unmatched channels to EPG data""" channels_without_epg = Channel.objects.filter(epg_data__isnull=True) for channel in channels_without_epg: # Try TVG ID match first if channel.tvg_id: epg_matches = EPGData.objects.filter(tvg_id=channel.tvg_id) # Use priority if multiple matches if epg_matches.exists(): epg = epg_matches.order_by('-epg_source__priority').first() channel.epg_data = epg channel.save()
Run auto-matching from the Channels page → Actions → Match EPG, or configure automatic matching after EPG refresh.
EPG Setup:├── XMLTV from Provider (Priority: 100)│ └── Covers 80% of channels├── Schedules Direct (Priority: 200)│ └── Covers US channels with high accuracy└── Dummy EPG (Priority: 10) └── Fallback for remaining channelsResult: Best available guide data for each channel
Scenario: Build custom guide for curated channels1. Import multiple XMLTV sources2. Set priorities based on accuracy3. Auto-match channels to EPG data4. Export unified XMLTV for Plex/Jellyfin