Modify version string to post-release version 11.8.17
[gmpc-lyrics.git] / src / _lyrictracker.c
blob08edcb7ce048dcaf49fa15dd2bb474109ddddccf
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"
23 gchar *
24 __lyrictracker_get_id (xmlDocPtr results_doc, gchar *artist, gchar *songtitle, int exact)
26 gchar *hid = NULL;
27 xmlNodePtr results, node;
29 results = xmlDocGetRootElement(results_doc);
30 if (!results)
31 return NULL;
33 /* If no results returned, don't even search in them */
34 if (strcmp((gchar *)xmlGetProp(results, (xmlChar *)"count"), "0") == 0)
35 return NULL;
37 node = get_node_by_name (results->xmlChildrenNode, (xmlChar *)"result");
38 while (node)
40 // TODO: figure out how to match exact when lyrictracker comes back up again
41 if (/*(strcasecmp((gchar *)xmlGetProp(node, (xmlChar *)"artist"),
42 artist) == 0) &&*/
43 (strcasecmp((gchar *)xmlGetProp(node, (xmlChar *)"title"),
44 songtitle) == 0))
46 hid = (gchar *)xmlGetProp(node, (xmlChar *)"id");
47 if (hid)
48 return hid;
51 node = get_node_by_name (node->next, (xmlChar *)"result");
54 return NULL;
57 gchar *
58 __lyrictracker_get_lyrics (const gchar *srcdata, gssize srcsize)
60 gsize converted;
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
70 gchar *
71 __lyrictracker_get_artist (xmlDocPtr results_doc, const gchar *srcdata, gssize srcsize,
72 gchar *hid)
74 gchar *artist = NULL;
75 xmlNodePtr results, node;
77 results = xmlDocGetRootElement(results_doc);
78 if (!results)
79 return NULL;
81 /* If no results returned, don't even search in them */
82 /* if (strcmp((gchar *)xmlGetProp(results, (xmlChar *)"count"), "0") == 0)
83 return NULL;
85 node = get_node_by_name (results->xmlChildrenNode, (xmlChar *)"result");
86 while (node)
88 if (strcmp((gchar *)xmlGetProp(node, (xmlChar *)"id"), hid) == 0)
90 artist = (gchar *)xmlGetProp(node, (xmlChar *)"artist");
91 if (artist)
92 return artist;
95 node = get_node_by_name (node->next, (xmlChar *)"result");
98 return NULL;
101 gchar *
102 __lyrictracker_get_songtitle (xmlDocPtr results_doc, const gchar *srcdata, gssize srcsize,
103 gchar *hid)
105 gchar *songtitle = NULL;
106 xmlNodePtr results, node;
108 results = xmlDocGetRootElement(results_doc);
109 if (!results)
110 return NULL;
112 /* If no results returned, don't even search in them */
113 /* if (strcmp((gchar *)xmlGetProp(results, (xmlChar *)"count"), "0") == 0)
114 return NULL;
116 node = get_node_by_name (results->xmlChildrenNode, (xmlChar *)"result");
117 while (node)
119 if (strcmp((gchar *)xmlGetProp(node, (xmlChar *)"id"), hid) == 0)
121 songtitle = (gchar *)xmlGetProp(node, (xmlChar *)"title");
122 if (songtitle)
123 return songtitle;
126 node = get_node_by_name (node->next, (xmlChar *)"result");
129 return NULL;