1 /* gmpc-lyrics (GMPC plugin)
2 * Copyright (C) 2006-2009 Qball Cow <qball@sarine.nl>
3 * Copyright (C) 2006 Maxime Petazzoni <maxime.petazzoni@bulix.org>
4 * Project homepage: http://gmpc.wikia.com/
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "gmpc-lyrics.h"
24 __lyrictracker_get_id (xmlDocPtr results_doc
, gchar
*artist
, gchar
*songtitle
, int exact
)
27 xmlNodePtr results
, node
;
29 results
= xmlDocGetRootElement(results_doc
);
33 /* If no results returned, don't even search in them */
34 if (strcmp((gchar
*)xmlGetProp(results
, (xmlChar
*)"count"), "0") == 0)
37 node
= get_node_by_name (results
->xmlChildrenNode
, (xmlChar
*)"result");
40 // TODO: figure out how to match exact when lyrictracker comes back up again
41 if (/*(strcasecmp((gchar *)xmlGetProp(node, (xmlChar *)"artist"),
43 (strcasecmp((gchar
*)xmlGetProp(node
, (xmlChar
*)"title"),
46 hid
= (gchar
*)xmlGetProp(node
, (xmlChar
*)"id");
51 node
= get_node_by_name (node
->next
, (xmlChar
*)"result");
58 __lyrictracker_get_lyrics (const gchar
*srcdata
, gssize srcsize
)
62 return g_convert(srcdata
, srcsize
, "UTF-8", "ISO-8859-1",
63 NULL
, &converted
, NULL
);
66 /* the following functions are not used but left here in
67 * case somebody needs them later
71 __lyrictracker_get_artist (xmlDocPtr results_doc, const gchar *srcdata, gssize srcsize,
75 xmlNodePtr results, node;
77 results = xmlDocGetRootElement(results_doc);
81 /* If no results returned, don't even search in them */
82 /* if (strcmp((gchar *)xmlGetProp(results, (xmlChar *)"count"), "0") == 0)
85 node = get_node_by_name (results->xmlChildrenNode, (xmlChar *)"result");
88 if (strcmp((gchar *)xmlGetProp(node, (xmlChar *)"id"), hid) == 0)
90 artist = (gchar *)xmlGetProp(node, (xmlChar *)"artist");
95 node = get_node_by_name (node->next, (xmlChar *)"result");
102 __lyrictracker_get_songtitle (xmlDocPtr results_doc, const gchar *srcdata, gssize srcsize,
105 gchar *songtitle = NULL;
106 xmlNodePtr results, node;
108 results = xmlDocGetRootElement(results_doc);
112 /* If no results returned, don't even search in them */
113 /* if (strcmp((gchar *)xmlGetProp(results, (xmlChar *)"count"), "0") == 0)
116 node = get_node_by_name (results->xmlChildrenNode, (xmlChar *)"result");
119 if (strcmp((gchar *)xmlGetProp(node, (xmlChar *)"id"), hid) == 0)
121 songtitle = (gchar *)xmlGetProp(node, (xmlChar *)"title");
126 node = get_node_by_name (node->next, (xmlChar *)"result");