Trigger a Celery task to set channel names from EPG data
(self, request)
| 1496 | |
| 1497 | @action(detail=False, methods=["post"], url_path="set-names-from-epg") |
| 1498 | def set_names_from_epg(self, request): |
| 1499 | """ |
| 1500 | Trigger a Celery task to set channel names from EPG data |
| 1501 | """ |
| 1502 | from .tasks import set_channels_names_from_epg |
| 1503 | |
| 1504 | data = request.data |
| 1505 | channel_ids = data.get("channel_ids", []) |
| 1506 | |
| 1507 | if not channel_ids: |
| 1508 | return Response( |
| 1509 | {"error": "channel_ids is required"}, |
| 1510 | status=status.HTTP_400_BAD_REQUEST, |
| 1511 | ) |
| 1512 | |
| 1513 | if not isinstance(channel_ids, list): |
| 1514 | return Response( |
| 1515 | {"error": "channel_ids must be a list"}, |
| 1516 | status=status.HTTP_400_BAD_REQUEST, |
| 1517 | ) |
| 1518 | |
| 1519 | # Start the Celery task |
| 1520 | task = set_channels_names_from_epg.delay(channel_ids) |
| 1521 | |
| 1522 | return Response({ |
| 1523 | "message": f"Started EPG name setting task for {len(channel_ids)} channels", |
| 1524 | "task_id": task.id, |
| 1525 | "channel_count": len(channel_ids) |
| 1526 | }) |
| 1527 | |
| 1528 | @action(detail=False, methods=["post"], url_path="set-logos-from-epg") |
| 1529 | def set_logos_from_epg(self, request): |