From 3498c8c8a606cbbe12da9790bfb3ec208d5d9b36 Mon Sep 17 00:00:00 2001 From: BPanther Date: Tue, 30 Apr 2024 09:26:25 +0200 Subject: [PATCH] yWeb: /control/getchannelinfo for short channel info added. Line 1: servicename, Line 2: epg info, Line 3: duration X/Y --- src/nhttpd/tuxboxapi/controlapi.cpp | 32 +++++++++++++++++++++++++++++ src/nhttpd/tuxboxapi/controlapi.h | 1 + 2 files changed, 33 insertions(+) diff --git a/src/nhttpd/tuxboxapi/controlapi.cpp b/src/nhttpd/tuxboxapi/controlapi.cpp index 101b40810..5815efa52 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -173,6 +173,7 @@ const CControlAPI::TyCgiCall CControlAPI::yCgiCallList[] = {"signal", &CControlAPI::SignalInfoCGI, "text/plain"}, {"getonidsid", &CControlAPI::GetChannelIDCGI, "text/plain"}, {"getchannelid", &CControlAPI::GetChannelIDCGI, ""}, + {"getchannelinfo", &CControlAPI::GetChannelInfoCGI, ""}, {"getepgid", &CControlAPI::GetEpgIDCGI, ""}, {"currenttpchannels", &CControlAPI::GetTPChannel_IDCGI, "text/plain"}, // boxcontrol - system @@ -737,6 +738,37 @@ void CControlAPI::GetChannelIDCGI(CyhookHandler *hh) hh->SendResult(result); } +// get actual channel_info +void CControlAPI::GetChannelInfoCGI(CyhookHandler *hh) +{ + t_channel_id channel_id = CZapit::getInstance()->GetCurrentChannelID(); + CZapitChannel *channel = CServiceManager::getInstance()->FindChannel48(channel_id); + + hh->outStart(); + std::string result = ""; + result = hh->outObject("name", hh->outValue(channel->getName()) + "\n"); + + CShortEPGData epg; + CSectionsdClient::responseGetCurrentNextInfoChannelID currentNextInfo; + CEitManager::getInstance()->getCurrentNextServiceKey(channel->getChannelID(), currentNextInfo); + + if (CEitManager::getInstance()->getEPGidShort(currentNextInfo.current_uniqueKey, &epg)) + { + result += hh->outObject("title", hh->outValue(epg.title) + "\n"); + } + + CChannelEvent event; + NeutrinoAPI->GetChannelEvents(); + NeutrinoAPI->GetChannelEvent(channel->getChannelID(), event); + + if (event.eventID) + { + result += hh->outObject("duration", string_printf("%d/", (time(NULL) - event.startTime) / 60) + string_printf("%d\n", event.duration / 60)); + } + + hh->SendResult(result); +} + //------------------------------------------------------------------------- /** Display epg id's * @param hh CyhookHandler diff --git a/src/nhttpd/tuxboxapi/controlapi.h b/src/nhttpd/tuxboxapi/controlapi.h index 765cd8d2e..059169367 100644 --- a/src/nhttpd/tuxboxapi/controlapi.h +++ b/src/nhttpd/tuxboxapi/controlapi.h @@ -86,6 +86,7 @@ class CControlAPI : public Cyhook void GetBouquetsxmlCGI(CyhookHandler *hh); void GetUBouquetsxmlCGI(CyhookHandler *hh); void GetChannelIDCGI(CyhookHandler *hh); + void GetChannelInfoCGI(CyhookHandler *hh); void GetEpgIDCGI(CyhookHandler *hh); void GetTPChannel_IDCGI(CyhookHandler *hh); void MessageCGI(CyhookHandler *hh);