mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-01-23 02:35:14 +00:00
Update epg tasks.py
Added gzip support for unzipping EPG files
This commit is contained in:
parent
1dcbf8875f
commit
725c21ed56
1 changed files with 11 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import gzip # <-- New import for gzip support
|
||||
from celery import shared_task
|
||||
from .models import EPGSource, EPGData, ProgramData
|
||||
from django.utils import timezone
|
||||
|
|
@ -29,7 +30,16 @@ def fetch_xmltv(source):
|
|||
response = requests.get(source.url, timeout=30)
|
||||
response.raise_for_status()
|
||||
logger.debug("XMLTV data fetched successfully.")
|
||||
root = ET.fromstring(response.content)
|
||||
|
||||
# If the URL ends with '.gz', decompress the response content
|
||||
if source.url.lower().endswith('.gz'):
|
||||
logger.debug("Detected .gz file. Decompressing...")
|
||||
decompressed_bytes = gzip.decompress(response.content)
|
||||
xml_data = decompressed_bytes.decode('utf-8')
|
||||
else:
|
||||
xml_data = response.text
|
||||
|
||||
root = ET.fromstring(xml_data)
|
||||
logger.debug("Parsed XMLTV XML content.")
|
||||
|
||||
# Group programmes by their tvg_id from the XMLTV file
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue