restructure epg

This commit is contained in:
Nirvana
2026-06-17 21:33:47 +02:00
parent ccb87473e3
commit b19b3a9905
+18
View File
@@ -266,6 +266,13 @@ def setup_epg_routes(app, manager, service):
country=country,
)
# Serialize EPGEntry objects to dicts here, at the response
# boundary — epg_ops returns EPGEntry objects (not JSON-safe).
grid_data = {
cid: [entry.to_dict() for entry in entries]
for cid, entries in grid_data.items()
}
response.content_type = "application/json; charset=utf-8"
return {
"provider": provider,
@@ -321,6 +328,10 @@ def setup_epg_routes(app, manager, service):
country=country,
)
# Serialize EPGEntry objects to dicts here, at the response
# boundary — epg_ops returns EPGEntry objects (not JSON-safe).
programs = [entry.to_dict() for entry in programs]
response.content_type = "application/json; charset=utf-8"
return {
"provider": provider,
@@ -364,6 +375,13 @@ def setup_epg_routes(app, manager, service):
response.content_type = "application/json; charset=utf-8"
return {"error": f"Program '{program_id}' not found for provider '{provider}'"}
# Serialize EPGEntry objects to dicts here, at the response
# boundary — epg_ops returns EPGEntry objects (not JSON-safe)
# on the native path. The generic fallback path can return a
# plain dict, so only convert if it's actually an EPGEntry.
if hasattr(program_data, "to_dict"):
program_data = program_data.to_dict()
response.content_type = "application/json; charset=utf-8"
return {
"provider": provider,