From c4c358720bd4d677bb7f6cc1aaf2efee8ef9771f Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Tue, 21 Apr 2015 14:31:00 +0200 Subject: [PATCH] - controlapi: add logolist command to allow easy channellogo management --- src/nhttpd/doc/nhttpd_controlapi.html | 28 ++++++++++++++ .../tuxboxapi/coolstream/controlapi.cpp | 37 +++++++++++++++++++ src/nhttpd/tuxboxapi/coolstream/controlapi.h | 1 + 3 files changed, 66 insertions(+) diff --git a/src/nhttpd/doc/nhttpd_controlapi.html b/src/nhttpd/doc/nhttpd_controlapi.html index d67934fb1..d6d8d9729 100644 --- a/src/nhttpd/doc/nhttpd_controlapi.html +++ b/src/nhttpd/doc/nhttpd_controlapi.html @@ -251,6 +251,11 @@ http://box_ip/control/build_live_url + + 54. Listet Senderlogos + + http://box_ip/control/logolist +     @@ -2181,6 +2186,29 @@ Beispiel:
http://box_ip:31339/id=bae8000600850083
  + +
54. Listet Senderlogos
+
Handler: http://box_ip/control/logolist
+
+Parameter: keine oder files +

+Rückgabe: ChannelID;Channelname;Logoname ohne Erweiterung[;benutztes Logo[;Ziel des Symlinks]] +

+Liste aller Kanäle incl. Logonamen
+Wird der Parameter files angegeben, wird - sofern vorhanden - der Dateiname des benutzen
+Senderlogos angehangen.
+Ist diese Datei ein symbolischer Link, wird noch zusätzlich das Ziel diesen Links angehangen. +
+
+Beispiel:
+
+>>>http://box_ip/control/logolist?files
+4c9d044d00016dca;Das Erste;44d00016dca;/share/logo/44d00016dca.png
+66dd03fb0001283d;Das Erste HD;3fb0001283d;/share/logo/3fb0001283d.png;/share/logo/3f300012b5c.png
+5b9d045900013355;BTV;45900013355
+519d0007008532da;Folx TV;7008532da
+   

diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp index 7d4290c3d..8f9fb0f8d 100644 --- a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp @@ -39,6 +39,8 @@ #include #include #include +#include +extern CPictureViewer *g_PicViewer; // yhttpd #include @@ -155,6 +157,7 @@ const CControlAPI::TyCgiCall CControlAPI::yCgiCallList[]= {"getservicesxml", &CControlAPI::GetServicesxmlCGI,""}, {"getbouquetsxml", &CControlAPI::GetBouquetsxmlCGI,""}, {"channellist", &CControlAPI::ChannellistCGI, "text/plain"}, + {"logolist", &CControlAPI::LogolistCGI, "text/plain"}, {"getbouquet", &CControlAPI::GetBouquetCGI, "+xml"}, {"getbouquets", &CControlAPI::GetBouquetsCGI, "+xml"}, {"getmode", &CControlAPI::GetModeCGI, "text/plain"}, @@ -830,6 +833,40 @@ void CControlAPI::ChannellistCGI(CyhookHandler *hh) SendChannelList(hh); } +void CControlAPI::LogolistCGI(CyhookHandler *hh) +{ + std::string result = ""; + int mode = NeutrinoAPI->Zapit->getMode(); + CBouquetManager::ChannelIterator cit = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->radioChannelsBegin() : g_bouquetManager->tvChannelsBegin(); + for (; !(cit.EndOfChannels()); cit++) + { + std::vector v; + CZapitChannel * channel = *cit; + size_t pos = std::find(v.begin(), v.end(), channel->getChannelID()) - v.begin(); + if (pos < v.size()) + continue; + v.push_back(channel->getChannelID()); + result += string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS";%s;"PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS"", channel->getChannelID(), channel->getName().c_str(), (channel->getChannelID() & 0xFFFFFFFFFFFFULL)); + + if (hh->ParamList["1"].compare("files") == 0) + { + std::string logoFile = ""; + std::string logoLink = ""; + char link[PATH_MAX + 1] = {0}; + if (g_PicViewer->GetLogoName(channel->getChannelID(), NeutrinoAPI->GetServiceName(channel->getChannelID()), logoFile, NULL, NULL)) + { + result += string_printf(";%s", logoFile.c_str()); + realpath(logoFile.c_str(), link); + logoLink = string(link); + if (strcmp(logoFile.c_str(), logoLink.c_str()) != 0) + result += string_printf(";%s", logoLink.c_str()); + } + } + + result += "\n"; + } + hh->WriteLn(result); +} //----------------------------------------------------------------------------- // get actual and next event data for given channel //----------------------------------------------------------------------------- diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.h b/src/nhttpd/tuxboxapi/coolstream/controlapi.h index 90b36de9e..a946f3c1c 100644 --- a/src/nhttpd/tuxboxapi/coolstream/controlapi.h +++ b/src/nhttpd/tuxboxapi/coolstream/controlapi.h @@ -78,6 +78,7 @@ private: void ShutdownCGI(CyhookHandler *hh); void VolumeCGI(CyhookHandler *hh); void ChannellistCGI(CyhookHandler *hh); + void LogolistCGI(CyhookHandler *hh); void GetBouquetCGI(CyhookHandler *hh); void GetBouquetsCGI(CyhookHandler *hh); void EpgCGI(CyhookHandler *hh);