Mercurial > audlegacy-plugins
annotate src/scrobbler/scrobbler.c @ 2499:4d6045c20cc5
Include cleanups, part #4.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 31 Mar 2008 15:18:05 +0300 |
parents | 1286f65395d7 |
children | bd3a24b39058 |
rev | line source |
---|---|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1 #include <pthread.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
2 #include <limits.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
3 #include <stdlib.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
4 #include <string.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
5 #include <stdarg.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
6 #include <curl/curl.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
7 #include <stdio.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
8 #include "fmt.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
9 #include "md5.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
10 #include "scrobbler.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
11 #include "config.h" |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
12 #include "settings.h" |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
13 #include <glib.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
14 |
1982
0ea55fc6f220
scrobbler: vtable fixing
William Pitcock <nenolod@atheme.org>
parents:
1976
diff
changeset
|
15 #include <audacious/plugin.h> |
732 | 16 #include <audacious/util.h> |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
17 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
18 #define SCROBBLER_HS_URL "http://post.audioscrobbler.com" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
19 #define SCROBBLER_CLI_ID "aud" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
20 #define SCROBBLER_HS_WAIT 1800 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
21 #define SCROBBLER_SB_WAIT 10 |
1026
ff0487e9d00d
[svn] - first attempt at implementing AudioScrobbler 1.2 protocol
nenolod
parents:
990
diff
changeset
|
22 #define SCROBBLER_VERSION "1.2" |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
23 #define SCROBBLER_IMPLEMENTATION "0.2" /* This is the implementation, not the player version. */ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
24 #define SCROBBLER_SB_MAXLEN 1024 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
25 #define CACHE_SIZE 1024 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
26 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
27 /* Scrobblerbackend for xmms plugin, first draft */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
28 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
29 static int sc_hs_status, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
30 sc_hs_timeout, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
31 sc_hs_errors, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
32 sc_sb_errors, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
33 sc_bad_users, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
34 sc_submit_interval, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
35 sc_submit_timeout, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
36 sc_srv_res_size, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
37 sc_giveup, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
38 sc_major_error_present; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
39 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
40 static char *sc_submit_url, /* queue */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
41 *sc_np_url, /* np */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
42 *sc_session_id, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
43 *sc_username = NULL, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
44 *sc_password = NULL, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
45 *sc_challenge_hash, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
46 sc_response_hash[65535], |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
47 *sc_srv_res, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
48 sc_curl_errbuf[CURL_ERROR_SIZE], |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
49 *sc_major_error; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
50 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
51 static void dump_queue(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
52 |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
53 /**** Queue stuff ****/ |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
54 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
55 #define I_ARTIST(i) i->artist |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
56 #define I_TITLE(i) i->title |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
57 #define I_TIME(i) i->utctime |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
58 #define I_LEN(i) i->len |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
59 #define I_ALBUM(i) i->album |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
60 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
61 typedef struct { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
62 char *artist, *title, *album; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
63 int utctime, track, len; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
64 int timeplayed; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
65 int numtries; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
66 void *next; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
67 } item_t; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
68 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
69 static item_t *q_queue = NULL; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
70 static item_t *q_queue_last = NULL; |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
71 static int q_nitems; |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
72 static item_t *np_item = NULL; |
2306
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2302
diff
changeset
|
73 |
1172 | 74 gchar * |
75 xmms_urldecode_plain(const gchar * encoded_path) | |
76 { | |
77 const gchar *cur, *ext; | |
78 gchar *path, *tmp; | |
79 gint realchar; | |
80 | |
81 if (!encoded_path) | |
82 return NULL; | |
83 | |
84 cur = encoded_path; | |
85 if (*cur == '/') | |
86 while (cur[1] == '/') | |
87 cur++; | |
88 | |
89 tmp = g_malloc0(strlen(cur) + 1); | |
90 | |
91 while ((ext = strchr(cur, '%')) != NULL) { | |
92 strncat(tmp, cur, ext - cur); | |
93 ext++; | |
94 cur = ext + 2; | |
95 if (!sscanf(ext, "%2x", &realchar)) { | |
96 /* | |
97 * Assume it is a literal '%'. Several file | |
98 * managers send unencoded file: urls on on | |
99 * drag and drop. | |
100 */ | |
101 realchar = '%'; | |
102 cur -= 2; | |
103 } | |
104 tmp[strlen(tmp)] = realchar; | |
105 } | |
106 | |
107 path = g_strconcat(tmp, cur, NULL); | |
108 g_free(tmp); | |
109 return path; | |
110 } | |
111 | |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
112 static void q_item_free(item_t *item) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
113 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
114 if (item == NULL) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
115 return; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
116 curl_free(item->artist); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
117 curl_free(item->title); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
118 curl_free(item->album); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
119 free(item); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
120 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
121 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
122 static item_t *q_additem(item_t *newitem) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
123 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
124 pdebug(fmt_vastr("Adding %s - %s to the queue", newitem->artist, newitem->title), DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
125 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
126 q_nitems++; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
127 newitem->next = NULL; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
128 if (q_queue_last == NULL) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
129 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
130 q_queue = q_queue_last = newitem; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
131 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
132 else |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
133 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
134 q_queue_last->next = newitem; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
135 q_queue_last = newitem; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
136 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
137 return newitem; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
138 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
139 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
140 static item_t *create_item(Tuple *tuple, int len) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
141 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
142 item_t *item; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
143 const gchar *album; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
144 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
145 item = malloc(sizeof(item_t)); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
146 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
147 item->artist = fmt_escape(aud_tuple_get_string(tuple, FIELD_ARTIST, NULL)); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
148 item->title = fmt_escape(aud_tuple_get_string(tuple, FIELD_TITLE, NULL)); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
149 item->len = len; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
150 item->track = aud_tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
151 item->timeplayed = 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
152 item->utctime = time(NULL); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
153 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
154 album = aud_tuple_get_string(tuple, FIELD_ALBUM, NULL); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
155 if (album) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
156 item->album = fmt_escape((char*) album); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
157 else |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
158 item->album = fmt_escape(""); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
159 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
160 item->next = NULL; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
161 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
162 return item; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
163 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
164 |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
165 static item_t *q_put(Tuple *tuple, int t, int len) |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
166 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
167 item_t *item; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
168 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
169 item = create_item(tuple, len); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
170 item->timeplayed = len; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
171 item->utctime = t; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
172 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
173 return q_additem(item); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
174 } |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
175 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
176 static item_t *set_np(Tuple *tuple, int len) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
177 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
178 q_item_free(np_item); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
179 np_item = create_item(tuple, len); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
180 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
181 pdebug(fmt_vastr("Tracking now-playing track: %s - %s", np_item->artist, np_item->title), DEBUG); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
182 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
183 return np_item; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
184 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
185 |
990
238055a6cb8f
[svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents:
786
diff
changeset
|
186 #if 0 |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
187 static item_t *q_peek(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
188 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
189 if (q_nitems == 0) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
190 return NULL; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
191 return q_queue; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
192 } |
990
238055a6cb8f
[svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents:
786
diff
changeset
|
193 #endif |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
194 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
195 static item_t *q_peekall(int rewind) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
196 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
197 static item_t *citem = NULL; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
198 item_t *temp_item; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
199 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
200 if (rewind) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
201 citem = q_queue; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
202 return NULL; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
203 } |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
204 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
205 temp_item = citem; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
206 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
207 if(citem != NULL) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
208 citem = citem->next; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
209 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
210 return temp_item; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
211 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
212 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
213 static int q_get(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
214 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
215 item_t *item; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
216 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
217 if (q_nitems == 0) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
218 return 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
219 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
220 item = q_queue; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
221 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
222 if(item == NULL) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
223 return 0; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
224 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
225 q_nitems--; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
226 q_queue = q_queue->next; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
227 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
228 pdebug(fmt_vastr("Removing %s - %s from queue", item->artist, item->title), DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
229 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
230 q_item_free(item); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
231 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
232 if (q_nitems == 0) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
233 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
234 q_queue_last = NULL; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
235 return 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
236 } |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
237 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
238 return -1; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
239 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
240 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
241 static void q_free(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
242 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
243 while (q_get()); |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
244 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
245 |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
246 static int q_len(void) |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
247 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
248 return q_nitems; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
249 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
250 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
251 /* isn't there better way for that? --desowin */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
252 gboolean sc_timeout(gpointer data) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
253 if (np_item) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
254 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
255 if (audacious_drct_get_playing() && !audacious_drct_get_paused()) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
256 np_item->timeplayed+=1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
257 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
258 /* |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
259 * Check our now-playing track to see if it should go into the queue |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
260 */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
261 if (((np_item->timeplayed >= (np_item->len / 2)) || |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
262 (np_item->timeplayed >= 240))) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
263 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
264 q_additem(np_item); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
265 np_item = NULL; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
266 dump_queue(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
267 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
268 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
269 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
270 return TRUE; |
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
271 } |
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
12
diff
changeset
|
272 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
273 /* Error functions */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
274 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
275 static void sc_throw_error(char *errortxt) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
276 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
277 sc_major_error_present = 1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
278 if(sc_major_error == NULL) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
279 sc_major_error = strdup(errortxt); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
280 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
281 return; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
282 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
283 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
284 int sc_catch_error(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
285 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
286 return sc_major_error_present; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
287 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
288 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
289 char *sc_fetch_error(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
290 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
291 return sc_major_error; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
292 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
293 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
294 void sc_clear_error(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
295 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
296 sc_major_error_present = 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
297 if(sc_major_error != NULL) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
298 free(sc_major_error); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
299 sc_major_error = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
300 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
301 return; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
302 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
303 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
304 static size_t sc_store_res(void *ptr, size_t size, |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
305 size_t nmemb, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
306 void *stream __attribute__((unused))) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
307 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
308 int len = size * nmemb; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
309 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
310 sc_srv_res = realloc(sc_srv_res, sc_srv_res_size + len + 1); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
311 memcpy(sc_srv_res + sc_srv_res_size, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
312 ptr, len); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
313 sc_srv_res_size += len; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
314 return len; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
315 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
316 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
317 static void sc_free_res(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
318 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
319 if(sc_srv_res != NULL) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
320 free(sc_srv_res); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
321 sc_srv_res = NULL; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
322 sc_srv_res_size = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
323 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
324 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
325 static int sc_parse_hs_res(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
326 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
327 char *interval; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
328 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
329 if (!sc_srv_res_size) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
330 pdebug("No reply from server", DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
331 return -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
332 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
333 *(sc_srv_res + sc_srv_res_size) = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
334 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
335 if (!strncmp(sc_srv_res, "OK\n", 3)) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
336 gchar *scratch = g_strdup(sc_srv_res); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
337 gchar **split = g_strsplit(scratch, "\n", 5); |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
338 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
339 g_free(scratch); |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
340 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
341 sc_session_id = g_strdup(split[1]); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
342 sc_np_url = g_strdup(split[2]); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
343 sc_submit_url = g_strdup(split[3]); |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
344 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
345 g_strfreev(split); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
346 return 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
347 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
348 if (!strncmp(sc_srv_res, "FAILED ", 7)) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
349 interval = strstr(sc_srv_res, "INTERVAL"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
350 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
351 /* Throwing a major error, just in case */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
352 /* sc_throw_error(fmt_vastr("%s", sc_srv_res)); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
353 sc_hs_errors++; */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
354 pdebug(fmt_vastr("error: %s", sc_srv_res), DEBUG); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
355 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
356 return -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
357 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
358 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
359 if (!strncmp(sc_srv_res, "UPDATE ", 7)) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
360 interval = strstr(sc_srv_res, "INTERVAL"); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
361 if(!interval) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
362 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
363 pdebug("missing INTERVAL", DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
364 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
365 else |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
366 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
367 *(interval - 1) = 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
368 sc_submit_interval = strtol(interval + 8, NULL, 10); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
369 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
370 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
371 sc_submit_url = strchr(strchr(sc_srv_res, '\n') + 1, '\n') + 1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
372 *(sc_submit_url - 1) = 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
373 sc_submit_url = strdup(sc_submit_url); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
374 sc_challenge_hash = strchr(sc_srv_res, '\n') + 1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
375 *(sc_challenge_hash - 1) = 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
376 sc_challenge_hash = strdup(sc_challenge_hash); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
377 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
378 /* Throwing major error. Need to alert client to update. */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
379 sc_throw_error(fmt_vastr("Please update Audacious.\n" |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
380 "Update available at: http://audacious-media-player.org")); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
381 pdebug(fmt_vastr("update client: %s", sc_srv_res + 7), DEBUG); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
382 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
383 /* |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
384 * Russ isn't clear on whether we can submit with a not-updated |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
385 * client. Neither is RJ. I use what we did before. |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
386 */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
387 sc_giveup = -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
388 return -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
389 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
390 if (!strncmp(sc_srv_res, "UPTODATE\n", 9)) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
391 sc_bad_users = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
392 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
393 interval = strstr(sc_srv_res, "INTERVAL"); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
394 if (!interval) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
395 pdebug("missing INTERVAL", DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
396 /* |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
397 * This is probably a bad thing, but Russ seems to |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
398 * think its OK to assume that an UPTODATE response |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
399 * may not have an INTERVAL... We return -1 anyway. |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
400 */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
401 return -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
402 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
403 else |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
404 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
405 *(interval - 1) = 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
406 sc_submit_interval = strtol(interval + 8, NULL, 10); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
407 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
408 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
409 sc_submit_url = strchr(strchr(sc_srv_res, '\n') + 1, '\n') + 1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
410 *(sc_submit_url - 1) = 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
411 sc_submit_url = strdup(sc_submit_url); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
412 sc_challenge_hash = strchr(sc_srv_res, '\n') + 1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
413 *(sc_challenge_hash - 1) = 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
414 sc_challenge_hash = strdup(sc_challenge_hash); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
415 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
416 return 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
417 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
418 if(!strncmp(sc_srv_res, "BADAUTH", 7)) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
419 /* Throwing major error. */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
420 sc_throw_error("Incorrect username/password.\n" |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
421 "Please fix in configuration."); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
422 pdebug("incorrect username/password", DEBUG); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
423 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
424 interval = strstr(sc_srv_res, "INTERVAL"); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
425 if(!interval) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
426 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
427 pdebug("missing INTERVAL", DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
428 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
429 else |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
430 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
431 *(interval - 1) = 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
432 sc_submit_interval = strtol(interval + 8, NULL, 10); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
433 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
434 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
435 return -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
436 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
437 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
438 pdebug(fmt_vastr("unknown server-reply '%s'", sc_srv_res), DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
439 return -1; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
440 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
441 |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
442 static unsigned char *md5_string(char *pass, int len) |
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
443 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
444 md5_state_t md5state; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
445 static unsigned char md5pword[16]; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
446 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
447 md5_init(&md5state); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
448 md5_append(&md5state, (unsigned const char *)pass, len); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
449 md5_finish(&md5state, md5pword); |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
450 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
451 return md5pword; |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
452 } |
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
453 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
454 static void hexify(char *pass, int len) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
455 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
456 char *bp = sc_response_hash; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
457 char hexchars[] = "0123456789abcdef"; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
458 int i; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
459 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
460 memset(sc_response_hash, 0, sizeof(sc_response_hash)); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
461 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
462 for(i = 0; i < len; i++) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
463 *(bp++) = hexchars[(pass[i] >> 4) & 0x0f]; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
464 *(bp++) = hexchars[pass[i] & 0x0f]; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
465 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
466 *bp = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
467 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
468 return; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
469 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
470 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
471 static int sc_handshake(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
472 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
473 int status; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
474 char buf[65535]; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
475 CURL *curl; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
476 time_t ts = time(NULL); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
477 char *auth_tmp; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
478 char *auth; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
479 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
480 auth_tmp = g_strdup_printf("%s%ld", sc_password, ts); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
481 auth = (char *)md5_string(auth_tmp, strlen(auth_tmp)); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
482 g_free(auth_tmp); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
483 hexify(auth, strlen(auth)); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
484 auth_tmp = g_strdup(sc_response_hash); |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
485 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
486 g_snprintf(buf, sizeof(buf), "%s/?hs=true&p=%s&c=%s&v=%s&u=%s&t=%ld&a=%s", |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
487 SCROBBLER_HS_URL, SCROBBLER_VERSION, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
488 SCROBBLER_CLI_ID, SCROBBLER_IMPLEMENTATION, sc_username, time(NULL), |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
489 auth_tmp); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
490 g_free(auth_tmp); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
491 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
492 curl = curl_easy_init(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
493 curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
494 curl_easy_setopt(curl, CURLOPT_URL, buf); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
495 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
496 sc_store_res); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
497 memset(sc_curl_errbuf, 0, sizeof(sc_curl_errbuf)); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
498 curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, sc_curl_errbuf); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
499 curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
500 curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
501 curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, SC_CURL_TIMEOUT); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
502 status = curl_easy_perform(curl); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
503 curl_easy_cleanup(curl); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
504 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
505 sc_hs_timeout = time(NULL) + SCROBBLER_HS_WAIT; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
506 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
507 if (status) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
508 pdebug(sc_curl_errbuf, DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
509 sc_hs_errors++; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
510 sc_free_res(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
511 return -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
512 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
513 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
514 if (sc_parse_hs_res()) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
515 sc_hs_errors++; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
516 sc_free_res(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
517 return -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
518 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
519 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
520 if (sc_challenge_hash != NULL) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
521 md5_state_t md5state; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
522 unsigned char md5pword[16]; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
523 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
524 md5_init(&md5state); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
525 /*pdebug(fmt_vastr("Pass Hash: %s", sc_password), DEBUG);*/ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
526 md5_append(&md5state, (unsigned const char *)sc_password, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
527 strlen(sc_password)); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
528 /*pdebug(fmt_vastr("Challenge Hash: %s", sc_challenge_hash), DEBUG);*/ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
529 md5_append(&md5state, (unsigned const char *)sc_challenge_hash, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
530 strlen(sc_challenge_hash)); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
531 md5_finish(&md5state, md5pword); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
532 hexify((char*)md5pword, sizeof(md5pword)); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
533 /*pdebug(fmt_vastr("Response Hash: %s", sc_response_hash), DEBUG);*/ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
534 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
535 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
536 sc_hs_errors = 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
537 sc_hs_status = 1; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
538 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
539 sc_free_res(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
540 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
541 pdebug(fmt_vastr("submiturl: %s - interval: %d", |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
542 sc_submit_url, sc_submit_interval), DEBUG); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
543 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
544 return 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
545 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
546 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
547 static int sc_parse_sb_res(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
548 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
549 char *ch, *ch2; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
550 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
551 if (!sc_srv_res_size) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
552 pdebug("No response from server", DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
553 return -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
554 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
555 *(sc_srv_res + sc_srv_res_size) = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
556 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
557 if (!strncmp(sc_srv_res, "OK", 2)) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
558 if ((ch = strstr(sc_srv_res, "INTERVAL"))) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
559 sc_submit_interval = strtol(ch + 8, NULL, 10); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
560 pdebug(fmt_vastr("got new interval: %d", |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
561 sc_submit_interval), DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
562 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
563 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
564 pdebug(fmt_vastr("submission ok: %s", sc_srv_res), DEBUG); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
565 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
566 return 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
567 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
568 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
569 if (!strncmp(sc_srv_res, "BADAUTH", 7)) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
570 if ((ch = strstr(sc_srv_res, "INTERVAL"))) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
571 sc_submit_interval = strtol(ch + 8, NULL, 10); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
572 pdebug(fmt_vastr("got new interval: %d", |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
573 sc_submit_interval), DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
574 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
575 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
576 pdebug("incorrect username/password", DEBUG); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
577 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
578 sc_giveup = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
579 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
580 /* |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
581 * We obviously aren't authenticated. The server might have |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
582 * lost our handshake status though, so let's try |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
583 * re-handshaking... This might not be proper. |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
584 * (we don't give up) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
585 */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
586 sc_hs_status = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
587 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
588 if(sc_challenge_hash != NULL) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
589 free(sc_challenge_hash); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
590 if(sc_submit_url != NULL) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
591 free(sc_submit_url); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
592 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
593 sc_challenge_hash = sc_submit_url = NULL; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
594 sc_bad_users++; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
595 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
596 if(sc_bad_users > 2) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
597 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
598 pdebug("3 BADAUTH returns on submission. Halting " |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
599 "submissions until login fixed.", DEBUG) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
600 sc_throw_error("Incorrect username/password.\n" |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
601 "Please fix in configuration."); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
602 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
603 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
604 return -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
605 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
606 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
607 if (!strncmp(sc_srv_res, "FAILED", 6)) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
608 if ((ch = strstr(sc_srv_res, "INTERVAL"))) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
609 sc_submit_interval = strtol(ch + 8, NULL, 10); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
610 pdebug(fmt_vastr("got new interval: %d", |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
611 sc_submit_interval), DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
612 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
613 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
614 /* This could be important. (Such as FAILED - Get new plugin) */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
615 /*sc_throw_error(fmt_vastr("%s", sc_srv_res));*/ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
616 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
617 pdebug(sc_srv_res, DEBUG); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
618 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
619 return -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
620 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
621 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
622 if (!strncmp(sc_srv_res, "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">", 50)) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
623 ch = strstr(sc_srv_res, "<TITLE>"); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
624 ch2 = strstr(sc_srv_res, "</TITLE>"); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
625 if (ch != NULL && ch2 != NULL) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
626 ch += strlen("<TITLE>"); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
627 *ch2 = '\0'; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
628 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
629 pdebug(fmt_vastr("HTTP Error (%d): '%s'", |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
630 atoi(ch), ch + 4), DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
631 // *ch2 = '<'; // needed? --yaz |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
632 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
633 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
634 return -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
635 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
636 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
637 pdebug(fmt_vastr("unknown server-reply %s", sc_srv_res), DEBUG); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
638 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
639 return -1; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
640 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
641 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
642 static gchar *sc_itemtag(char c, int n, char *str) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
643 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
644 static char buf[SCROBBLER_SB_MAXLEN]; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
645 g_snprintf(buf, SCROBBLER_SB_MAXLEN, "&%c[%d]=%s", c, n, str); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
646 return buf; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
647 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
648 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
649 #define cfa(f, l, n, v) \ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
650 curl_formadd(f, l, CURLFORM_COPYNAME, n, \ |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
651 CURLFORM_PTRCONTENTS, v, CURLFORM_END) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
652 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
653 static int sc_generateentry(GString *submission) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
654 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
655 int i; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
656 item_t *item; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
657 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
658 i = 0; |
1030
9dae0c13a65f
[svn] - enforce audioscrobbler rules on queued tracks
nenolod
parents:
1029
diff
changeset
|
659 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
660 q_peekall(1); |
1030
9dae0c13a65f
[svn] - enforce audioscrobbler rules on queued tracks
nenolod
parents:
1029
diff
changeset
|
661 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
662 while ((item = q_peekall(0)) && i < 10) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
663 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
664 /* |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
665 * We assume now that all tracks in the queue should be submitted. |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
666 * The check occurs in the sc_timeout() function now. |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
667 */ |
1030
9dae0c13a65f
[svn] - enforce audioscrobbler rules on queued tracks
nenolod
parents:
1029
diff
changeset
|
668 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
669 if (!item) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
670 return i; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
671 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
672 g_string_append(submission,sc_itemtag('a',i,I_ARTIST(item))); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
673 g_string_append(submission,sc_itemtag('t',i,I_TITLE(item))); |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
674 gchar *tmp = g_strdup_printf("%d",I_LEN(item)); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
675 g_string_append(submission,sc_itemtag('l',i,tmp)); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
676 g_free(tmp); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
677 tmp = g_strdup_printf("%d",I_TIME(item)); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
678 g_string_append(submission,sc_itemtag('i',i,tmp)); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
679 g_free(tmp); |
2315 | 680 g_string_append(submission,sc_itemtag('m',i,"")); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
681 g_string_append(submission,sc_itemtag('b',i,I_ALBUM(item))); |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
682 g_string_append(submission,sc_itemtag('o',i,"P")); |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
683 tmp = g_strdup_printf("%d",item->track); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
684 g_string_append(submission,sc_itemtag('n',i,tmp)); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
685 g_free(tmp); |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
686 g_string_append(submission,sc_itemtag('r',i,"")); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
687 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
688 pdebug(fmt_vastr("a[%d]=%s t[%d]=%s l[%d]=%d i[%d]=%d b[%d]=%s", |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
689 i, I_ARTIST(item), |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
690 i, I_TITLE(item), |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
691 i, I_LEN(item), |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
692 i, I_TIME(item), |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
693 i, I_ALBUM(item)), DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
694 i++; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
695 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
696 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
697 return i; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
698 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
699 |
1443
f4d8082668c1
scrobbler: tuple API update
William Pitcock <nenolod@atheme-project.org>
parents:
1172
diff
changeset
|
700 static int sc_submit_np(Tuple *tuple) |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
701 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
702 CURL *curl; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
703 /* struct HttpPost *post = NULL , *last = NULL; */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
704 int status; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
705 gchar *entry; |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
706 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
707 curl = curl_easy_init(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
708 curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
709 curl_easy_setopt(curl, CURLOPT_URL, sc_np_url); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
710 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
711 sc_store_res); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
712 curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
713 curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
714 /*cfa(&post, &last, "debug", "failed");*/ |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
715 |
2283
689bdfacb10c
Fixes memory leaks in scrobbler plugin when submitting songs. (Bugzilla #83)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
2267
diff
changeset
|
716 char *field_artist = fmt_escape(aud_tuple_get_string(tuple, FIELD_ARTIST, NULL)); |
689bdfacb10c
Fixes memory leaks in scrobbler plugin when submitting songs. (Bugzilla #83)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
2267
diff
changeset
|
717 char *field_title = fmt_escape(aud_tuple_get_string(tuple, FIELD_TITLE, NULL)); |
689bdfacb10c
Fixes memory leaks in scrobbler plugin when submitting songs. (Bugzilla #83)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
2267
diff
changeset
|
718 char *field_album = aud_tuple_get_string(tuple, FIELD_ALBUM, NULL) ? fmt_escape(aud_tuple_get_string(tuple, FIELD_ALBUM, NULL)) : fmt_escape(""); |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
719 entry = g_strdup_printf("s=%s&a=%s&t=%s&b=%s&l=%d&n=%d&m=", sc_session_id, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
720 field_artist, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
721 field_title, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
722 field_album, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
723 aud_tuple_get_int(tuple, FIELD_LENGTH, NULL) / 1000, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
724 aud_tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL)); |
2283
689bdfacb10c
Fixes memory leaks in scrobbler plugin when submitting songs. (Bugzilla #83)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
2267
diff
changeset
|
725 curl_free(field_artist); |
689bdfacb10c
Fixes memory leaks in scrobbler plugin when submitting songs. (Bugzilla #83)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
2267
diff
changeset
|
726 curl_free(field_title); |
689bdfacb10c
Fixes memory leaks in scrobbler plugin when submitting songs. (Bugzilla #83)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
2267
diff
changeset
|
727 curl_free(field_album); |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
728 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
729 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, (char *) entry); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
730 memset(sc_curl_errbuf, 0, sizeof(sc_curl_errbuf)); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
731 curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, sc_curl_errbuf); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
732 curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
733 curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, SC_CURL_TIMEOUT); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
734 curl_easy_setopt(curl, CURLOPT_TIMEOUT, SCROBBLER_SB_WAIT); |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
735 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
736 status = curl_easy_perform(curl); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
737 curl_easy_cleanup(curl); |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
738 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
739 g_free(entry); |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
740 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
741 if (status) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
742 pdebug(sc_curl_errbuf, DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
743 sc_sb_errors++; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
744 sc_free_res(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
745 return -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
746 } |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
747 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
748 if (sc_parse_sb_res()) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
749 sc_sb_errors++; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
750 sc_free_res(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
751 pdebug(fmt_vastr("Retrying in %d secs, %d elements in queue", |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
752 sc_submit_interval, q_len()), DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
753 return -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
754 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
755 sc_free_res(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
756 return 0; |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
757 } |
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
758 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
759 static int sc_submitentry(gchar *entry) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
760 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
761 CURL *curl; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
762 /* struct HttpPost *post = NULL , *last = NULL; */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
763 int status; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
764 GString *submission; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
765 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
766 curl = curl_easy_init(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
767 curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
768 curl_easy_setopt(curl, CURLOPT_URL, sc_submit_url); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
769 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
770 sc_store_res); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
771 curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
772 curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
773 /*cfa(&post, &last, "debug", "failed");*/ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
774 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
775 /*pdebug(fmt_vastr("Response Hash: %s", sc_response_hash), DEBUG);*/ |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
776 submission = g_string_new("s="); |
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
777 g_string_append(submission, (gchar *)sc_session_id); |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
778 g_string_append(submission, entry); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
779 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
780 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, (char *)submission->str); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
781 memset(sc_curl_errbuf, 0, sizeof(sc_curl_errbuf)); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
782 curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, sc_curl_errbuf); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
783 curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
784 curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, SC_CURL_TIMEOUT); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
785 curl_easy_setopt(curl, CURLOPT_TIMEOUT, SCROBBLER_SB_WAIT); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
786 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
787 status = curl_easy_perform(curl); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
788 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
789 curl_easy_cleanup(curl); |
2283
689bdfacb10c
Fixes memory leaks in scrobbler plugin when submitting songs. (Bugzilla #83)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
2267
diff
changeset
|
790 g_string_free(submission, TRUE); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
791 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
792 if (status) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
793 pdebug(sc_curl_errbuf, DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
794 sc_sb_errors++; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
795 sc_free_res(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
796 return -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
797 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
798 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
799 if (sc_parse_sb_res()) { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
800 sc_sb_errors++; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
801 sc_free_res(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
802 pdebug(fmt_vastr("Retrying in %d secs, %d elements in queue", |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
803 sc_submit_interval, q_len()), DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
804 return -1; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
805 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
806 sc_free_res(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
807 return 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
808 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
809 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
810 static void sc_handlequeue(GMutex *mutex) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
811 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
812 GString *submitentry; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
813 int nsubmit; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
814 int wait; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
815 int i; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
816 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
817 if(sc_submit_timeout < time(NULL) && sc_bad_users < 3) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
818 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
819 submitentry = g_string_new(""); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
820 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
821 g_mutex_lock(mutex); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
822 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
823 nsubmit = sc_generateentry(submitentry); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
824 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
825 g_mutex_unlock(mutex); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
826 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
827 if (nsubmit > 0) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
828 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
829 pdebug(fmt_vastr("Number submitting: %d", nsubmit), DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
830 pdebug(fmt_vastr("Submission: %s", submitentry->str), DEBUG); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
831 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
832 if(!sc_submitentry(submitentry->str)) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
833 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
834 g_mutex_lock(mutex); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
835 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
836 pdebug(fmt_vastr("Clearing out %d item(s) from the queue", nsubmit), DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
837 for (i=0; i<nsubmit; i++) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
838 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
839 q_get(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
840 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
841 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
842 /* |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
843 * This should make sure that the queue doesn't |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
844 * get submitted multiple times on a nasty |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
845 * segfault... |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
846 */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
847 dump_queue(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
848 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
849 g_mutex_unlock(mutex); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
850 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
851 sc_sb_errors = 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
852 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
853 if(sc_sb_errors) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
854 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
855 /* Dump queue */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
856 g_mutex_lock(mutex); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
857 dump_queue(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
858 g_mutex_unlock(mutex); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
859 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
860 if(sc_sb_errors < 5) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
861 /* Retry after 1 min */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
862 wait = 60; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
863 else |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
864 wait = /* sc_submit_interval + */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
865 ( ((sc_sb_errors - 5) < 7) ? |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
866 (60 << (sc_sb_errors-5)) : |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
867 7200 ); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
868 |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
869 sc_submit_timeout = time(NULL) + wait; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
870 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
871 pdebug(fmt_vastr("Error while submitting. " |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
872 "Retrying after %d seconds.", wait), |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
873 DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
874 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
875 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
876 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
877 g_string_free(submitentry, TRUE); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
878 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
879 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
880 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
881 static void read_cache(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
882 { |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
883 FILE *fd; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
884 char buf[PATH_MAX]; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
885 int i=0; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
886 item_t *item; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
887 gchar* config_datadir; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
888 |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
889 config_datadir = audacious_get_localdir(); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
890 g_snprintf(buf, sizeof(buf), "%s/scrobblerqueue.txt", config_datadir); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
891 g_free(config_datadir); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
892 |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
893 if (!(fd = fopen(buf, "r"))) |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
894 return; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
895 pdebug(fmt_vastr("Opening %s", buf), DEBUG); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
896 fclose(fd); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
897 |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
898 gchar* cache; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
899 gchar** values; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
900 gchar** entry; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
901 g_file_get_contents(buf, &cache, NULL, NULL); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
902 values = g_strsplit(cache, "\n", 0); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
903 |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
904 int x; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
905 for (x=0; values[x] && strlen(values[x]); x++) { |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
906 entry = g_strsplit(values[x], "\t", 0); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
907 if (entry[0] && entry[1] && entry[2] && entry[3] && entry[4] && entry[6]) { |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
908 char *artist, *title, *album; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
909 int t, len, track; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
910 |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
911 artist = g_strdup(entry[0]); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
912 album = g_strdup(entry[1]); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
913 title = g_strdup(entry[2]); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
914 track = atoi(entry[3]); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
915 len = atoi(entry[4]); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
916 t = atoi(entry[6]); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
917 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
918 /* |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
919 * All entries in the queue should have "L" as the sixth field now, but |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
920 * we'll continue to check the value anyway, for backwards-compatibility reasons. |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
921 */ |
2306
dd78327f5747
keep track of how long song is played
Tomasz Mon <desowin@gmail.com>
parents:
2302
diff
changeset
|
922 if (!strncmp(entry[5], "L", 1)) { |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
923 Tuple *tuple = aud_tuple_new(); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
924 gchar* string_value; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
925 string_value = xmms_urldecode_plain(artist); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
926 aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, string_value); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
927 g_free(string_value); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
928 string_value = xmms_urldecode_plain(title); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
929 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, string_value); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
930 g_free(string_value); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
931 string_value = xmms_urldecode_plain(album); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
932 aud_tuple_associate_string(tuple, FIELD_ALBUM, NULL, string_value); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
933 g_free(string_value); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
934 aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, track); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
935 item = q_put(tuple, t, len); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
936 |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
937 aud_tuple_free(tuple); |
2315 | 938 |
939 pdebug(fmt_vastr("a[%d]=%s t[%d]=%s l[%d]=%d i[%d]=%d b[%d]=%s", | |
940 i, I_ARTIST(item), | |
941 i, I_TITLE(item), | |
942 i, I_LEN(item), | |
943 i, I_TIME(item), | |
944 i, I_ALBUM(item)), DEBUG); | |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
945 } |
1028
b5de3b4129a6
[svn] - fully update to AudioScrobbler 1.2 protocol
nenolod
parents:
1026
diff
changeset
|
946 |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
947 free(artist); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
948 free(title); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
949 free(album); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
950 i++; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
951 } |
2442
1286f65395d7
string arrays should be freed with g_strfreev()
Tomasz Mon <desowin@gmail.com>
parents:
2441
diff
changeset
|
952 g_strfreev(entry); |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
953 } |
2442
1286f65395d7
string arrays should be freed with g_strfreev()
Tomasz Mon <desowin@gmail.com>
parents:
2441
diff
changeset
|
954 g_strfreev(values); |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
955 g_free(cache); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
956 pdebug("Done loading cache.", DEBUG); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
957 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
958 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
959 static void dump_queue(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
960 { |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
961 FILE *fd; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
962 item_t *item; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
963 char *home, buf[PATH_MAX]; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
964 gchar* config_datadir; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
965 |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
966 /*pdebug("Entering dump_queue();", DEBUG);*/ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
967 |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
968 if (!(home = getenv("HOME"))) |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
969 { |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
970 pdebug("No HOME directory found. Cannot dump queue.", DEBUG); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
971 return; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
972 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
973 |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
974 config_datadir = audacious_get_localdir(); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
975 g_snprintf(buf, sizeof(buf), "%s/scrobblerqueue.txt", config_datadir); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
976 g_free(config_datadir); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
977 |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
978 if (!(fd = fopen(buf, "w"))) |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
979 { |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
980 pdebug(fmt_vastr("Failure opening %s", buf), DEBUG); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
981 return; |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
982 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
983 |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
984 pdebug(fmt_vastr("Opening %s", buf), DEBUG); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
985 |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
986 q_peekall(1); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
987 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
988 /* |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
989 * The sixth field used to be "L" for tracks which were valid submissions, |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
990 * and "S" for tracks which were still playing, and shouldn't be submitted |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
991 * yet. We only store valid submissions in the queue, now, but the "L" value |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
992 * is left in-place for backwards-compatibility reasons. It should probably |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
993 * be removed at some point. |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
994 */ |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
995 while ((item = q_peekall(0))) { |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
996 fprintf(fd, "%s\t%s\t%s\t%d\t%d\t%s\t%d\n", |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
997 I_ARTIST(item), |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
998 I_ALBUM(item), |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
999 I_TITLE(item), |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
1000 item->track, |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
1001 I_LEN(item), |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1002 "L", |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
1003 I_TIME(item)); |
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
1004 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1005 |
2302
f074702a0df3
revise scrobblerqueue.txt a bit
Tomasz Mon <desowin@gmail.com>
parents:
2283
diff
changeset
|
1006 fclose(fd); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1007 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1008 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1009 /* This was made public */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1010 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1011 void sc_cleaner(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1012 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1013 if(sc_submit_url != NULL) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1014 free(sc_submit_url); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1015 if(sc_username != NULL) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1016 free(sc_username); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1017 if(sc_password != NULL) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1018 free(sc_password); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1019 if(sc_challenge_hash != NULL) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1020 free(sc_challenge_hash); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1021 if(sc_srv_res != NULL) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1022 free(sc_srv_res); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1023 if(sc_major_error != NULL) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1024 free(sc_major_error); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1025 dump_queue(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1026 q_free(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1027 pdebug("scrobbler shutting down", DEBUG); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1028 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1029 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1030 static void sc_checkhandshake(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1031 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1032 int wait; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1033 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1034 if (!sc_username || !sc_password) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1035 return; |
348
314b7ac7f771
[svn] - handle no account data gracefully (e.g. you only use one of the
nenolod
parents:
344
diff
changeset
|
1036 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1037 if (sc_hs_status) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1038 return; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1039 if (sc_hs_timeout < time(NULL)) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1040 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1041 sc_handshake(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1042 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1043 if(sc_hs_errors) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1044 { |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1045 if(sc_hs_errors < 5) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1046 /* Retry after 60 seconds */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1047 wait = 60; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1048 else |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1049 wait = /* sc_submit_interval + */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1050 ( ((sc_hs_errors - 5) < 7) ? |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1051 (60 << (sc_hs_errors-5)) : |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1052 7200 ); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1053 sc_hs_timeout = time(NULL) + wait; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1054 pdebug(fmt_vastr("Error while handshaking. Retrying " |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1055 "after %d seconds.", wait), DEBUG); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1056 } |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1057 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1058 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1059 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1060 /**** Public *****/ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1061 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1062 /* Called at session startup*/ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1063 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1064 void sc_init(char *uname, char *pwd) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1065 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1066 sc_hs_status = sc_hs_timeout = sc_hs_errors = sc_submit_timeout = |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1067 sc_srv_res_size = sc_giveup = sc_major_error_present = |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1068 sc_bad_users = sc_sb_errors = 0; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1069 sc_submit_interval = 1; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1070 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1071 sc_submit_url = sc_username = sc_password = sc_srv_res = |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1072 sc_challenge_hash = sc_major_error = NULL; |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1073 sc_username = strdup(uname); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1074 sc_password = strdup(pwd); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1075 read_cache(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1076 pdebug("scrobbler starting up", DEBUG); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1077 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1078 |
1443
f4d8082668c1
scrobbler: tuple API update
William Pitcock <nenolod@atheme-project.org>
parents:
1172
diff
changeset
|
1079 void sc_addentry(GMutex *mutex, Tuple *tuple, int len) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1080 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1081 g_mutex_lock(mutex); |
1029
a33470329dbe
[svn] - NP pings apparently do not affect musical profile, so queue tracks for submission
nenolod
parents:
1028
diff
changeset
|
1082 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1083 sc_submit_np(tuple); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1084 set_np(tuple, len); |
1029
a33470329dbe
[svn] - NP pings apparently do not affect musical profile, so queue tracks for submission
nenolod
parents:
1028
diff
changeset
|
1085 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1086 /* |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1087 * This will help make sure the queue will be saved on a nasty |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1088 * segfault... |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1089 */ |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1090 dump_queue(); |
1029
a33470329dbe
[svn] - NP pings apparently do not affect musical profile, so queue tracks for submission
nenolod
parents:
1028
diff
changeset
|
1091 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1092 g_mutex_unlock(mutex); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1093 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1094 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1095 /* Call periodically from the plugin */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1096 int sc_idle(GMutex *mutex) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1097 { |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1098 sc_checkhandshake(); |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1099 if (sc_hs_status) |
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1100 sc_handlequeue(mutex); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1101 |
2441
166397a7efe1
Fixes for scrobbler plugin - skipped tracks, inappropriate scrobbling, re-tabs (Bugzilla #200)
CJ Kucera <pez@apocalyptech.com>
parents:
2317
diff
changeset
|
1102 return sc_giveup; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1103 } |