summaryrefslogtreecommitdiff
path: root/scraper/thetvdbscraper/tvdbactor.c
diff options
context:
space:
mode:
authorhorchi <vdr@jwendel.de>2017-03-05 16:39:28 +0100
committerhorchi <vdr@jwendel.de>2017-03-05 16:39:28 +0100
commite2a48d8701f91b8e24fbe9e99e91eb72a87bb749 (patch)
tree726f70554b4ca985a09ef6e30a7fdc8df089993c /scraper/thetvdbscraper/tvdbactor.c
downloadvdr-epg-daemon-e2a48d8701f91b8e24fbe9e99e91eb72a87bb749.tar.gz
vdr-epg-daemon-e2a48d8701f91b8e24fbe9e99e91eb72a87bb749.tar.bz2
git init1.1.103
Diffstat (limited to 'scraper/thetvdbscraper/tvdbactor.c')
-rw-r--r--scraper/thetvdbscraper/tvdbactor.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/scraper/thetvdbscraper/tvdbactor.c b/scraper/thetvdbscraper/tvdbactor.c
new file mode 100644
index 0000000..f64846a
--- /dev/null
+++ b/scraper/thetvdbscraper/tvdbactor.c
@@ -0,0 +1,66 @@
+#include <iostream>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include "tvdbactor.h"
+
+using namespace std;
+
+cTVDBActors::cTVDBActors(string language, cTVDBMirrors *mirrors) {
+ this->language = language;
+ this->mirrors = mirrors;
+}
+
+cTVDBActors::~cTVDBActors() {
+}
+
+void cTVDBActors::ParseXML(string xml, vector<cTVDBActor*> *actors) {
+ xmlDoc *doc = xmlReadMemory(xml.c_str(), xml.size(), "noname.xml", NULL, 0);
+ if (doc == NULL)
+ return;
+ //Root Element has to be <Actors>
+ xmlNode *node = NULL;
+ node = xmlDocGetRootElement(doc);
+ if (!(node && !xmlStrcmp(node->name, (const xmlChar *)"Actors"))) {
+ xmlFreeDoc(doc);
+ return;
+ }
+ //Looping through actors
+ node = node->children;
+ xmlNode *cur_node = NULL;
+ for (cur_node = node; cur_node; cur_node = cur_node->next) {
+ if ((cur_node->type == XML_ELEMENT_NODE) && !xmlStrcmp(cur_node->name, (const xmlChar *)"Actor")) {
+ cTVDBActor *actor = ReadEntry(doc, cur_node->children);
+ actors->push_back(actor);
+ }
+ }
+ xmlFreeDoc(doc);
+}
+
+cTVDBActor *cTVDBActors::ReadEntry(xmlDoc *doc, xmlNode *node) {
+ xmlNode *cur_node = NULL;
+ xmlChar *node_content;
+ cTVDBActor *actor = new cTVDBActor();
+ for (cur_node = node; cur_node; cur_node = cur_node->next) {
+ if (cur_node->type == XML_ELEMENT_NODE) {
+ node_content = xmlNodeListGetString(doc, cur_node->xmlChildrenNode, 1);
+ if (!node_content)
+ continue;
+ if (!xmlStrcmp(cur_node->name, (const xmlChar *)"Image")) {
+ actor->thumbUrl = mirrors->GetMirrorBanner() + (const char *)node_content;
+ } else if (!xmlStrcmp(cur_node->name, (const xmlChar *)"Name")) {
+ actor->name = (const char *)node_content;
+ } else if (!xmlStrcmp(cur_node->name, (const xmlChar *)"Role")) {
+ actor->role = (const char *)node_content;
+ } else if (!xmlStrcmp(cur_node->name, (const xmlChar *)"id")) {
+ actor->id = atoi((const char *)node_content);
+ } else if (!xmlStrcmp(cur_node->name, (const xmlChar *)"SortOrder")) {
+ actor->sortOrder = atoi((const char *)node_content);
+ }
+ xmlFree(node_content);
+ }
+ }
+ return actor;
+} \ No newline at end of file