Skip to content

Commit

Permalink
add support for embedded epg-url in m3u
Browse files Browse the repository at this point in the history
  • Loading branch information
TangoCash authored and vanhofen committed Sep 9, 2021
1 parent ee8e678 commit 8a3dc3a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/gui/webchannels_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ int CWebChannelsSetup::Show()
}
webchannels_auto();
g_Zapit->reinitChannels();
CNeutrinoApp::getInstance()->xmltv_xml_m3u_readepg();
changed = false;
hint.hide();
}
Expand Down
11 changes: 9 additions & 2 deletions src/neutrino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -3325,8 +3327,8 @@ TIMER_STOP("################################## after all #######################
CUpdateCheckPackages::getInstance()->startThread();
#endif

for (std::list<std::string>::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);
Expand Down Expand Up @@ -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<std::string>::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)) {
Expand Down
7 changes: 7 additions & 0 deletions src/neutrino.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ class CNeutrinoApp : public CMenuTarget, CChangeObserver, public sigc::trackable
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<std::string>::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<std::string>::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

Expand Down
25 changes: 22 additions & 3 deletions src/nhttpd/tuxboxapi/controlapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand All @@ -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)
{
Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/system/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ struct SNeutrinoSettings

// xmltv
std::list<std::string> xmltv_xml; // see http://wiki.xmltv.org/
std::list<std::string> xmltv_xml_m3u; // contains temp xml from m3u

int livestreamResolution;
std::string livestreamScriptPath;
Expand Down
22 changes: 20 additions & 2 deletions src/zapit/src/bouquets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <iostream>

#include <global.h>
#include <neutrino.h>
#include <driver/pictureviewer/pictureviewer.h>
#include <system/helpers.h>
#include <system/set_threadname.h>
Expand All @@ -48,6 +49,7 @@
#include <xmlinterface.h>

#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="
Expand Down Expand Up @@ -531,6 +533,7 @@ void CBouquetManager::loadBouquets(bool ignoreBouquetFile)
sortBouquets();
}

CNeutrinoApp::getInstance()->g_settings_xmltv_xml_m3u_clear();
loadWebtv();
loadWebradio();
loadLogos();
Expand Down Expand Up @@ -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 = "";
Expand All @@ -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<std::string> epg_list = ::split(epg_url, ',');
for (std::vector<std::string>::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(':');
Expand Down

0 comments on commit 8a3dc3a

Please sign in to comment.