Read metadata keys from XBEL
This commit is contained in:
parent
967b080680
commit
491fadc119
1 changed files with 43 additions and 2 deletions
|
@ -109,6 +109,47 @@ katze_array_from_xmlNodePtr (xmlNodePtr cur)
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
katze_xbel_parse_info (KatzeItem* item,
|
||||||
|
xmlNodePtr cur)
|
||||||
|
{
|
||||||
|
cur = cur->xmlChildrenNode;
|
||||||
|
while (cur)
|
||||||
|
{
|
||||||
|
if (!xmlStrcmp (cur->name, (const xmlChar*)"metadata"))
|
||||||
|
{
|
||||||
|
xmlChar* owner = xmlGetProp (cur, (xmlChar*)"owner");
|
||||||
|
g_strstrip ((gchar*)owner);
|
||||||
|
/* FIXME: Save metadata from unknown owners */
|
||||||
|
if (!g_strcmp0 ((gchar*)owner, "http://www.twotoasts.de"))
|
||||||
|
{
|
||||||
|
xmlAttrPtr properties = cur->properties;
|
||||||
|
while (properties)
|
||||||
|
{
|
||||||
|
xmlChar* value = xmlGetProp (cur, properties->name);
|
||||||
|
if (properties->ns && properties->ns->prefix)
|
||||||
|
{
|
||||||
|
gchar* ns_value = g_strdup_printf ("%s:%s",
|
||||||
|
properties->ns->prefix, properties->name);
|
||||||
|
katze_item_set_meta_string (item,
|
||||||
|
(gchar*)ns_value, value);
|
||||||
|
g_free (ns_value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
katze_item_set_meta_string (item,
|
||||||
|
(gchar*)properties->name, (gchar*)value);
|
||||||
|
xmlFree (value);
|
||||||
|
properties = properties->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xmlFree (owner);
|
||||||
|
}
|
||||||
|
else if (g_strcmp0 ((gchar*)cur->name, "text"))
|
||||||
|
g_critical ("Unexpected element <%s> in <metadata>.", cur->name);
|
||||||
|
cur = cur->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Loads the contents from an xmlNodePtr into an array. */
|
/* Loads the contents from an xmlNodePtr into an array. */
|
||||||
static gboolean
|
static gboolean
|
||||||
katze_array_from_xmlDocPtr (KatzeArray* array,
|
katze_array_from_xmlDocPtr (KatzeArray* array,
|
||||||
|
@ -153,8 +194,8 @@ katze_array_from_xmlDocPtr (KatzeArray* array,
|
||||||
item = katze_item_from_xmlNodePtr (cur);
|
item = katze_item_from_xmlNodePtr (cur);
|
||||||
else if (!xmlStrcmp (cur->name, (const xmlChar*)"separator"))
|
else if (!xmlStrcmp (cur->name, (const xmlChar*)"separator"))
|
||||||
item = katze_item_new ();
|
item = katze_item_new ();
|
||||||
/*else if (!xmlStrcmp (cur->name, (const xmlChar*)"info"))
|
else if (!xmlStrcmp (cur->name, (const xmlChar*)"info"))
|
||||||
item = katze_xbel_parse_info (xbel, cur);*/
|
katze_xbel_parse_info (KATZE_ITEM (array), cur);
|
||||||
if (item)
|
if (item)
|
||||||
katze_array_add_item (array, item);
|
katze_array_add_item (array, item);
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
|
|
Loading…
Reference in a new issue