Dispatcharr/apps/epg
Curt LeCaptain 408c3c6bea feat(epg): add native xz decompression support for EPG sources
Adds .xz to the set of compressed formats detect_file_format(),
extract_compressed_file(), fetch_xmltv(), and EPGSource.get_cache_file()
recognize, mirroring the existing gzip handling. Uses stdlib lzma, no new
dependency. Detection works via LZMA magic bytes (fd 37 7a 58 5a 00),
the .xz extension (including compound extensions like .xml.xz), and the
application/x-xz mimetype fallback.

Widened the magic-byte read in get_cache_file() from 4 to 6 bytes since
the xz signature is 6 bytes (the previous 4-byte read was sufficient
only for the 2-byte gzip/zip signatures it originally supported). That
widening silently broke the bare-<tv> raw-XML detection: the
fixed-length slice comparison header[:5] == b'<tv>' can never match a
5-byte slice of a 6-byte header against a 4-byte literal. Replaced the
fixed-length slice comparisons with header.startswith(...), which is
correct regardless of how many bytes are read - this also fixes the
adjacent <?xml declaration check, which was silently dead before this
change (a 4-byte read could never equal the 5-byte b'<?xml' literal
either).

Fixes Dispatcharr/Dispatcharr#1414

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 19:48:44 -05:00
..
migrations refactor(epg): separate programme index into dedicated table for optimized data handling 2026-06-23 15:10:27 -05:00
tests feat(epg): add native xz decompression support for EPG sources 2026-07-07 19:48:44 -05:00
__init__.py
admin.py
api_urls.py
api_views.py enhancement(epg): add export lookback and cutoff parameters to EPG generation 2026-06-23 15:27:15 -05:00
apps.py
models.py feat(epg): add native xz decompression support for EPG sources 2026-07-07 19:48:44 -05:00
query_utils.py
serializers.py
signals.py
tasks.py feat(epg): add native xz decompression support for EPG sources 2026-07-07 19:48:44 -05:00
urls.py
utils.py
views.py