1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#include "medianamespace.h"
#include <string>
#include "xmlutilities.h"
#define MEDIA_RSS_URI "http://search.yahoo.com/mrss/"
namespace rsspp {
bool is_media_node(xmlNode* node)
{
return has_namespace(node, MEDIA_RSS_URI);
}
void parse_media_node(xmlNode* node, Item& it, Enclosure* enclosure)
{
if (node_is(node, "group", MEDIA_RSS_URI)) {
for (xmlNode* mnode = node->children; mnode != nullptr; mnode = mnode->next) {
parse_media_node(mnode, it);
}
} else if (node_is(node, "content", MEDIA_RSS_URI)) {
it.enclosures.push_back(
Enclosure {
get_prop(node, "url"),
get_prop(node, "type"),
"",
"",
}
);
for (xmlNode* mnode = node->children; mnode != nullptr; mnode = mnode->next) {
parse_media_node(mnode, it, &it.enclosures.back());
}
} else if (node_is(node, "description", MEDIA_RSS_URI)) {
const std::string description = get_content(node);
const std::string type = get_prop(node, "type");
const std::string mime_type = (type == "html" ? "text/html" : "text/plain");
if (it.description.empty()) {
it.description = description;
it.description_mime_type = mime_type;
}
if (enclosure) {
enclosure->description = description;
enclosure->description_mime_type = mime_type;
}
} else if (node_is(node, "title", MEDIA_RSS_URI)) {
const std::string title = get_content(node);
const std::string type = get_prop(node, "type");
const std::string mime_type = (type == "html" ? "text/html" : "text/plain");
if (it.title.empty()) {
it.title = title;
it.title_type = type;
}
if (enclosure) {
if (enclosure->description.empty()) {
enclosure->description = title;
enclosure->description_mime_type = mime_type;
}
}
} else if (node_is(node, "player", MEDIA_RSS_URI)) {
if (it.link.empty()) {
it.link = get_prop(node, "url");
}
}
}
} // namespace rsspp
|