mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 23:42:58 +02:00
nhttpd-API: Updates to GetBouquetCGI
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@541 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -803,6 +803,45 @@ void CControlAPI::ChannellistCGI(CyhookHandler *hh)
|
||||
SendChannelList(hh);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CControlAPI::_GetBouquetWriteItem(CyhookHandler *hh, CZapitChannel * channel, int bouquetNr, int nr){
|
||||
if (hh->ParamList["format"] == "json"){
|
||||
hh->printf("\t\t{'number': '%u', 'id': '"
|
||||
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
||||
"', 'short_id': '"
|
||||
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
||||
"', 'name': '%s', logo: '%s', bouquetnr: '%d'}\n",
|
||||
nr,
|
||||
channel->channel_id,
|
||||
channel->channel_id&0xFFFFFFFFFFFFULL,
|
||||
channel->getName().c_str(),
|
||||
NeutrinoAPI->getLogoFile(hh->WebserverConfigList["Tuxbox.LogosURL"], channel->channel_id).c_str(),
|
||||
bouquetNr
|
||||
);
|
||||
}
|
||||
else if((hh->ParamList["format"] == "xml") || !(hh->ParamList["xml"].empty()) ){
|
||||
hh->printf("<channel>\n\t<number>%u</number>\n\t<bouquet>%d</bouquet>\n\t<id>"
|
||||
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
||||
"</id>\n\t<short_id>"
|
||||
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
||||
"</short_id>\n\t<name><![CDATA[%s]]></name>\n<logo><![CDATA[%s]]></logo>\n</channel>\n",
|
||||
nr,
|
||||
bouquetNr,
|
||||
channel->channel_id,
|
||||
channel->channel_id&0xFFFFFFFFFFFFULL,
|
||||
channel->getName().c_str(),
|
||||
NeutrinoAPI->getLogoFile(hh->WebserverConfigList["Tuxbox.LogosURL"], channel->channel_id).c_str()
|
||||
);
|
||||
}
|
||||
else{
|
||||
hh->printf("%u "
|
||||
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
||||
" %s\n",
|
||||
nr,
|
||||
channel->channel_id,
|
||||
channel->getName().c_str());
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void CControlAPI::GetBouquetCGI(CyhookHandler *hh)
|
||||
{
|
||||
@@ -835,64 +874,46 @@ void CControlAPI::GetBouquetCGI(CyhookHandler *hh)
|
||||
// write header
|
||||
if (hh->ParamList["format"] == "json"){
|
||||
hh->WriteLn("{");
|
||||
hh->printf("\t{bouquetnumber: %d}\n",hh->ParamList["bouquet"].c_str());
|
||||
hh->WriteLn("\t{cannels: {");
|
||||
}
|
||||
else if((hh->ParamList["format"] == "xml") || !(hh->ParamList["xml"].empty()) ){
|
||||
hh->WriteLn("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||
hh->WriteLn("<bouquetlist>");
|
||||
hh->printf("<bouquet>\n\t<bnumber>%s</bnumber>\n</bouquet>\n",hh->ParamList["bouquet"].c_str());
|
||||
hh->WriteLn("<channellist>");
|
||||
// hh->printf("<bouquet>\n\t<bnumber>%s</bnumber>\n</bouquet>\n",hh->ParamList["bouquet"].c_str());
|
||||
}
|
||||
|
||||
ZapitChannelList channels;
|
||||
int BouquetNr = atoi(hh->ParamList["bouquet"].c_str());
|
||||
if(BouquetNr > 0)
|
||||
BouquetNr--;
|
||||
channels = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->Bouquets[BouquetNr]->radioChannels : g_bouquetManager->Bouquets[BouquetNr]->tvChannels;
|
||||
int num = 1 + (mode == CZapitClient::MODE_RADIO ? g_bouquetManager->radioChannelsBegin().getNrofFirstChannelofBouquet(BouquetNr) : g_bouquetManager->tvChannelsBegin().getNrofFirstChannelofBouquet(BouquetNr)) ;
|
||||
for(int j = 0; j < (int) channels.size(); j++) {
|
||||
CZapitChannel * channel = channels[j];
|
||||
|
||||
if (hh->ParamList["format"] == "json"){
|
||||
hh->printf("\t\t{number: %u, id: "
|
||||
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
||||
", short_id: "
|
||||
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
||||
", name: %s, logo: %s}\n",
|
||||
num + j,
|
||||
channel->channel_id,
|
||||
channel->channel_id&0xFFFFFFFFFFFFULL,
|
||||
channel->getName().c_str(),
|
||||
NeutrinoAPI->getLogoFile(hh->WebserverConfigList["Tuxbox.LogosURL"], channel->channel_id).c_str()
|
||||
);
|
||||
if(hh->ParamList["bouquet"] != ""){
|
||||
// list for given bouquet
|
||||
int BouquetNr = atoi(hh->ParamList["bouquet"].c_str());
|
||||
if(BouquetNr > 0)
|
||||
BouquetNr--;
|
||||
channels = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->Bouquets[BouquetNr]->radioChannels : g_bouquetManager->Bouquets[BouquetNr]->tvChannels;
|
||||
int num = 1 + (mode == CZapitClient::MODE_RADIO ? g_bouquetManager->radioChannelsBegin().getNrofFirstChannelofBouquet(BouquetNr) : g_bouquetManager->tvChannelsBegin().getNrofFirstChannelofBouquet(BouquetNr)) ;
|
||||
for(int j = 0; j < (int) channels.size(); j++) {
|
||||
CZapitChannel * channel = channels[j];
|
||||
_GetBouquetWriteItem(hh, channel, BouquetNr, num+j);
|
||||
}
|
||||
else if((hh->ParamList["format"] == "xml") || !(hh->ParamList["xml"].empty()) ){
|
||||
hh->printf("<channel>\n\t<number>%u</number>\n\t<id>"
|
||||
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
||||
"</id>\n\t<short_id>"
|
||||
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
||||
"</short_id>\n\t<name><![CDATA[%s]]></name>\n<logo><![CDATA[%s]]></logo>\n</channel>\n",
|
||||
num + j,
|
||||
channel->channel_id,
|
||||
channel->channel_id&0xFFFFFFFFFFFFULL,
|
||||
channel->getName().c_str(),
|
||||
NeutrinoAPI->getLogoFile(hh->WebserverConfigList["Tuxbox.LogosURL"], channel->channel_id).c_str()
|
||||
);
|
||||
}
|
||||
else{
|
||||
hh->printf("%u "
|
||||
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
||||
" %s\n",
|
||||
num + j,
|
||||
channel->channel_id,
|
||||
channel->getName().c_str());
|
||||
} else {
|
||||
// list all
|
||||
for (int i = 0; i < (int) g_bouquetManager->Bouquets.size(); i++) {
|
||||
/*
|
||||
CBouquetManager::ChannelIterator cit = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->radioChannelsBegin() : g_bouquetManager->tvChannelsBegin();
|
||||
for (; !(cit.EndOfChannels()); cit++) {
|
||||
CZapitChannel * channel = *cit;*/
|
||||
channels = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->Bouquets[i]->radioChannels : g_bouquetManager->Bouquets[i]->tvChannels;
|
||||
int num = 1 + (mode == CZapitClient::MODE_RADIO ? g_bouquetManager->radioChannelsBegin().getNrofFirstChannelofBouquet(i) : g_bouquetManager->tvChannelsBegin().getNrofFirstChannelofBouquet(i)) ;
|
||||
for(int j = 0; j < (int) channels.size(); j++) {
|
||||
CZapitChannel * channel = channels[j];
|
||||
_GetBouquetWriteItem(hh, channel, i, num+j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// write footer
|
||||
if (hh->ParamList["format"] == "json")
|
||||
hh->WriteLn("\t}\n}");
|
||||
hh->WriteLn("}");
|
||||
else if((hh->ParamList["format"] == "xml") || !(hh->ParamList["xml"].empty()) )
|
||||
hh->WriteLn("</bouquetlist>");
|
||||
hh->WriteLn("</channellist>");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@@ -7,6 +7,7 @@
|
||||
// C++
|
||||
#include <string>
|
||||
// yhttpd
|
||||
#include <zapit/channel.h>
|
||||
#include "yhook.h"
|
||||
|
||||
// forward declaration
|
||||
@@ -44,6 +45,7 @@ private:
|
||||
void doModifyTimer(CyhookHandler *hh);
|
||||
void doNewTimer(CyhookHandler *hh);
|
||||
void _SendTime(CyhookHandler *hh, struct tm *Time, int digits);
|
||||
void _GetBouquetWriteItem(CyhookHandler *hh, CZapitChannel * channel, int bouquetNr, int nr);
|
||||
//yweb
|
||||
void YWeb_SendVideoStreamingPids(CyhookHandler *hh, int apid_no);
|
||||
void YWeb_SendRadioStreamingPid(CyhookHandler *hh);
|
||||
|
Reference in New Issue
Block a user