diff --git a/src/eitd/xmlutil.cpp b/src/eitd/xmlutil.cpp index e1d8c6cd9..9c5254339 100644 --- a/src/eitd/xmlutil.cpp +++ b/src/eitd/xmlutil.cpp @@ -542,31 +542,29 @@ t_channel_id getepgid(std::string epg_name) CBouquetManager::ChannelIterator cit = g_bouquetManager->tvChannelsBegin(); - // FIXME: Maybe there's a nicer solution for (int m = CZapitClient::MODE_TV; m < CZapitClient::MODE_ALL; m++) { if (m == CZapitClient::MODE_RADIO) cit = g_bouquetManager->radioChannelsBegin(); - for (; !(cit.EndOfChannels()); cit++) - { - std::string tvg_id = (*cit)->getScriptName(); - - if (tvg_id.empty()) - continue; - - std::size_t found = tvg_id.find("#"+epg_name); - if (found != std::string::npos) + for (; !(cit.EndOfChannels()); cit++) { - tvg_id = tvg_id.substr(tvg_id.find_first_of("=")); - sscanf(tvg_id.c_str(), "=%" SCNx64, &epgid); - return epgid; - } - else - continue; - } + std::string tvg_id = (*cit)->getScriptName(); - } // for m-loop + if (tvg_id.empty()) + continue; + + std::size_t found = tvg_id.find("#"+epg_name); + if (found != std::string::npos) + { + tvg_id = tvg_id.substr(tvg_id.find_first_of("=")); + sscanf(tvg_id.c_str(), "=%" SCNx64, &epgid); + return epgid; + } + else + continue; + } + } return 0; } diff --git a/src/nhttpd/tuxboxapi/controlapi.cpp b/src/nhttpd/tuxboxapi/controlapi.cpp index 3232e8e5c..a68386290 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -3265,57 +3265,55 @@ void CControlAPI::xmltvepgCGI(CyhookHandler *hh) { g_bouquetManager->Bouquets[i]->getTvChannels(chanlist); - // FIXME: Maybe there's a nicer solution for (int m = CZapitClient::MODE_TV; m < CZapitClient::MODE_ALL; m++) { if (m == CZapitClient::MODE_RADIO) g_bouquetManager->Bouquets[i]->getRadioChannels(chanlist); - if(!chanlist.empty() && !g_bouquetManager->Bouquets[i]->bHidden && g_bouquetManager->Bouquets[i]->bUser) - { - for(unsigned int j = 0; j < chanlist.size(); j++) + if(!chanlist.empty() && !g_bouquetManager->Bouquets[i]->bHidden && g_bouquetManager->Bouquets[i]->bUser) { - CZapitChannel * channel = chanlist[j]; - channel_id = channel->getChannelID() & 0xFFFFFFFFFFFFULL; - channelTag = "channel id=\""+string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id)+"\""; - channelData = hh->outPair("display-name", hh->outValue(channel->getName(), xml_cdata), true); - result += hh->outObject(channelTag, channelData); - - eList.clear(); - - CEitManager::getInstance()->getEventsServiceKey(channel_id, eList); - - if (eList.size() == 0) - continue; - - if (eList.size() > 50) - eList.erase(eList.begin()+50,eList.end()); - - for (eventIterator = eList.begin(); eventIterator != eList.end(); ++eventIterator) + for(unsigned int j = 0; j < chanlist.size(); j++) { - if (eventIterator->get_channel_id() == channel_id) + CZapitChannel * channel = chanlist[j]; + channel_id = channel->getChannelID() & 0xFFFFFFFFFFFFULL; + channelTag = "channel id=\""+string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id)+"\""; + channelData = hh->outPair("display-name", hh->outValue(channel->getName(), xml_cdata), true); + result += hh->outObject(channelTag, channelData); + + eList.clear(); + + CEitManager::getInstance()->getEventsServiceKey(channel_id, eList); + + if (eList.size() == 0) + continue; + + if (eList.size() > 50) + eList.erase(eList.begin()+50,eList.end()); + + for (eventIterator = eList.begin(); eventIterator != eList.end(); ++eventIterator) { - programmeTag = "programme "; - programmeTag += "channel=\""+string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id)+"\" "; - char zbuffer[25] = { 0 }; - struct tm *mtime = gmtime(&eventIterator->startTime); - strftime(zbuffer, 21, "%Y%m%d%H%M%S %z", mtime); - programmeTag += "start=\""+std::string(zbuffer)+"\" "; - long _stoptime = eventIterator->startTime + eventIterator->duration; - mtime = gmtime(&_stoptime); - strftime(zbuffer, 21, "%Y%m%d%H%M%S %z", mtime); - programmeTag += "stop=\""+std::string(zbuffer)+"\" "; + if (eventIterator->get_channel_id() == channel_id) + { + programmeTag = "programme "; + programmeTag += "channel=\""+string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id)+"\" "; + char zbuffer[25] = { 0 }; + struct tm *mtime = gmtime(&eventIterator->startTime); + strftime(zbuffer, 21, "%Y%m%d%H%M%S %z", mtime); + programmeTag += "start=\""+std::string(zbuffer)+"\" "; + long _stoptime = eventIterator->startTime + eventIterator->duration; + mtime = gmtime(&_stoptime); + strftime(zbuffer, 21, "%Y%m%d%H%M%S %z", mtime); + programmeTag += "stop=\""+std::string(zbuffer)+"\" "; - programmeData = hh->outPair("title lang=\"de\"", hh->outValue(eventIterator->description, xml_cdata), false); - programmeData += hh->outPair("desc lang=\"de\"", hh->outValue(eventIterator->text, xml_cdata), true); + programmeData = hh->outPair("title lang=\"de\"", hh->outValue(eventIterator->description, xml_cdata), false); + programmeData += hh->outPair("desc lang=\"de\"", hh->outValue(eventIterator->text, xml_cdata), true); - result += hh->outArrayItem(programmeTag, programmeData, false); + result += hh->outArrayItem(programmeTag, programmeData, false); + } } } } } - - } // for m-loop } result = hh->outObject("tv generator-info-name=\"Neutrino XMLTV Generator v1.0\"", result); @@ -3358,7 +3356,6 @@ void CControlAPI::xmltvm3uCGI(CyhookHandler *hh) { ZapitChannelList chanlist; - // FIXME: Maybe there's a nicer solution for (int m = CZapitClient::MODE_TV; m < CZapitClient::MODE_ALL; m++) { if (mode == CZapitClient::MODE_RADIO || m == CZapitClient::MODE_RADIO) @@ -3366,33 +3363,33 @@ void CControlAPI::xmltvm3uCGI(CyhookHandler *hh) else g_bouquetManager->Bouquets[i]->getTvChannels(chanlist); - if (!chanlist.empty() && !g_bouquetManager->Bouquets[i]->bHidden && g_bouquetManager->Bouquets[i]->bUser) - { - for (unsigned int j = 0; j < chanlist.size(); j++) + if (!chanlist.empty() && !g_bouquetManager->Bouquets[i]->bHidden && g_bouquetManager->Bouquets[i]->bUser) { - CZapitChannel *channel = chanlist[j]; - std::string bouq_name = g_bouquetManager->Bouquets[i]->bName; - std::string chan_id_short = string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel->getChannelID() & 0xFFFFFFFFFFFFULL); - result += "#EXTINF:-1 tvg-id=\"" + chan_id_short + "\""; - result += " tvg-name=\"" + channel->getName() + "\""; - if (!NeutrinoAPI->getLogoFile(channel->getChannelID()).empty()) - result += " tvg-logo=\"" + host + NeutrinoAPI->getLogoFile(channel->getChannelID()) + "\""; - else - result += " tvg-logo=\"\""; - if (mode == CZapitClient::MODE_RADIO || m == CZapitClient::MODE_RADIO) - result += " radio=\"true\""; - else - result += " radio=\"\""; - result += " group-prefix=\"" + std::string(hostname) + "\""; - result += " group-title=\"" + bouq_name + "\","; - result += channel->getName() + "\n"; - result += url + string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel->getChannelID()) + "\n"; + for (unsigned int j = 0; j < chanlist.size(); j++) + { + CZapitChannel *channel = chanlist[j]; + std::string bouq_name = g_bouquetManager->Bouquets[i]->bName; + std::string chan_id_short = string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel->getChannelID() & 0xFFFFFFFFFFFFULL); + result += "#EXTINF:-1 tvg-id=\"" + chan_id_short + "\""; + result += " tvg-name=\"" + channel->getName() + "\""; + if (!NeutrinoAPI->getLogoFile(channel->getChannelID()).empty()) + result += " tvg-logo=\"" + host + NeutrinoAPI->getLogoFile(channel->getChannelID()) + "\""; + else + result += " tvg-logo=\"\""; + if (mode == CZapitClient::MODE_RADIO || m == CZapitClient::MODE_RADIO) + result += " radio=\"true\""; + else + result += " radio=\"\""; + result += " group-prefix=\"" + std::string(hostname) + "\""; + result += " group-title=\"" + bouq_name + "\","; + result += channel->getName() + "\n"; + result += url + string_printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel->getChannelID()) + "\n"; + } } - } if (mode != CZapitClient::MODE_ALL) break; - } // for m-loop + } } hh->SendResult(result);