From a1ac4f7b958d48f1c16b3bcf3354e3b20f5b1b9c Mon Sep 17 00:00:00 2001 From: BPanther Date: Fri, 3 May 2024 21:09:51 +0200 Subject: [PATCH] yWeb: /control/getchannelinfo for short channel info added. Line 1: servicename Line 2: epg info Line 3: duration X/Y Origin commit data ------------------ Commit: https://github.com/Duckbox-Developers/neutrino-ddt/commit/3498c8c8a606cbbe12da9790bfb3ec208d5d9b36 Author: BPanther Date: 2024-04-30 (Tue, 30 Apr 2024) ------------------ This commit was generated by Migit --- 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 3119d42e9..7a2783a40 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -207,6 +207,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 @@ -762,6 +763,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 34e5e36e3..a77c3f110 100644 --- a/src/nhttpd/tuxboxapi/controlapi.h +++ b/src/nhttpd/tuxboxapi/controlapi.h @@ -87,6 +87,7 @@ private: 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);