Bug Fix: XC get_simple_data_table now returns the id of the program in the database and epg_id the epg id from the matched epg.

This commit is contained in:
SergeantPanda 2025-12-18 16:11:26 -06:00
parent 73956924f5
commit e78c18c473
2 changed files with 16 additions and 4 deletions

View file

@ -30,6 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- nginx now gracefully handles hosts without IPv6 support by automatically disabling IPv6 binding at startup (Fixes #744)
- XtreamCodes EPG API now returns correct date/time format for start/end fields and proper string types for timestamps and channel_id
- XtreamCodes EPG API now handles None values for title and description fields to prevent AttributeError
- XtreamCodes EPG `id` field now provides unique identifiers per program listing instead of always returning "0" for better client EPG handling
- XtreamCodes EPG `epg_id` field now correctly returns the EPGData record ID (representing the EPG source/channel mapping) instead of a dummy value
## [0.14.0] - 2025-12-09

View file

@ -2292,17 +2292,27 @@ def xc_get_epg(request, user, short=False):
output = {"epg_listings": []}
for program in programs:
id = "0"
epg_id = "0"
title = program['title'] if isinstance(program, dict) else program.title
description = program['description'] if isinstance(program, dict) else program.description
start = program["start_time"] if isinstance(program, dict) else program.start_time
end = program["end_time"] if isinstance(program, dict) else program.end_time
# For database programs, use actual ID; for generated dummy programs, create synthetic ID
if isinstance(program, dict):
# Generated dummy program - create unique ID from channel + timestamp
program_id = str(abs(hash(f"{channel_id}_{int(start.timestamp())}")))
else:
# Database program - use actual ID
program_id = str(program.id)
# epg_id refers to the EPG source/channel mapping in XC panels
# Use the actual EPGData ID when available, otherwise fall back to 0
epg_id = str(channel.epg_data.id) if channel.epg_data else "0"
program_output = {
"id": f"{id}",
"epg_id": f"{epg_id}",
"id": program_id,
"epg_id": epg_id,
"title": base64.b64encode((title or "").encode()).decode(),
"lang": "",
"start": start.strftime("%Y-%m-%d %H:%M:%S"),