diff --git a/src/gui/webchannels_setup.cpp b/src/gui/webchannels_setup.cpp index ea22c4037..bba62236a 100644 --- a/src/gui/webchannels_setup.cpp +++ b/src/gui/webchannels_setup.cpp @@ -278,6 +278,7 @@ int CWebChannelsSetup::Show() } webchannels_auto(); g_Zapit->reinitChannels(); + CNeutrinoApp::getInstance()->xmltv_xml_m3u_readepg(); changed = false; hint.hide(); } diff --git a/src/neutrino.cpp b/src/neutrino.cpp index c429e64da..b192d8a42 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -968,6 +968,8 @@ int CNeutrinoApp::loadSetup(const char *fname) } } + g_settings.xmltv_xml_m3u.clear(); + g_settings.livestreamResolution = configfile.getInt32("livestreamResolution", 1920); g_settings.livestreamScriptPath = configfile.getString("livestreamScriptPath", WEBTVDIR); @@ -3325,8 +3327,8 @@ TIMER_STOP("################################## after all ####################### CUpdateCheckPackages::getInstance()->startThread(); #endif - for (std::list::iterator it = g_settings.xmltv_xml.begin(); it != g_settings.xmltv_xml.end(); it++) - g_Sectionsd->readSIfromXMLTV((*it).c_str()); + xmltv_xml_readepg(); + xmltv_xml_m3u_readepg(); RealRun(); ExitRun(g_info.hw_caps->can_shutdown); @@ -4727,6 +4729,11 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) printf("CNeutrinoApp::handleMsg: Reading xmltv epg from %s ...\n", (*it).c_str()); g_Sectionsd->readSIfromXMLTV((*it).c_str()); } + for (std::list::iterator it_tmp = g_settings.xmltv_xml_m3u.begin(); it_tmp != g_settings.xmltv_xml_m3u.end(); it_tmp++) + { + printf("CNeutrinoApp::handleMsg: Reading xmltv epg from %s ...\n", (*it_tmp).c_str()); + g_Sectionsd->readSIfromXMLTV((*it_tmp).c_str()); + } return messages_return::handled; } if ((msg >= CRCInput::RC_WithData) && (msg < CRCInput::RC_WithData + 0x10000000)) { diff --git a/src/neutrino.h b/src/neutrino.h index 1607a5c27..9a6a49834 100644 --- a/src/neutrino.h +++ b/src/neutrino.h @@ -243,6 +243,13 @@ public: void channelRezap(); void g_settings_video_Mode(int value) { g_settings.video_Mode = value; } + + void g_settings_xmltv_xml_m3u_clear() { g_settings.xmltv_xml_m3u.clear(); } + void g_settings_xmltv_xml_m3u_pushback(std::string _epg_url) {g_settings.xmltv_xml_m3u.push_back(_epg_url); } + void xmltv_xml_readepg() { for (std::list::iterator it = g_settings.xmltv_xml.begin(); it != g_settings.xmltv_xml.end(); it++) + g_Sectionsd->readSIfromXMLTV((*it).c_str()); } + void xmltv_xml_m3u_readepg() { for (std::list::iterator it_tmp = g_settings.xmltv_xml_m3u.begin(); it_tmp != g_settings.xmltv_xml_m3u.end(); it_tmp++) + g_Sectionsd->readSIfromXMLTV((*it_tmp).c_str()); } }; #endif diff --git a/src/nhttpd/tuxboxapi/controlapi.cpp b/src/nhttpd/tuxboxapi/controlapi.cpp index fd35b5348..2dadcc1b8 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -3252,6 +3252,14 @@ void CControlAPI::xmltvepgCGI(CyhookHandler *hh) hh->ParamList["format"] = "xml"; hh->outStart(); + int mode; + if (hh->ParamList["mode"] == "tv") + mode = CZapitClient::MODE_TV; + else if (hh->ParamList["mode"] == "radio") + mode = CZapitClient::MODE_RADIO; + else + mode = CZapitClient::MODE_ALL; + bool xml_cdata = false; t_channel_id channel_id; std::string result = ""; @@ -3268,8 +3276,10 @@ void CControlAPI::xmltvepgCGI(CyhookHandler *hh) for (int m = CZapitClient::MODE_TV; m < CZapitClient::MODE_ALL; m++) { - if (m == CZapitClient::MODE_RADIO) + if (mode == CZapitClient::MODE_RADIO || m == CZapitClient::MODE_RADIO) g_bouquetManager->Bouquets[i]->getRadioChannels(chanlist); + else + g_bouquetManager->Bouquets[i]->getTvChannels(chanlist); if(!chanlist.empty() && !g_bouquetManager->Bouquets[i]->bHidden && g_bouquetManager->Bouquets[i]->bUser) { @@ -3326,8 +3336,7 @@ void CControlAPI::xmltvepgCGI(CyhookHandler *hh) void CControlAPI::xmltvm3uCGI(CyhookHandler *hh) { - hh->outStart(); - std::string result("#EXTM3U\n"); + //hh->outStart(); int mode; if (hh->ParamList["mode"] == "tv") @@ -3347,6 +3356,16 @@ void CControlAPI::xmltvm3uCGI(CyhookHandler *hh) char hostname[HOST_NAME_MAX]; gethostname(hostname, HOST_NAME_MAX); + std::string result("#EXTM3U"); + result += " tvg-url=\"" + host + "/control/xmltv.xml"; + + if (mode == CZapitClient::MODE_TV) + result += "?mode=tv"; + else if (mode == CZapitClient::MODE_RADIO) + result += "?mode=radio"; + + result += "\"\n"; + // build url std::string url = host; if (url.rfind(":") != 4) diff --git a/src/system/settings.h b/src/system/settings.h index 76ffd4828..d88270d68 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -752,6 +752,7 @@ struct SNeutrinoSettings // xmltv std::list xmltv_xml; // see http://wiki.xmltv.org/ + std::list xmltv_xml_m3u; // contains temp xml from m3u int livestreamResolution; std::string livestreamScriptPath; diff --git a/src/zapit/src/bouquets.cpp b/src/zapit/src/bouquets.cpp index f0bb364a6..4d18e12cf 100644 --- a/src/zapit/src/bouquets.cpp +++ b/src/zapit/src/bouquets.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -48,6 +49,7 @@ #include #define M3U_START_MARKER "#EXTM3U" +#define M3U_START_EPG_MARKER "tvg-url=" #define M3U_INFO_MARKER "#EXTINF" #define TVG_INFO_ID_MARKER "tvg-id=" #define TVG_INFO_NAME_MARKER "tvg-name=" @@ -531,6 +533,7 @@ void CBouquetManager::loadBouquets(bool ignoreBouquetFile) sortBouquets(); } + CNeutrinoApp::getInstance()->g_settings_xmltv_xml_m3u_clear(); loadWebtv(); loadWebradio(); loadLogos(); @@ -986,6 +989,7 @@ void CBouquetManager::loadWebchannels(int mode) { std::ifstream infile; char cLine[1024]; + std::string epg_url = ""; std::string desc = ""; std::string title = ""; std::string prefix = ""; @@ -1009,8 +1013,22 @@ void CBouquetManager::loadWebchannels(int mode) continue; if (strLine.find(M3U_START_MARKER) != std::string::npos) - continue; - + { + epg_url = ""; + epg_url = ReadMarkerValue(strLine, M3U_START_EPG_MARKER); + printf("tvg-url: %s\n", epg_url.c_str()); + if (!epg_url.empty()) + { + if (epg_url.find_first_of(',') != std::string::npos) + { + std::vector epg_list = ::split(epg_url, ','); + for (std::vector::iterator it_epg = epg_list.begin(); it_epg != epg_list.end(); it_epg++) + CNeutrinoApp::getInstance()->g_settings_xmltv_xml_m3u_pushback((*it_epg)); + } + else + CNeutrinoApp::getInstance()->g_settings_xmltv_xml_m3u_pushback(epg_url); + } + } if (strLine.find(M3U_INFO_MARKER) != std::string::npos) { int iColon = (int)strLine.find_first_of(':');