summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzmike <michael.blumenkrantz@gmail.com>2014-02-05 23:52:12 -0500
committerzmike <michael.blumenkrantz@gmail.com>2014-02-05 23:52:12 -0500
commit272f25b8b8b08eb8518be45917ab8c7af8048a71 (patch)
treefcc0a371545a116340e4bc7971f5ed312634018d
parentfb23cb084407cecc53fda923c1666aa270be560c (diff)
check for instrumentals
-rw-r--r--excetra.c26
-rw-r--r--excetra.h7
2 files changed, 24 insertions, 9 deletions
diff --git a/excetra.c b/excetra.c
index a98342f..a5ab5ec 100644
--- a/excetra.c
+++ b/excetra.c
@@ -22,6 +22,7 @@ struct Excetra_Req
22 Eina_Strbuf *buf; 22 Eina_Strbuf *buf;
23 Excetra_Result_Cb cb; 23 Excetra_Result_Cb cb;
24 void *data; 24 void *data;
25 Eina_Bool instrumental : 1;
25}; 26};
26 27
27static Ecore_Event_Handler *handler_data; 28static Ecore_Event_Handler *handler_data;
@@ -111,6 +112,13 @@ lyricwiki_parse_stub(Excetra_Req *req)
111 INF("STUB:"); 112 INF("STUB:");
112 Lyricwiki_Lyric_print(NULL, 0, lwl); 113 Lyricwiki_Lyric_print(NULL, 0, lwl);
113 ecore_con_url_free(req->url); 114 ecore_con_url_free(req->url);
115 req->instrumental = lwl->lyrics && (!strcmp(lwl->lyrics, "Instrumental"));
116 if (req->instrumental)
117 {
118 req->cb(req->data, req, NULL);
119 excetra_req_free(req);
120 return;
121 }
114 req->url = ecore_con_url_new(lwl->url); 122 req->url = ecore_con_url_new(lwl->url);
115 ecore_con_url_data_set(req->url, req); 123 ecore_con_url_data_set(req->url, req);
116 ecore_con_url_get(req->url); 124 ecore_con_url_get(req->url);
@@ -170,20 +178,20 @@ lyricwiki_complete(void *d EINA_UNUSED, int type EINA_UNUSED, Ecore_Con_Event_Ur
170} 178}
171 179
172void 180void
173lyricwiki_request_cancel(Excetra_Req *req) 181excetra_req_cancel(Excetra_Req *req)
174{ 182{
175 if (req) excetra_req_free(req); 183 if (req) excetra_req_free(req);
176} 184}
177 185
178void * 186void *
179lyricwiki_request_data_get(const Excetra_Req *req) 187excetra_req_data_get(const Excetra_Req *req)
180{ 188{
181 EINA_SAFETY_ON_NULL_RETURN_VAL(req, NULL); 189 EINA_SAFETY_ON_NULL_RETURN_VAL(req, NULL);
182 return req->data; 190 return req->data;
183} 191}
184 192
185Excetra_Req * 193Excetra_Req *
186lyricwiki_request(const char *artist, const char *song, Excetra_Result_Cb cb, const void *data) 194excetra_req_new(const char *artist, const char *song, Excetra_Result_Cb cb, const void *data)
187{ 195{
188 Ecore_Con_Url *url; 196 Ecore_Con_Url *url;
189 char buf[4096]; 197 char buf[4096];
@@ -216,6 +224,12 @@ lyricwiki_request(const char *artist, const char *song, Excetra_Result_Cb cb, co
216 return req; 224 return req;
217} 225}
218 226
227Eina_Bool
228excetra_req_is_instrumental(const Excetra_Req *req)
229{
230 return req->instrumental;
231}
232
219int 233int
220excetra_init(void) 234excetra_init(void)
221{ 235{
@@ -258,9 +272,9 @@ excetra_shutdown(void)
258 272
259#ifndef EXCETRA_LIB 273#ifndef EXCETRA_LIB
260static void 274static void
261result_cb(void *data EINA_UNUSED, Excetra_Req *req EINA_UNUSED, const char *lyric) 275result_cb(void *data EINA_UNUSED, Excetra_Req *req, const char *lyric)
262{ 276{
263 INF("\n%s", lyric); 277 INF("\n%s", excetra_req_is_instrumental(req) ? "Instrumental" : lyric);
264 ecore_main_loop_quit(); 278 ecore_main_loop_quit();
265} 279}
266 280
@@ -273,7 +287,7 @@ main(int argc, char *argv[])
273 exit(1); 287 exit(1);
274 } 288 }
275 if (!excetra_init()) exit(1); 289 if (!excetra_init()) exit(1);
276 lyricwiki_request(argv[1], argv[2], result_cb, NULL); 290 excetra_req_new(argv[1], argv[2], result_cb, NULL);
277 ecore_main_loop_begin(); 291 ecore_main_loop_begin();
278 return 0; 292 return 0;
279} 293}
diff --git a/excetra.h b/excetra.h
index 1f7554f..a3ac362 100644
--- a/excetra.h
+++ b/excetra.h
@@ -6,6 +6,7 @@ typedef void (*Excetra_Result_Cb)(void *user_data, Excetra_Req *req, const char
6 6
7EAPI int excetra_init(void); 7EAPI int excetra_init(void);
8EAPI void excetra_shutdown(void); 8EAPI void excetra_shutdown(void);
9EAPI Excetra_Req *lyricwiki_request(const char *artist, const char *song, Excetra_Result_Cb cb, const void *data); 9EAPI Excetra_Req *excetra_req_new(const char *artist, const char *song, Excetra_Result_Cb cb, const void *data);
10EAPI void lyricwiki_request_cancel(Excetra_Req *req); 10EAPI void excetra_req_cancel(Excetra_Req *req);
11EAPI void *lyricwiki_request_data_get(const Excetra_Req *req); 11EAPI void *excetra_req_data_get(const Excetra_Req *req);
12EAPI Eina_Bool excetra_req_is_instrumental(const Excetra_Req *req);