mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-08-02 23:02:37 +00:00
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
This commit is contained in:
parent
d06c5bfdf3
commit
0a15e09805
1 changed files with 5 additions and 3 deletions
|
|
@ -875,15 +875,17 @@ def parse_channels_only(source):
|
|||
if process:
|
||||
logger.debug(f"[parse_channels_only] Memory after opening file: {process.memory_info().rss / 1024 / 1024:.2f} MB")
|
||||
|
||||
# Change iterparse to look for both channel and programme elements
|
||||
# Use iterparse to find the <tv> element
|
||||
logger.debug(f"Creating iterparse context for channels and programmes")
|
||||
channel_parser = etree.iterparse(source_file, events=('end',), tag=('channel', 'programme'), remove_blank_text=True, recover=True)
|
||||
tv_finder = etree.iterparse(source_file, events=('start',), tag='tv', remove_blank_text=True, recover=True)
|
||||
_, tv_root = next(tv_finder)
|
||||
if process:
|
||||
logger.debug(f"[parse_channels_only] Memory after creating iterparse: {process.memory_info().rss / 1024 / 1024:.2f} MB")
|
||||
|
||||
channel_count = 0
|
||||
total_elements_processed = 0 # Track total elements processed, not just channels
|
||||
for _, elem in channel_parser:
|
||||
|
||||
for elem in tv_root.iter('channel', 'programme'):
|
||||
total_elements_processed += 1
|
||||
# Only process channel elements
|
||||
if elem.tag == 'channel':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue