- controlapi: allow search in EPG-titles only; fix typo

* Sytax:
  http://STBIP/control/epgsearch?SEARCHWORDS&epginfo=false
  or
  http://STBIP/control/epgsearchxml?SEARCHWORDS&epginfo=false
This commit is contained in:
svenhoefer
2015-04-13 12:34:12 +02:00
parent 3c82d147db
commit ca34388616
2 changed files with 32 additions and 22 deletions

View File

@@ -1335,23 +1335,31 @@ inline static bool sortByDateTime (const CChannelEvent& a, const CChannelEvent&
return a.startTime < b.startTime; return a.startTime < b.startTime;
} }
extern const char * GetGenre(const unsigned char contentClassification); // UTF-8 extern const char * GetGenre(const unsigned char contentClassification); // UTF-8
void CControlAPI::EpgSearchXMLCGI(CyhookHandler *hh) void CControlAPI::EpgSearchXMLCGI(CyhookHandler *hh)
{ {
EpgSearchCGI(hh, true);//xml_forat = true EpgSearchCGI(hh, true); //xml_format = true
}
void CControlAPI::EpgSearchTXTCGI(CyhookHandler *hh)
{
EpgSearchCGI(hh, false);//xml_forat = false
} }
void CControlAPI::EpgSearchCGI(CyhookHandler *hh, bool xml_forat ) void CControlAPI::EpgSearchTXTCGI(CyhookHandler *hh)
{
EpgSearchCGI(hh, false); //xml_format = false
}
void CControlAPI::EpgSearchCGI(CyhookHandler *hh, bool xml_format )
{ {
t_channel_id channel_id; t_channel_id channel_id;
CChannelEventList evtlist; CChannelEventList evtlist;
bool param_empty = hh->ParamList.empty();
const int m_search_epg_item = 5; if (!hh->ParamList.empty()) {
if(!param_empty){ bool search_epginfo = true;
if(xml_forat){ if (hh->ParamList["epginfo"] == "false")
search_epginfo = false;
const int m_search_epg_item = search_epginfo ? 5 /*SEARCH_EPG_ALL*/ : 1 /*SEARCH_EPG_TITLE*/;
std::string m_search_keyword = hh->ParamList["1"];
if(xml_format){
hh->SetHeader(HTTP_OK, "text/xml; charset=UTF-8"); hh->SetHeader(HTTP_OK, "text/xml; charset=UTF-8");
hh->WriteLn("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); hh->WriteLn("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
hh->WriteLn("<neutrino commandversion=\"1\">"); hh->WriteLn("<neutrino commandversion=\"1\">");
@@ -1359,8 +1367,6 @@ void CControlAPI::EpgSearchCGI(CyhookHandler *hh, bool xml_forat )
else{ else{
hh->SetHeader(HTTP_OK, "text/plain; charset=UTF-8"); // default hh->SetHeader(HTTP_OK, "text/plain; charset=UTF-8"); // default
} }
std::string m_search_keyword =hh->ParamList["1"];
std::vector<t_channel_id> v; std::vector<t_channel_id> v;
int channel_nr = CNeutrinoApp::getInstance ()->channelList->getSize();//unique channelList TV or Radio int channel_nr = CNeutrinoApp::getInstance ()->channelList->getSize();//unique channelList TV or Radio
@@ -1404,12 +1410,14 @@ void CControlAPI::EpgSearchCGI(CyhookHandler *hh, bool xml_forat )
if( (eventIterator->startTime+eventIterator->duration) < u_azeit) if( (eventIterator->startTime+eventIterator->duration) < u_azeit)
continue; continue;
struct tm *tmStartZeit = localtime(&eventIterator->startTime); struct tm *tmStartZeit = localtime(&eventIterator->startTime);
if(xml_forat){ if(xml_format){
hh->printf("\t<epgsearch>"); hh->printf("\t<epgsearch>");
hh->printf("\t\t<channelname>%s</channelname>\n",ZapitTools::UTF8_to_UTF8XML(NeutrinoAPI->GetServiceName(eventIterator->channelID).c_str()).c_str());; hh->printf("\t\t<channelname>%s</channelname>\n",ZapitTools::UTF8_to_UTF8XML(NeutrinoAPI->GetServiceName(eventIterator->channelID).c_str()).c_str());;
hh->printf("\t\t<epgtitle>%s</epgtitle>\n",ZapitTools::UTF8_to_UTF8XML(epg.title.c_str()).c_str()); hh->printf("\t\t<epgtitle>%s</epgtitle>\n",ZapitTools::UTF8_to_UTF8XML(epg.title.c_str()).c_str());
hh->printf("\t\t<info1>%s</info1>\n",ZapitTools::UTF8_to_UTF8XML(epg.info1.c_str()).c_str()); if (search_epginfo) {
hh->printf("\t\t<info2>%s</info2>\n",ZapitTools::UTF8_to_UTF8XML(epg.info2.c_str()).c_str()); hh->printf("\t\t<info1>%s</info1>\n",ZapitTools::UTF8_to_UTF8XML(epg.info1.c_str()).c_str());
hh->printf("\t\t<info2>%s</info2>\n",ZapitTools::UTF8_to_UTF8XML(epg.info2.c_str()).c_str());
}
if (CEitManager::getInstance()->getEPGid(eventIterator->eventID, eventIterator->startTime, &longepg)) { if (CEitManager::getInstance()->getEPGid(eventIterator->eventID, eventIterator->startTime, &longepg)) {
hh->printf("\t\t<fsk>%u</fsk>\n", longepg.fsk); hh->printf("\t\t<fsk>%u</fsk>\n", longepg.fsk);
#ifdef FULL_CONTENT_CLASSIFICATION #ifdef FULL_CONTENT_CLASSIFICATION
@@ -1448,10 +1456,12 @@ void CControlAPI::EpgSearchCGI(CyhookHandler *hh, bool xml_forat )
hh->WriteLn(datetimer_str); hh->WriteLn(datetimer_str);
hh->WriteLn(NeutrinoAPI->GetServiceName(eventIterator->channelID)); hh->WriteLn(NeutrinoAPI->GetServiceName(eventIterator->channelID));
hh->WriteLn(epg.title); hh->WriteLn(epg.title);
if(!epg.info1.empty()) if (search_epginfo) {
hh->WriteLn(epg.info1); if(!epg.info1.empty())
if(!epg.info2.empty()) hh->WriteLn(epg.info1);
hh->WriteLn(epg.info2); if(!epg.info2.empty())
hh->WriteLn(epg.info2);
}
if (CEitManager::getInstance()->getEPGid(eventIterator->eventID, eventIterator->startTime, &longepg)) { if (CEitManager::getInstance()->getEPGid(eventIterator->eventID, eventIterator->startTime, &longepg)) {
hh->printf("fsk:%u\n", longepg.fsk); hh->printf("fsk:%u\n", longepg.fsk);
#ifdef FULL_CONTENT_CLASSIFICATION #ifdef FULL_CONTENT_CLASSIFICATION
@@ -1473,7 +1483,7 @@ void CControlAPI::EpgSearchCGI(CyhookHandler *hh, bool xml_forat )
} }
} }
} }
if(xml_forat) if(xml_format)
hh->printf("</neutrino>"); hh->printf("</neutrino>");
}else }else
hh->SendError(); hh->SendError();

View File

@@ -42,7 +42,7 @@ private:
void epgDetailList(CyhookHandler *hh); void epgDetailList(CyhookHandler *hh);
void EpgSearchXMLCGI(CyhookHandler *hh); void EpgSearchXMLCGI(CyhookHandler *hh);
void EpgSearchTXTCGI(CyhookHandler *hh); void EpgSearchTXTCGI(CyhookHandler *hh);
void EpgSearchCGI(CyhookHandler *hh, bool xml_forat = false); void EpgSearchCGI(CyhookHandler *hh, bool xml_format = false);
// subs // subs
friend class CNeutrinoWebserver; // for timer /fb/ compatibility friend class CNeutrinoWebserver; // for timer /fb/ compatibility
void doModifyTimer(CyhookHandler *hh); void doModifyTimer(CyhookHandler *hh);