add option to map xml epg to normal channels

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
TangoCash
2018-10-28 13:06:12 +01:00
committed by Thilo Graf
parent aff3629fdb
commit 63592d0489
4 changed files with 38 additions and 8 deletions

View File

@@ -16,4 +16,7 @@
<filter channel_id="b12003ee00011078" new_epg_id="ac423070013e2144"/> --rainews24
<filter channel_id="b4d6070800c80e26" new_epg_id="b45803fb0001283d"/> --Das Erste
<filter channel_id="aa0004210001ef10" >RTL.de</filter> --RTL HD
<filter channel_id="b6ba3db8013e4224" >RedlightHD.ero</filter> --Redlight HD
</zapit>

View File

@@ -106,8 +106,10 @@ class CBouquetManager
void writeBouquet(FILE * bouq_fd, uint32_t i, bool bUser);
//remap epg_id
std::map<t_channel_id, t_channel_id> EpgIDMapping;
std::map<t_channel_id, std::string> EpgXMLMapping;
void readEPGMapping();
t_channel_id reMapEpgID(t_channel_id channelid);
std::string reMapEpgXML(t_channel_id channelid);
//logo downloads
static void* LogoThread(void* _logolist);
pthread_t thrLogo;

View File

@@ -219,6 +219,7 @@ class CZapitChannel
t_transport_stream_id getTransportStreamId(void) const { return transport_stream_id; }
t_original_network_id getOriginalNetworkId(void) const { return original_network_id; }
std::string getScriptName(void) const { return script; }
inline void setScriptName(const std::string &pscript) { script = pscript; }
unsigned char getServiceType(bool real=false);
bool isUHD();
bool isHD();

View File

@@ -478,7 +478,12 @@ void CBouquetManager::parseBouquetsXml(const char *fname, bool bUser)
t_channel_id new_epgid = reMapEpgID(chan->getChannelID());
if(new_epgid)
chan->setEPGid(new_epgid);
std::string new_epgxml = reMapEpgXML(chan->getChannelID());
if(!new_epgxml.empty()) {
char buf[100];
snprintf(buf, sizeof(buf), "%llx", chan->getChannelID() & 0xFFFFFFFFFFFFULL);
chan->setScriptName("#" + new_epgxml + "=" + buf);
}
newBouquet->addService(chan);
} else if (bUser) {
if (url) {
@@ -516,6 +521,9 @@ void CBouquetManager::parseBouquetsXml(const char *fname, bool bUser)
if(!bUser && !EpgIDMapping.empty()){
EpgIDMapping.clear();
}
if(!bUser && !EpgXMLMapping.empty()){
EpgXMLMapping.clear();
}
}
xmlFreeDoc(parser);
}
@@ -1250,11 +1258,24 @@ t_channel_id CBouquetManager::reMapEpgID(t_channel_id channelid)
return 0;
}
std::string CBouquetManager::reMapEpgXML(t_channel_id channelid)
{
if(!EpgXMLMapping.empty()){
std::map<t_channel_id, std::string>::iterator it = EpgXMLMapping.find(channelid);
if ( it != EpgXMLMapping.end() )
return it->second;
}
return "";
}
void CBouquetManager::readEPGMapping()
{
if(!EpgIDMapping.empty())
EpgIDMapping.clear();
if(!EpgXMLMapping.empty())
EpgXMLMapping.clear();
const std::string epg_map_dir = CONFIGDIR "/zapit/epgmap.xml";
xmlDocPtr epgmap_parser = parseXmlFile(epg_map_dir.c_str());
@@ -1267,18 +1288,21 @@ void CBouquetManager::readEPGMapping()
while (epgmap)
{
const char *cannelid = xmlGetAttribute(epgmap, "channel_id");
const char *channelid = xmlGetAttribute(epgmap, "channel_id");
const char *epgid = xmlGetAttribute(epgmap, "new_epg_id");
const char *xmlepg = xmlGetData(epgmap);
t_channel_id epg_id = 0;
t_channel_id chid = 0;
t_channel_id channel_id = 0;
if (epgid)
epg_id = strtoull(epgid, NULL, 16);
if (cannelid)
chid = strtoull(cannelid, NULL, 16);
if(chid && epg_id){
EpgIDMapping[chid]=epg_id;
if (channelid)
channel_id = strtoull(channelid, NULL, 16);
if(channel_id && epg_id){
EpgIDMapping[channel_id]=epg_id;
}
if(channel_id && xmlepg){
EpgXMLMapping[channel_id]=xmlepg;
}
epgmap = xmlNextNode(epgmap);
}
}