summaryrefslogtreecommitdiff
path: root/parse.cpp
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2011-01-03 20:22:04 +0100
committerJochen Dolze <vdr@dolze.de>2011-01-03 20:22:04 +0100
commit6d94396a7088c0b33aea1838e7cc91053eef15c6 (patch)
tree872bf00cac6361b19b08354b7a1035761563550e /parse.cpp
parent83cf2436ce3f2ed9ce4e0a0847b10d5144907061 (diff)
downloadvdr-plugin-xmltv2vdr-6d94396a7088c0b33aea1838e7cc91053eef15c6.tar.gz
vdr-plugin-xmltv2vdr-6d94396a7088c0b33aea1838e7cc91053eef15c6.tar.bz2
Fixed bugs in xmltv format processing
Added more options (still not working)
Diffstat (limited to 'parse.cpp')
-rw-r--r--parse.cpp89
1 files changed, 57 insertions, 32 deletions
diff --git a/parse.cpp b/parse.cpp
index 747567d..0124165 100644
--- a/parse.cpp
+++ b/parse.cpp
@@ -8,7 +8,7 @@
#include <string.h>
#include <stdlib.h>
#include <limits.h>
-
+#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
@@ -425,29 +425,47 @@ bool cParse::FetchEvent(xmlNodePtr enode)
xmlFree(content);
}
}
- else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "country")))
+ else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "credits")))
+ {
+ }
+ else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "date")))
{
xmlChar *content=xmlNodeListGetString(node->doc,node->xmlChildrenNode,1);
if (content)
{
- xevent.SetCountry(conv->Convert((const char *) content));
+ xevent.SetYear(atoi((const char *) content));
xmlFree(content);
}
}
- else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "date")))
+ else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "category")))
{
+ // what to do with attribute lang?
xmlChar *content=xmlNodeListGetString(node->doc,node->xmlChildrenNode,1);
if (content)
{
- xevent.SetYear(atoi((const char *) content));
+ if (isdigit(content[0]))
+ {
+ xevent.SetEventID(atoi((const char *) content));
+ }
+ else
+ {
+ }
xmlFree(content);
}
}
- else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "category")))
+ else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "country")))
{
- // attribute lang
+ xmlChar *content=xmlNodeListGetString(node->doc,node->xmlChildrenNode,1);
+ if (content)
+ {
+ xevent.SetCountry(conv->Convert((const char *) content));
+ xmlFree(content);
+ }
}
- else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "credits")))
+ else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "video")))
+ {
+ }
+ else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "audio")))
{
}
else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "rating")))
@@ -455,15 +473,26 @@ bool cParse::FetchEvent(xmlNodePtr enode)
xmlChar *system=xmlGetProp(node,(const xmlChar *) "system");
if (system)
{
- xmlChar *content=xmlNodeListGetString(node->doc,node->xmlChildrenNode,1);
- if (content)
+ xmlNodePtr vnode=node->xmlChildrenNode;
+ while (vnode)
{
- const char *crating=strdup(conv->Convert((const char *) content));
- const char *csystem=strdup(conv->Convert((const char *) system));
- xevent.SetRating(csystem,crating);
- if (crating) free((void *) crating);
- if (csystem) free((void *) csystem);
- xmlFree(content);
+ if (vnode->type==XML_ELEMENT_NODE)
+ {
+ if ((!xmlStrcasecmp(vnode->name, (const xmlChar *) "value")))
+ {
+ xmlChar *content=xmlNodeListGetString(vnode->doc,vnode->xmlChildrenNode,1);
+ if (content)
+ {
+ const char *crating=strdup(conv->Convert((const char *) content));
+ const char *csystem=strdup(conv->Convert((const char *) system));
+ xevent.SetRating(csystem,crating);
+ if (crating) free((void *) crating);
+ if (csystem) free((void *) csystem);
+ xmlFree(content);
+ }
+ }
+ }
+ vnode=vnode->next;
}
xmlFree(system);
}
@@ -482,12 +511,6 @@ bool cParse::FetchEvent(xmlNodePtr enode)
xmlFree(type);
}
}
- else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "video")))
- {
- }
- else if ((!xmlStrcasecmp(node->name, (const xmlChar *) "audio")))
- {
- }
else
{
esyslog("xmltv2vdr: '%s' unknown element %s, please report!",name,node->name);
@@ -542,11 +565,11 @@ bool cParse::Process(char *buffer, int bufsize)
{
if ((!xmlStrcasecmp(node->name, (const xmlChar *) "programme")))
{
- xmlChar *channelid=xmlGetProp(node,(const xmlChar *) "channelid");
+ xmlChar *channelid=xmlGetProp(node,(const xmlChar *) "channel");
cEPGMapping *map=NULL;
if (channelid && (map=EPGMapping((const char *) channelid)))
{
- time_t end=begin+86000*map->Days();
+ time_t end=begin+(86000*map->Days())+3600; // 1 hour overlap
xmlChar *start,*stop;
time_t starttime=(time_t) 0;
time_t stoptime=(time_t) 0;
@@ -570,14 +593,6 @@ bool cParse::Process(char *buffer, int bufsize)
{
xevent.Clear();
- xmlChar *eventid;
- eventid=xmlGetProp(node,(const xmlChar *) "eventid");
- if (eventid)
- {
- xevent.SetEventID(atoi((const char *) eventid));
- xmlFree(eventid);
- }
-
xmlChar *vpsstart=xmlGetProp(node,(const xmlChar *) "vps-start");
if (vpsstart)
{
@@ -627,6 +642,16 @@ bool cParse::Process(char *buffer, int bufsize)
return true;
}
+void cParse::InitLibXML()
+{
+ xmlInitParser();
+}
+
+void cParse::CleanupLibXML()
+{
+ xmlCleanupParser();
+}
+
cParse::cParse(const char *Name, cEPGMappings *Maps, cTEXTMappings *Texts)
{
#if VDRVERSNUM < 10701 || defined(__FreeBSD__)