Mercurial > audlegacy-plugins
annotate src/lastfm/lastfm.c @ 1200:0ae013f630fa
mowgli transition, and some fixes
author | Cristi Magherusan <majeru@atheme-project.org> |
---|---|
date | Sun, 01 Jul 2007 18:11:44 +0300 |
parents | 8df9aab3897e |
children | d4efe4889489 |
rev | line source |
---|---|
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
1 /* Audacious lastfm transport plugin |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
2 * Copyright (c) 2007 Cristi Magherusan <majeru@gentoo.ro> |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
3 * All rights reserved. |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
4 * |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
5 * Redistribution and use in source and binary forms, with or without modification, |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
6 * are permitted provided that the following conditions are met: |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
7 * |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
8 * Redistributions of source code must retain the above copyright notice, |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
9 * this list of conditions and the following disclaimer. |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
10 * |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
11 * Redistributions in binary form must reproduce the above copyright notice, |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
12 * this list of conditions and the following disclaimer in the documentation |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
13 * and/or other materials provided with the distribution. |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
14 * |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
15 * Neither the name of the author nor the names of its contributors may be |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
16 * used to endorse or promote products derived from this software without |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
17 * specific prior written permission. |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
18 * |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
29 */ |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
30 |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
31 #include <audacious/vfs.h> |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
32 #include <audacious/plugin.h> |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
33 #include <audacious/configdb.h> |
1161 | 34 #include <libmowgli/mowgli_global_storage.h> |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
35 #include <curl/curl.h> |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
36 #include <glib.h> |
982 | 37 #include "lastfm.h" |
978
3513bc2fd738
[svn] got the metadata but couldnt make use of it yet
majeru
parents:
976
diff
changeset
|
38 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
39 #define DEBUG 1 |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
40 |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
41 size_t lastfm_store_res(void *ptr, size_t size, size_t nmemb, void *udata) |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
42 { |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
43 GString *data = (GString *) udata; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
44 g_string_append_len(data, ptr, nmemb); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
45 return size * nmemb; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
46 } |
1036 | 47 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
48 gint lastfm_get_data_from_uri(gchar *url, GString * result) |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
49 { |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
50 CURL *curl = curl_easy_init(); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
51 curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
52 curl_easy_setopt(curl, CURLOPT_USERAGENT, "mplayer"); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
53 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, lastfm_store_res); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
54 curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
55 curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
56 curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, LASTFM_CURL_TIMEOUT); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
57 curl_easy_setopt(curl, CURLOPT_URL, url); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
58 curl_easy_setopt(curl, CURLOPT_WRITEDATA, result); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
59 gint status = curl_easy_perform(curl); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
60 curl_easy_cleanup(curl); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
61 return status; |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
62 } |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
63 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
64 gchar* lastfm_get_login_uri() |
1008 | 65 { |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
66 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
67 g_print("Getting login data from config\n"); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
68 #endif |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
69 |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
70 ConfigDb *cfgfile = NULL; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
71 gchar *buf=NULL, |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
72 *username = NULL, |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
73 *password = NULL; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
74 if ((cfgfile = bmp_cfg_db_open()) != NULL) |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
75 { |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
76 bmp_cfg_db_get_string(cfgfile, "audioscrobbler","username", |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
77 &username); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
78 bmp_cfg_db_get_string(cfgfile, "audioscrobbler","password", |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
79 &password); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
80 g_free(cfgfile); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
81 } |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
82 if (username != NULL && password != NULL) |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
83 { |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
84 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
85 g_print("Creating the login URI\n"); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
86 #endif |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
87 |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
88 buf=g_strdup_printf(LASTFM_HANDSHAKE_URL, username, password); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
89 g_free(password); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
90 g_free(username); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
91 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
92 g_print("Succesfully created the login uri\n"); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
93 #endif |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
94 return buf; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
95 } |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
96 else { |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
97 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
98 g_print("Couldn't find the login data. Use the scrobbler plugin to set it up.\n"); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
99 #endif |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
100 |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
101 return NULL; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
102 } |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
103 } |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
104 |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
105 void lastfm_store(gchar *var_name,gchar* var){ |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
106 if (mowgli_global_storage_get(var_name)) |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
107 mowgli_global_storage_free(var_name); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
108 |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
109 mowgli_global_storage_put(var_name,var); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
110 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
111 g_print("Storing into '%s' the value '%s'\n",var_name,var); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
112 #endif |
1008 | 113 } |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
114 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
115 int lastfm_login(void) |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
116 { |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
117 /*gets the session ID in the URL to be played and stores them using |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
118 * mowgli_global_storage |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
119 * read http://gabistapler.de/blog/index.php?/archives/268-Play-last.fm-streams-without-the-player.html for more info |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
120 */ |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
121 |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
122 gint status, i; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
123 gchar *lastfm_session_id=NULL, |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
124 *lastfm_stream_uri=NULL, |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
125 *login_uri=NULL, |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
126 **split = NULL; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
127 GString *res = g_string_new(NULL); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
128 g_print("Logging in\n"); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
129 login_uri=lastfm_get_login_uri(); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
130 if(login_uri==NULL){ |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
131 g_free(login_uri); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
132 return LASTFM_MISSING_LOGIN_DATA; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
133 } |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
134 status = lastfm_get_data_from_uri(login_uri, res); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
135 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
136 g_print("Opened login URI: '%s'\n", login_uri); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
137 g_print("Got following data: '%s'\n", res->str); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
138 #endif |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
139 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
140 if (status == CURLE_OK) |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
141 { |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
142 split = g_strsplit(res->str, "\n", 7); |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
143 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
144 for (i = 0; split && split[i]; i++) |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
145 { |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
146 if (g_str_has_prefix(split[i], "session=")) |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
147 { |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
148 lastfm_session_id = g_strndup(split[i] + 8, 32); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
149 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
150 g_print("Got session ID:'%s'\n",lastfm_session_id); |
979
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
151 #endif |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
152 } |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
153 else if (g_str_has_prefix(split[i], "stream_url=")) |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
154 lastfm_stream_uri = g_strdup(split[i] + 11); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
155 } |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
156 } |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
157 else |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
158 { |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
159 g_strfreev(split); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
160 g_string_erase(res, 0, -1); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
161 g_free(lastfm_session_id); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
162 g_free(lastfm_stream_uri); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
163 g_free(login_uri); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
164 return LASTFM_LOGIN_ERROR; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
165 } |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
166 lastfm_store("lastfm_session_id",lastfm_session_id); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
167 lastfm_store("lastfm_stream_uri",lastfm_stream_uri); |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
168 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
169 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
170 g_print("Login finished succesfully\n"); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
171 #endif |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
172 g_strfreev(split); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
173 g_string_erase(res, 0, -1); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
174 g_free(login_uri); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
175 return LASTFM_LOGIN_OK ; |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
176 } |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
177 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
178 gint lastfm_adjust(const gchar * uri) |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
179 { |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
180 int status, i; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
181 gchar tmp[4096], **split = NULL; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
182 gboolean ret = FALSE; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
183 GString *res = g_string_new(NULL); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
184 gchar* session_id=mowgli_global_storage_get("lastfm_session_id"); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
185 |
1010
8bad1b46ef78
[svn] - make this compile again and indent properly
nenolod
parents:
1009
diff
changeset
|
186 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
187 if (!session_id) |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
188 return LASTFM_SESSION_MISSING; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
189 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
190 g_print("Session ID: '%s'\n",session_id); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
191 #endif |
1008 | 192 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
193 snprintf(tmp, sizeof(tmp), LASTFM_ADJUST_URL, session_id, uri); |
1008 | 194 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
195 status = lastfm_get_data_from_uri(tmp, res); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
196 |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
197 #if DEBUG |
1010
8bad1b46ef78
[svn] - make this compile again and indent properly
nenolod
parents:
1009
diff
changeset
|
198 g_print("Adjust received data:%s\n", res->str); |
979
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
199 #endif |
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
200 if (status == CURLE_OK) |
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
201 { |
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
202 split = g_strsplit(res->str, "\n", 3); |
975 | 203 |
979
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
204 for (i = 0; split && split[i]; i++) |
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
205 { |
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
206 if (g_str_has_prefix(split[i], "response=OK")) |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
207 ret = LASTFM_ADJUST_OK; |
979
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
208 if (g_str_has_prefix(split[i], "stationname=")) |
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
209 { |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
210 mowgli_global_storage_put("lastfm_station_name", g_strdup(split[i] + 12)); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
211 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
212 g_print ("Setting station name: '%s'\n", |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
213 (gchar*)mowgli_global_storage_get("lastfm_station_name")); |
1009
f30aaf18916a
[svn] added primitive metadata handling (just gets printed in the terminal)
majeru
parents:
1008
diff
changeset
|
214 #endif |
f30aaf18916a
[svn] added primitive metadata handling (just gets printed in the terminal)
majeru
parents:
1008
diff
changeset
|
215 } |
f30aaf18916a
[svn] added primitive metadata handling (just gets printed in the terminal)
majeru
parents:
1008
diff
changeset
|
216 } |
f30aaf18916a
[svn] added primitive metadata handling (just gets printed in the terminal)
majeru
parents:
1008
diff
changeset
|
217 g_strfreev(split); |
f30aaf18916a
[svn] added primitive metadata handling (just gets printed in the terminal)
majeru
parents:
1008
diff
changeset
|
218 } |
f30aaf18916a
[svn] added primitive metadata handling (just gets printed in the terminal)
majeru
parents:
1008
diff
changeset
|
219 g_string_erase(res, 0, -1); |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
220 |
1009
f30aaf18916a
[svn] added primitive metadata handling (just gets printed in the terminal)
majeru
parents:
1008
diff
changeset
|
221 return ret; |
f30aaf18916a
[svn] added primitive metadata handling (just gets printed in the terminal)
majeru
parents:
1008
diff
changeset
|
222 } |
1036 | 223 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
224 void parse( gchar **split , gchar* field, gchar* data){ |
1036 | 225 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
226 |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
227 } |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
228 |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
229 void parse_metadata(LastFM * handle,GString * metadata) |
1036 | 230 { |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
231 gchar **split = g_strsplit(metadata->str, "\n", 20); |
1036 | 232 int i; |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
233 handle->lastfm_duration=0; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
234 |
1036 | 235 for (i = 0; split && split[i]; i++) |
236 { | |
237 if (g_str_has_prefix(split[i], "artist=")) | |
238 { | |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
239 if (handle->lastfm_artist) |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
240 g_free(handle->lastfm_artist); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
241 |
1036 | 242 handle->lastfm_artist = g_strdup(split[i] + 7); |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
243 #if DEBUG |
1036 | 244 g_print("Artist: %s\n", handle->lastfm_artist); |
245 #endif | |
246 } | |
247 if (g_str_has_prefix(split[i], "track=")) | |
248 { | |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
249 if (handle->lastfm_title) |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
250 g_free(handle->lastfm_title); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
251 |
1036 | 252 handle->lastfm_title = g_strdup(split[i] + 6); |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
253 #if DEBUG |
1036 | 254 g_print("Title: %s\n", handle->lastfm_title); |
255 #endif | |
256 } | |
257 | |
258 if (g_str_has_prefix(split[i], "album=")) | |
259 handle->lastfm_album = g_strdup(split[i] + 6); | |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
260 |
1036 | 261 if (g_str_has_prefix(split[i], "albumcover_medium=")) |
262 handle->lastfm_cover = g_strdup(split[i] + 18); | |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
263 |
1036 | 264 if (g_str_has_prefix(split[i], "trackduration=")) |
265 { | |
266 handle->lastfm_duration = g_ascii_strtoull(g_strdup(split[i] + 14), NULL, 10); | |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
267 #if DEBUG |
1036 | 268 g_print("Duration:%d\n", handle->lastfm_duration); |
269 #endif | |
270 } | |
271 if (g_str_has_prefix(split[i], "trackprogress=")) | |
272 handle->lastfm_progress = g_ascii_strtoull(g_strdup(split[i] + 14), NULL, 10); | |
273 | |
274 if (g_str_has_prefix(split[i], "station=")) | |
275 { | |
276 handle->lastfm_station_name = g_strdup(split[i] + 8); | |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
277 #if DEBUG |
1036 | 278 g_print("Station Name: %s\n", handle->lastfm_station_name); |
279 #endif | |
280 } | |
281 } | |
282 | |
283 g_strfreev(split); | |
284 return; | |
285 } | |
286 | |
287 | |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
288 gpointer lastfm_get_metadata(gpointer arg) |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
289 { |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
290 gint err=0, |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
291 delay=-2, |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
292 sleep_duration=1, |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
293 count=0, |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
294 status; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
295 gchar uri[4096]; |
1036 | 296 GString *res = g_string_new(NULL); |
297 gboolean track_end=FALSE; | |
1044
b1128efde471
[svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents:
1036
diff
changeset
|
298 LastFM *handle = (LastFM *)arg; |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
299 handle->lastfm_session_id =g_strdup(mowgli_global_storage_get("lastfm_session_id")); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
300 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
301 g_print("Session ID: %s\n", handle->lastfm_session_id); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
302 #endif |
1044
b1128efde471
[svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents:
1036
diff
changeset
|
303 |
1036 | 304 if (handle->lastfm_session_id == NULL) |
305 return NULL; | |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
306 snprintf(uri, sizeof(uri), LASTFM_METADATA_URL, handle->lastfm_session_id); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
307 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
308 g_print("Download URI: %s\n", uri); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
309 #endif |
1036 | 310 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
311 |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
312 while ( (handle!= NULL) && (err<5)) |
1036 | 313 //exit after 5 failed retries or after metadata_thread changes |
314 { | |
315 count++; | |
316 if (count==sleep_duration) | |
317 { | |
318 handle->lastfm_duration = 0; | |
319 handle->lastfm_progress = 0; | |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
320 status = lastfm_get_data_from_uri(uri, res); |
1036 | 321 if (status == CURLE_OK) |
322 { | |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
323 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
324 g_print("Successfully got Metadata\n"); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
325 g_print("Received metadata:'%s'\nParsing...", res->str); |
979
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
326 #endif |
1036 | 327 parse_metadata( handle,res); |
328 } | |
329 g_string_erase(res, 0, -1); | |
979
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
330 |
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
331 |
1036 | 332 if ((!track_end) && (handle->lastfm_duration >0)) |
333 { //refresh metadata 2 sec before track's end and 2 sec after the next track starts | |
334 sleep_duration = handle->lastfm_duration - handle->lastfm_progress - delay -4; | |
335 track_end=TRUE; | |
336 err=delay=count=0; | |
337 } | |
338 else | |
339 { | |
340 err++; | |
341 track_end=FALSE; | |
342 sleep_duration=4; | |
343 count=0; | |
344 } | |
978
3513bc2fd738
[svn] got the metadata but couldnt make use of it yet
majeru
parents:
976
diff
changeset
|
345 |
1036 | 346 if(handle->lastfm_duration ==0) //polling every 2 seconds until I get first data |
347 { | |
348 sleep_duration=2; | |
349 count=0; | |
350 delay+=2; //time until I get first data | |
351 //starts from -2 to have uniform handling for in first iteration | |
352 //when calculating sleep_time | |
353 } | |
1013
177d47add6dd
[svn] lastfn's metadata seems to wotk, but still it has some glitches
majeru
parents:
1010
diff
changeset
|
354 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
355 #if DEBUG |
1036 | 356 g_print("Sleeping for %d seconds\n", sleep_duration); |
1013
177d47add6dd
[svn] lastfn's metadata seems to wotk, but still it has some glitches
majeru
parents:
1010
diff
changeset
|
357 #endif |
1036 | 358 } |
359 sleep(1); | |
360 } | |
361 | |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
362 #if DEBUG |
1047 | 363 g_print("Exiting thread, ID = %p\n", (void *)g_thread_self()); |
1036 | 364 #endif |
365 handle->metadata_thread = NULL; | |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
366 return NULL; |
978
3513bc2fd738
[svn] got the metadata but couldnt make use of it yet
majeru
parents:
976
diff
changeset
|
367 } |
3513bc2fd738
[svn] got the metadata but couldnt make use of it yet
majeru
parents:
976
diff
changeset
|
368 |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
369 VFSFile *lastfm_vfs_fopen_impl(const gchar * path, const gchar * mode) |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
370 { |
1036 | 371 // static GThread *th; |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
372 VFSFile *file; |
975 | 373 LastFM *handle; |
976 | 374 file = g_new0(VFSFile, 1); |
975 | 375 handle = g_new0(LastFM, 1); |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
376 int login_count = 0; |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
377 while( ! mowgli_global_storage_get("lastfm_stream_uri")&&(login_count <= 3)) |
976 | 378 { |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
379 printf("Login try count: %d\n", login_count++); |
976 | 380 lastfm_login(); |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
381 if (!mowgli_global_storage_get("lastfm_stream_uri")) |
976 | 382 sleep(5); |
383 } | |
978
3513bc2fd738
[svn] got the metadata but couldnt make use of it yet
majeru
parents:
976
diff
changeset
|
384 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
385 if (!mowgli_global_storage_get("lastfm_stream_uri")) |
979
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
386 return NULL; |
978
3513bc2fd738
[svn] got the metadata but couldnt make use of it yet
majeru
parents:
976
diff
changeset
|
387 |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
388 handle->lastfm_session_id = g_strdup(mowgli_global_storage_get("lastfm_session_id")); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
389 handle->lastfm_mp3_stream_url = g_strdup(mowgli_global_storage_get("lastfm_stream_uri")); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
390 |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
391 if (!mowgli_global_storage_get("lastfm_station_name")) |
1036 | 392 { |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
393 if(lastfm_adjust(path)==LASTFM_ADJUST_OK) |
1036 | 394 { |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
395 #if DEBUG |
1036 | 396 g_print("Tuning was successfully completed into the channel\n"); |
397 #endif | |
398 } | |
399 else | |
400 { | |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
401 #if DEBUG |
1036 | 402 g_print("Cannot tune to given channel\n"); |
403 #endif | |
404 } | |
405 } | |
406 | |
407 if ((handle->metadata_thread = g_thread_create(lastfm_get_metadata, handle, FALSE, NULL)) == NULL) | |
408 { | |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
409 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
410 g_print("Error creating metadata thread!!!\n"); |
1036 | 411 #endif |
412 return NULL; | |
413 } | |
414 else | |
415 { | |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
416 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
417 g_print("A metadata thread has just been created, ID = %p \n", (void *)handle->metadata_thread); |
1036 | 418 #endif |
419 } | |
420 | |
421 handle->proxy_fd = vfs_fopen(handle->lastfm_mp3_stream_url, mode); | |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
422 file->handle = handle; |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
423 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
424 return file; |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
425 } |
976 | 426 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
427 gint lastfm_vfs_fclose_impl(VFSFile * file) |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
428 { |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
429 gint ret = 0; |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
430 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
431 if (file == NULL) |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
432 return -1; |
1036 | 433 LastFM *handle = file->handle; |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
434 ret = vfs_fclose(handle->proxy_fd); |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
435 if (!ret) |
1036 | 436 { |
437 handle->proxy_fd = NULL; | |
438 handle->metadata_thread=NULL; | |
439 } | |
440 g_free(handle); | |
441 handle=NULL; | |
442 return ret; | |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
443 } |
1013
177d47add6dd
[svn] lastfn's metadata seems to wotk, but still it has some glitches
majeru
parents:
1010
diff
changeset
|
444 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
445 size_t lastfm_vfs_fread_impl(gpointer ptr, size_t size, size_t nmemb, VFSFile * file) |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
446 { |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
447 LastFM *handle = file->handle; |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
448 size_t ret = vfs_fread(ptr, size, nmemb, handle->proxy_fd); |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
449 return ret; |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
450 } |
1013
177d47add6dd
[svn] lastfn's metadata seems to wotk, but still it has some glitches
majeru
parents:
1010
diff
changeset
|
451 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
452 size_t lastfm_vfs_fwrite_impl(gconstpointer ptr, size_t size, size_t nmemb, VFSFile * file) |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
453 { |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
454 return -1; |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
455 } |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
456 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
457 gint lastfm_vfs_getc_impl(VFSFile * stream) |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
458 { |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
459 LastFM *handle = stream->handle; |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
460 return vfs_getc(handle->proxy_fd); |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
461 } |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
462 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
463 gint lastfm_vfs_ungetc_impl(gint c, VFSFile * stream) |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
464 { |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
465 LastFM *handle = stream->handle; |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
466 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
467 return vfs_ungetc(c, handle->proxy_fd); |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
468 } |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
469 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
470 gint lastfm_vfs_fseek_impl(VFSFile * file, glong offset, gint whence) |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
471 { |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
472 return -1; |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
473 } |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
474 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
475 void lastfm_vfs_rewind_impl(VFSFile * file) |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
476 { |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
477 return; |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
478 } |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
479 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
480 glong lastfm_vfs_ftell_impl(VFSFile * file) |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
481 { |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
482 LastFM *handle = file->handle; |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
483 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
484 return vfs_ftell(handle->proxy_fd); |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
485 } |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
486 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
487 gboolean lastfm_vfs_feof_impl(VFSFile * file) |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
488 { |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
489 LastFM *handle = file->handle; |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
490 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
491 return vfs_feof(handle->proxy_fd); |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
492 } |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
493 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
494 gint lastfm_vfs_truncate_impl(VFSFile * file, glong size) |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
495 { |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
496 return -1; |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
497 } |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
498 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
499 off_t lastfm_vfs_fsize_impl(VFSFile * file) |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
500 { |
1017
2f0b7056f354
[svn] - returning -1 is invalid here for fsize(). make metadata display in Audacious.
nenolod
parents:
1016
diff
changeset
|
501 return 0; |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
502 } |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
503 |
1014
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
504 gchar *lastfm_vfs_metadata_impl(VFSFile * file, const gchar * field) |
af586df84c9b
[svn] - lets avoid spawning >1 threads for metadata
nenolod
parents:
1013
diff
changeset
|
505 { |
976 | 506 LastFM *handle = file->handle; |
979
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
507 |
1036 | 508 #if 0 |
509 g_print("Interesting metadata (want: %s):\n", field); | |
979
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
510 |
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
511 if (handle->lastfm_station_name != NULL) |
1010
8bad1b46ef78
[svn] - make this compile again and indent properly
nenolod
parents:
1009
diff
changeset
|
512 g_print("%s\n", handle->lastfm_station_name); |
979
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
513 |
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
514 if (handle->lastfm_artist != NULL) |
1010
8bad1b46ef78
[svn] - make this compile again and indent properly
nenolod
parents:
1009
diff
changeset
|
515 g_print("%s\n", handle->lastfm_artist); |
975 | 516 |
1036 | 517 |
979
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
518 if (handle->lastfm_title != NULL) |
1010
8bad1b46ef78
[svn] - make this compile again and indent properly
nenolod
parents:
1009
diff
changeset
|
519 g_print("%s\n", handle->lastfm_title); |
978
3513bc2fd738
[svn] got the metadata but couldnt make use of it yet
majeru
parents:
976
diff
changeset
|
520 |
1013
177d47add6dd
[svn] lastfn's metadata seems to wotk, but still it has some glitches
majeru
parents:
1010
diff
changeset
|
521 g_print("%u\n\n", handle->lastfm_duration); |
979
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
522 #endif |
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
523 |
1013
177d47add6dd
[svn] lastfn's metadata seems to wotk, but still it has some glitches
majeru
parents:
1010
diff
changeset
|
524 if (!g_ascii_strncasecmp(field, "stream-name", 11) && (handle->lastfm_station_name != NULL)) |
979
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
525 return g_strdup(handle->lastfm_station_name); |
1013
177d47add6dd
[svn] lastfn's metadata seems to wotk, but still it has some glitches
majeru
parents:
1010
diff
changeset
|
526 if (!g_ascii_strncasecmp(field, "track-name", 10) && (handle->lastfm_title != NULL) && (handle->lastfm_artist != NULL)) |
979
e31c4566feb6
[svn] - disable all use of puts() unless -DDEBUG is defined.
nenolod
parents:
978
diff
changeset
|
527 return g_strdup_printf("%s - %s", handle->lastfm_artist, handle->lastfm_title); |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
528 |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
529 return NULL; |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
530 } |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
531 |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
532 VFSConstructor lastfm_const = { |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
533 "lastfm://", |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
534 lastfm_vfs_fopen_impl, |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
535 lastfm_vfs_fclose_impl, |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
536 lastfm_vfs_fread_impl, |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
537 lastfm_vfs_fwrite_impl, |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
538 lastfm_vfs_getc_impl, |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
539 lastfm_vfs_ungetc_impl, |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
540 lastfm_vfs_fseek_impl, |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
541 lastfm_vfs_rewind_impl, |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
542 lastfm_vfs_ftell_impl, |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
543 lastfm_vfs_feof_impl, |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
544 lastfm_vfs_truncate_impl, |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
545 lastfm_vfs_fsize_impl, |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
546 lastfm_vfs_metadata_impl |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
547 }; |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
548 |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
549 static void init(void) |
1036 | 550 { |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
551 vfs_register_transport(&lastfm_const); |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
552 } |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
553 |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
554 static void cleanup(void) |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
555 { |
1200
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
556 |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
557 mowgli_global_storage_free("lastfm_session_id"); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
558 mowgli_global_storage_free("lastfm_stream_uri"); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
559 #if DEBUG |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
560 g_print ("Cleanup finished\n"); |
0ae013f630fa
mowgli transition, and some fixes
Cristi Magherusan <majeru@atheme-project.org>
parents:
1182
diff
changeset
|
561 #endif |
972
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
562 } |
cf7021ca4e7b
[svn] Add lastfm:// transport, an abstract VFS class which derives from curl
nenolod
parents:
diff
changeset
|
563 |
1182
8df9aab3897e
[svn] - Bleh, squash the evil warning! Must compile without warnings!
nazca
parents:
1161
diff
changeset
|
564 DECLARE_PLUGIN(lastfm, init, cleanup, NULL, NULL, NULL, NULL, NULL) |