1 /*****************************************************************************
2 * audioscrobbler.c : audioscrobbler submission plugin
3 *****************************************************************************
4 * Copyright © 2006-2011 the VideoLAN team
7 * Author: Rafaël Carré <funman at videolanorg>
8 * Ilkka Ollakka <ileoo at videolan org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /* audioscrobbler protocol version: 1.2
26 * http://www.audioscrobbler.net/development/protocol/
28 * TODO: "Now Playing" feature (not mandatory)
29 * Update to new API? http://www.lastfm.fr/api
31 /*****************************************************************************
33 *****************************************************************************/
41 #include <vlc_common.h>
42 #include <vlc_plugin.h>
43 #include <vlc_interface.h>
44 #include <vlc_dialog.h>
47 #include <vlc_stream.h>
49 #include <vlc_network.h>
50 #include <vlc_playlist.h>
52 /*****************************************************************************
54 *****************************************************************************/
58 /* Keeps track of metadata to be submitted */
59 typedef struct audioscrobbler_song_t
61 char *psz_a; /**< track artist */
62 char *psz_t; /**< track title */
63 char *psz_b; /**< track album */
64 char *psz_n; /**< track number */
65 int i_l; /**< track length */
66 char *psz_m; /**< musicbrainz id */
67 time_t date; /**< date since epoch */
68 mtime_t i_start; /**< playing start */
69 } audioscrobbler_song_t;
73 audioscrobbler_song_t p_queue[QUEUE_MAX]; /**< songs not submitted yet*/
74 int i_songs; /**< number of songs */
76 vlc_mutex_t lock; /**< p_sys mutex */
77 vlc_cond_t wait; /**< song to submit event */
79 /* submission of played songs */
80 char *psz_submit_host; /**< where to submit data */
81 int i_submit_port; /**< port to which submit */
82 char *psz_submit_file; /**< file to which submit */
84 /* submission of playing song */
86 char *psz_nowp_host; /**< where to submit data */
87 int i_nowp_port; /**< port to which submit */
88 char *psz_nowp_file; /**< file to which submit */
90 char psz_auth_token[33]; /**< Authentication token */
92 /* data about song currently playing */
93 audioscrobbler_song_t p_current_song; /**< song being played */
95 mtime_t time_pause; /**< time when vlc paused */
96 mtime_t time_total_pauses; /**< total time in pause */
98 bool b_submit; /**< do we have to submit ? */
100 bool b_state_cb; /**< if we registered the
101 * "state" callback */
103 bool b_meta_read; /**< if we read the song's
104 * metadata already */
107 static int Open (vlc_object_t *);
108 static void Close (vlc_object_t *);
109 static void Run (intf_thread_t *);
111 /*****************************************************************************
113 ****************************************************************************/
115 #define USERNAME_TEXT N_("Username")
116 #define USERNAME_LONGTEXT N_("The username of your last.fm account")
117 #define PASSWORD_TEXT N_("Password")
118 #define PASSWORD_LONGTEXT N_("The password of your last.fm account")
119 #define URL_TEXT N_("Scrobbler URL")
120 #define URL_LONGTEXT N_("The URL set for an alternative scrobbler engine")
122 /* This error value is used when last.fm plugin has to be unloaded. */
123 #define VLC_AUDIOSCROBBLER_EFATAL -69
125 /* last.fm client identifier */
126 #define CLIENT_NAME PACKAGE
127 #define CLIENT_VERSION VERSION
130 set_category(CAT_INTERFACE)
131 set_subcategory(SUBCAT_INTERFACE_CONTROL)
132 set_shortname(N_("Audioscrobbler"))
133 set_description(N_("Submission of played songs to last.fm"))
134 add_string("lastfm-username", "",
135 USERNAME_TEXT, USERNAME_LONGTEXT, false)
136 add_password("lastfm-password", "",
137 PASSWORD_TEXT, PASSWORD_LONGTEXT, false)
138 add_string("scrobbler-url", "post.audioscrobbler.com",
139 URL_TEXT, URL_LONGTEXT, false)
140 set_capability("interface", 0)
141 set_callbacks(Open, Close)
144 /*****************************************************************************
145 * DeleteSong : Delete the char pointers in a song
146 *****************************************************************************/
147 static void DeleteSong(audioscrobbler_song_t* p_song)
149 FREENULL(p_song->psz_a);
150 FREENULL(p_song->psz_b);
151 FREENULL(p_song->psz_t);
152 FREENULL(p_song->psz_m);
153 FREENULL(p_song->psz_n);
156 /*****************************************************************************
157 * ReadMetaData : Read meta data when parsed by vlc
158 *****************************************************************************/
159 static void ReadMetaData(intf_thread_t *p_this)
161 input_thread_t *p_input;
162 input_item_t *p_item;
164 intf_sys_t *p_sys = p_this->p_sys;
166 p_input = playlist_CurrentInput(pl_Get(p_this));
170 p_item = input_GetItem(p_input);
173 vlc_object_release(p_input);
177 #define ALLOC_ITEM_META(a, b) do { \
178 char *psz_meta = input_item_Get##b(p_item); \
179 if (psz_meta && *psz_meta) \
180 a = encode_URI_component(psz_meta); \
184 vlc_mutex_lock(&p_sys->lock);
186 p_sys->b_meta_read = true;
188 ALLOC_ITEM_META(p_sys->p_current_song.psz_a, Artist);
189 if (!p_sys->p_current_song.psz_a)
191 msg_Dbg(p_this, "No artist..");
192 DeleteSong(&p_sys->p_current_song);
196 ALLOC_ITEM_META(p_sys->p_current_song.psz_t, Title);
197 if (!p_sys->p_current_song.psz_t)
199 msg_Dbg(p_this, "No track name..");
200 DeleteSong(&p_sys->p_current_song);
204 /* Now we have read the mandatory meta data, so we can submit that info */
205 p_sys->b_submit = true;
207 ALLOC_ITEM_META(p_sys->p_current_song.psz_b, Album);
208 if (!p_sys->p_current_song.psz_b)
209 p_sys->p_current_song.psz_b = calloc(1, 1);
211 ALLOC_ITEM_META(p_sys->p_current_song.psz_m, TrackID);
212 if (!p_sys->p_current_song.psz_m)
213 p_sys->p_current_song.psz_m = calloc(1, 1);
215 p_sys->p_current_song.i_l = input_item_GetDuration(p_item) / 1000000;
217 ALLOC_ITEM_META(p_sys->p_current_song.psz_n, TrackNum);
218 if (!p_sys->p_current_song.psz_n)
219 p_sys->p_current_song.psz_n = calloc(1, 1);
220 #undef ALLOC_ITEM_META
222 msg_Dbg(p_this, "Meta data registered");
225 vlc_mutex_unlock(&p_sys->lock);
226 vlc_object_release(p_input);
229 /*****************************************************************************
230 * AddToQueue: Add the played song to the queue to be submitted
231 *****************************************************************************/
232 static void AddToQueue (intf_thread_t *p_this)
235 intf_sys_t *p_sys = p_this->p_sys;
237 vlc_mutex_lock(&p_sys->lock);
238 if (!p_sys->b_submit)
241 /* wait for the user to listen enough before submitting */
242 played_time = mdate() - p_sys->p_current_song.i_start -
243 p_sys->time_total_pauses;
244 played_time /= 1000000; /* µs → s */
246 /*HACK: it seam that the preparsing sometime fail,
247 so use the playing time as the song length */
248 if (p_sys->p_current_song.i_l == 0)
249 p_sys->p_current_song.i_l = played_time;
251 /* Don't send song shorter than 30s */
252 if (p_sys->p_current_song.i_l < 30)
254 msg_Dbg(p_this, "Song too short (< 30s), not submitting");
258 /* Send if the user had listen more than 240s OR half the track length */
259 if ((played_time < 240) &&
260 (played_time < (p_sys->p_current_song.i_l / 2)))
262 msg_Dbg(p_this, "Song not listened long enough, not submitting");
266 /* Check that all meta are present */
267 if (!p_sys->p_current_song.psz_a || !*p_sys->p_current_song.psz_a ||
268 !p_sys->p_current_song.psz_t || !*p_sys->p_current_song.psz_t)
270 msg_Dbg(p_this, "Missing artist or title, not submitting");
274 if (p_sys->i_songs >= QUEUE_MAX)
276 msg_Warn(p_this, "Submission queue is full, not submitting");
280 msg_Dbg(p_this, "Song will be submitted.");
282 #define QUEUE_COPY(a) \
283 p_sys->p_queue[p_sys->i_songs].a = p_sys->p_current_song.a
285 #define QUEUE_COPY_NULL(a) \
287 p_sys->p_current_song.a = NULL
290 QUEUE_COPY_NULL(psz_n);
291 QUEUE_COPY_NULL(psz_a);
292 QUEUE_COPY_NULL(psz_t);
293 QUEUE_COPY_NULL(psz_b);
294 QUEUE_COPY_NULL(psz_m);
296 #undef QUEUE_COPY_NULL
301 /* signal the main loop we have something to submit */
302 vlc_cond_signal(&p_sys->wait);
305 DeleteSong(&p_sys->p_current_song);
306 p_sys->b_submit = false;
307 vlc_mutex_unlock(&p_sys->lock);
310 /*****************************************************************************
311 * PlayingChange: Playing status change callback
312 *****************************************************************************/
313 static int PlayingChange(vlc_object_t *p_this, const char *psz_var,
314 vlc_value_t oldval, vlc_value_t newval, void *p_data)
318 intf_thread_t *p_intf = (intf_thread_t*) p_data;
319 intf_sys_t *p_sys = p_intf->p_sys;
320 input_thread_t *p_input = (input_thread_t*)p_this;
325 if (newval.i_int != INPUT_EVENT_STATE) return VLC_SUCCESS;
327 if (var_CountChoices(p_input, "video-es"))
329 msg_Dbg(p_this, "Not an audio-only input, not submitting");
333 state = var_GetInteger(p_input, "state");
335 if (!p_sys->b_meta_read && state >= PLAYING_S)
337 ReadMetaData(p_intf);
344 else if (state == PAUSE_S)
345 p_sys->time_pause = mdate();
346 else if (p_sys->time_pause > 0 && state == PLAYING_S)
348 p_sys->time_total_pauses += (mdate() - p_sys->time_pause);
349 p_sys->time_pause = 0;
355 /*****************************************************************************
356 * ItemChange: Playlist item change callback
357 *****************************************************************************/
358 static int ItemChange(vlc_object_t *p_this, const char *psz_var,
359 vlc_value_t oldval, vlc_value_t newval, void *p_data)
361 input_thread_t *p_input;
362 intf_thread_t *p_intf = (intf_thread_t*) p_data;
363 intf_sys_t *p_sys = p_intf->p_sys;
364 input_item_t *p_item;
366 VLC_UNUSED(p_this); VLC_UNUSED(psz_var);
367 VLC_UNUSED(oldval); VLC_UNUSED(newval);
369 p_sys->b_state_cb = false;
370 p_sys->b_meta_read = false;
371 p_sys->b_submit = false;
373 p_input = playlist_CurrentInput(pl_Get(p_intf));
375 if (!p_input || p_input->b_dead)
378 p_item = input_GetItem(p_input);
381 vlc_object_release(p_input);
385 if (var_CountChoices(p_input, "video-es"))
387 msg_Dbg(p_this, "Not an audio-only input, not submitting");
388 vlc_object_release(p_input);
392 p_sys->time_total_pauses = 0;
393 time(&p_sys->p_current_song.date); /* to be sent to last.fm */
394 p_sys->p_current_song.i_start = mdate(); /* only used locally */
396 var_AddCallback(p_input, "intf-event", PlayingChange, p_intf);
397 p_sys->b_state_cb = true;
399 if (input_item_IsPreparsed(p_item))
400 ReadMetaData(p_intf);
401 /* if the input item was not preparsed, we'll do it in PlayingChange()
402 * callback, when "state" == PLAYING_S */
404 vlc_object_release(p_input);
408 /*****************************************************************************
409 * Open: initialize and create stuff
410 *****************************************************************************/
411 static int Open(vlc_object_t *p_this)
413 intf_thread_t *p_intf = (intf_thread_t*) p_this;
414 intf_sys_t *p_sys = calloc(1, sizeof(intf_sys_t));
419 p_intf->p_sys = p_sys;
421 vlc_mutex_init(&p_sys->lock);
422 vlc_cond_init(&p_sys->wait);
424 var_AddCallback(pl_Get(p_intf), "item-current", ItemChange, p_intf);
426 p_intf->pf_run = Run;
431 /*****************************************************************************
432 * Close: destroy interface stuff
433 *****************************************************************************/
434 static void Close(vlc_object_t *p_this)
436 playlist_t *p_playlist = pl_Get(p_this);
437 input_thread_t *p_input;
438 intf_thread_t *p_intf = (intf_thread_t*) p_this;
439 intf_sys_t *p_sys = p_intf->p_sys;
441 var_DelCallback(p_playlist, "item-current", ItemChange, p_intf);
443 p_input = playlist_CurrentInput(p_playlist);
446 if (p_sys->b_state_cb)
447 var_DelCallback(p_input, "intf-event", PlayingChange, p_intf);
448 vlc_object_release(p_input);
452 for (i = 0; i < p_sys->i_songs; i++)
453 DeleteSong(&p_sys->p_queue[i]);
454 free(p_sys->psz_submit_host);
455 free(p_sys->psz_submit_file);
457 free(p_sys->psz_nowp_host);
458 free(p_sys->psz_nowp_file);
460 vlc_cond_destroy(&p_sys->wait);
461 vlc_mutex_destroy(&p_sys->lock);
466 /*****************************************************************************
467 * ParseURL : Split an http:// URL into host, file, and port
469 * Example: "62.216.251.205:80/protocol_1.2"
470 * will be split into "62.216.251.205", 80, "protocol_1.2"
472 * psz_url will be freed before returning
473 * *psz_file & *psz_host will be freed before use
476 * VLC_ENOMEM Out Of Memory
477 * VLC_EGENERIC Invalid url provided
478 * VLC_SUCCESS Success
479 *****************************************************************************/
480 static int ParseURL(char *psz_url, char **psz_host, char **psz_file,
484 size_t i_len = strlen(psz_url);
485 bool b_no_port = false;
489 i_pos = strcspn(psz_url, ":");
493 i_pos = strcspn(psz_url, "/");
497 *psz_host = strndup(psz_url, i_pos);
503 i_pos++; /* skip the ':' */
504 *i_port = atoi(psz_url + i_pos);
511 i_pos = strcspn(psz_url, "/");
517 i_pos++; /* skip the '/' */
518 *psz_file = strdup(psz_url + i_pos);
528 /*****************************************************************************
529 * Handshake : Init audioscrobbler connection
530 *****************************************************************************/
531 static int Handshake(intf_thread_t *p_this)
533 char *psz_username, *psz_password;
534 char *psz_scrobbler_url;
536 char psz_timestamp[21];
538 struct md5_s p_struct_md5;
541 char *psz_handshake_url;
542 uint8_t p_buffer[1024];
548 intf_thread_t *p_intf = (intf_thread_t*) p_this;
549 intf_sys_t *p_sys = p_this->p_sys;
551 psz_username = var_InheritString(p_this, "lastfm-username");
555 psz_password = var_InheritString(p_this, "lastfm-password");
562 /* username or password have not been setup */
563 if (!*psz_username || !*psz_password)
572 /* generates a md5 hash of the password */
573 InitMD5(&p_struct_md5);
574 AddMD5(&p_struct_md5, (uint8_t*) psz_password, strlen(psz_password));
575 EndMD5(&p_struct_md5);
579 char *psz_password_md5 = psz_md5_hash(&p_struct_md5);
580 if (!psz_password_md5)
586 snprintf(psz_timestamp, sizeof(psz_timestamp), "%"PRIu64,
587 (uint64_t)timestamp);
589 /* generates a md5 hash of :
590 * - md5 hash of the password, plus
591 * - timestamp in clear text
593 InitMD5(&p_struct_md5);
594 AddMD5(&p_struct_md5, (uint8_t*) psz_password_md5, 32);
595 AddMD5(&p_struct_md5, (uint8_t*) psz_timestamp, strlen(psz_timestamp));
596 EndMD5(&p_struct_md5);
597 free(psz_password_md5);
599 char *psz_auth_token = psz_md5_hash(&p_struct_md5);
606 psz_scrobbler_url = var_InheritString(p_this, "scrobbler-url");
607 if (!psz_scrobbler_url)
613 i_ret = asprintf(&psz_handshake_url,
614 "http://%s/?hs=true&p=1.2&c="CLIENT_NAME"&v="CLIENT_VERSION"&u=%s&t=%s&a=%s"
615 , psz_scrobbler_url, psz_username, psz_timestamp, psz_auth_token);
617 free(psz_scrobbler_url);
622 /* send the http handshake request */
623 p_stream = stream_UrlNew(p_intf, psz_handshake_url);
624 free(psz_handshake_url);
630 i_ret = stream_Read(p_stream, p_buffer, sizeof(p_buffer) - 1);
633 stream_Delete(p_stream);
636 p_buffer[i_ret] = '\0';
637 stream_Delete(p_stream);
639 p_buffer_pos = strstr((char*) p_buffer, "FAILED ");
642 /* handshake request failed, sorry */
643 msg_Err(p_this, "last.fm handshake failed: %s", p_buffer_pos + 7);
647 if (strstr((char*) p_buffer, "BADAUTH"))
649 /* authentication failed, bad username/password combination */
651 _("last.fm: Authentication failed"),
652 "%s", _("last.fm username or password is incorrect. "
653 "Please verify your settings and relaunch VLC."));
654 return VLC_AUDIOSCROBBLER_EFATAL;
657 if (strstr((char*) p_buffer, "BANNED"))
659 /* oops, our version of vlc has been banned by last.fm servers */
660 msg_Err(p_intf, "This version of VLC has been banned by last.fm. "
661 "You should upgrade VLC, or disable the last.fm plugin.");
662 return VLC_AUDIOSCROBBLER_EFATAL;
665 if (strstr((char*) p_buffer, "BADTIME"))
667 /* The system clock isn't good */
668 msg_Err(p_intf, "last.fm handshake failed because your clock is too "
669 "much shifted. Please correct it, and relaunch VLC.");
670 return VLC_AUDIOSCROBBLER_EFATAL;
673 p_buffer_pos = strstr((char*) p_buffer, "OK");
677 p_buffer_pos = strstr(p_buffer_pos, "\n");
678 if (!p_buffer_pos || strlen(p_buffer_pos) < 33)
680 p_buffer_pos++; /* we skip the '\n' */
682 /* save the session ID */
683 memcpy(p_sys->psz_auth_token, p_buffer_pos, 32);
684 p_sys->psz_auth_token[32] = '\0';
686 p_buffer_pos = strstr(p_buffer_pos, "http://");
687 if (!p_buffer_pos || strlen(p_buffer_pos) == 7)
690 /* We need to read the nowplaying url */
691 p_buffer_pos += 7; /* we skip "http://" */
693 psz_url = strndup(p_buffer_pos, strcspn(p_buffer_pos, "\n"));
697 switch(ParseURL(psz_url, &p_sys->psz_nowp_host,
698 &p_sys->psz_nowp_file, &p_sys->i_nowp_port))
709 p_buffer_pos = strstr(p_buffer_pos, "http://");
710 if (!p_buffer_pos || strlen(p_buffer_pos) == 7)
713 /* We need to read the submission url */
714 p_buffer_pos += 7; /* we skip "http://" */
715 psz_url = strndup(p_buffer_pos, strcspn(p_buffer_pos, "\n"));
719 int ret = ParseURL(psz_url, &p_sys->psz_submit_host,
720 &p_sys->psz_submit_file, &p_sys->i_submit_port);
740 msg_Err(p_intf, "Handshake: can't recognize server protocol");
744 static void HandleInterval(mtime_t *next, unsigned int *i_interval)
746 if (*i_interval == 0)
748 /* first interval is 1 minute */
753 /* else we double the previous interval, up to 120 minutes */
755 if (*i_interval > 120)
758 *next = mdate() + (*i_interval * 1000000 * 60);
761 /*****************************************************************************
762 * Run : call Handshake() then submit songs
763 *****************************************************************************/
764 static void Run(intf_thread_t *p_intf)
766 uint8_t p_buffer[1024];
767 int canc = vlc_savecancel();
768 bool b_handshaked = false;
770 /* data about audioscrobbler session */
771 mtime_t next_exchange; /**< when can we send data */
772 unsigned int i_interval; /**< waiting interval (secs)*/
774 intf_sys_t *p_sys = p_intf->p_sys;
779 vlc_restorecancel(canc);
780 vlc_mutex_lock(&p_sys->lock);
781 mutex_cleanup_push(&p_sys->lock);
784 vlc_cond_wait(&p_sys->wait, &p_sys->lock);
785 while (mdate() < next_exchange);
788 canc = vlc_savecancel();
790 /* handshake if needed */
793 msg_Dbg(p_intf, "Handshaking with last.fm ...");
795 switch(Handshake(p_intf))
801 /* username not set */
803 _("Last.fm username not set"),
804 "%s", _("Please set a username or disable the "
805 "audioscrobbler plugin, and restart VLC.\n"
806 "Visit http://www.last.fm/join/ to get an account.")
811 msg_Dbg(p_intf, "Handshake successfull :)");
814 next_exchange = mdate();
817 case VLC_AUDIOSCROBBLER_EFATAL:
818 msg_Warn(p_intf, "Exiting...");
823 /* protocol error : we'll try later */
824 HandleInterval(&next_exchange, &i_interval);
827 /* if handshake failed let's restart the loop */
832 msg_Dbg(p_intf, "Going to submit some data...");
834 if (asprintf(&psz_submit, "s=%s", p_sys->psz_auth_token) == -1)
837 /* forge the HTTP POST request */
838 vlc_mutex_lock(&p_sys->lock);
839 audioscrobbler_song_t *p_song;
840 for (int i_song = 0 ; i_song < p_sys->i_songs ; i_song++)
842 char *psz_submit_song, *psz_submit_tmp;
843 p_song = &p_sys->p_queue[i_song];
844 if (asprintf(&psz_submit_song,
854 i_song, p_song->psz_a,
855 i_song, p_song->psz_t,
856 i_song, (unsigned)p_song->date, /* HACK: %ju (uintmax_t) unsupported on Windows */
860 i_song, p_song->psz_b,
861 i_song, p_song->psz_n,
862 i_song, p_song->psz_m
864 { /* Out of memory */
865 vlc_mutex_unlock(&p_sys->lock);
868 psz_submit_tmp = psz_submit;
869 if (asprintf(&psz_submit, "%s%s",
870 psz_submit_tmp, psz_submit_song) == -1)
871 { /* Out of memory */
872 free(psz_submit_tmp);
873 free(psz_submit_song);
874 vlc_mutex_unlock(&p_sys->lock);
877 free(psz_submit_song);
878 free(psz_submit_tmp);
880 vlc_mutex_unlock(&p_sys->lock);
882 int i_post_socket = net_ConnectTCP(p_intf, p_sys->psz_submit_host,
883 p_sys->i_submit_port);
885 if (i_post_socket == -1)
887 /* If connection fails, we assume we must handshake again */
888 HandleInterval(&next_exchange, &i_interval);
889 b_handshaked = false;
894 /* we transmit the data */
895 int i_net_ret = net_Printf(p_intf, i_post_socket, NULL,
896 "POST /%s HTTP/1.1\n"
897 "Accept-Encoding: identity\n"
898 "Content-length: %zu\n"
899 "Connection: close\n"
900 "Content-type: application/x-www-form-urlencoded\n"
902 "User-agent: VLC media player/"VERSION"\r\n"
906 p_sys->psz_submit_file, strlen(psz_submit),
907 p_sys->psz_submit_host, psz_submit
913 /* If connection fails, we assume we must handshake again */
914 HandleInterval(&next_exchange, &i_interval);
915 b_handshaked = false;
919 i_net_ret = net_Read(p_intf, i_post_socket, NULL,
920 p_buffer, sizeof(p_buffer) - 1, false);
923 /* if we get no answer, something went wrong : try again */
927 net_Close(i_post_socket);
928 p_buffer[i_net_ret] = '\0';
930 char *failed = strstr((char *) p_buffer, "FAILED");
933 msg_Warn(p_intf, "%s", failed);
934 HandleInterval(&next_exchange, &i_interval);
938 if (strstr((char *) p_buffer, "BADSESSION"))
940 msg_Err(p_intf, "Authentication failed (BADSESSION), are you connected to last.fm with another program ?");
941 b_handshaked = false;
942 HandleInterval(&next_exchange, &i_interval);
946 if (strstr((char *) p_buffer, "OK"))
948 for (int i = 0; i < p_sys->i_songs; i++)
949 DeleteSong(&p_sys->p_queue[i]);
952 next_exchange = mdate();
953 msg_Dbg(p_intf, "Submission successful!");
957 msg_Err(p_intf, "Authentication failed, handshaking again (%s)",
959 b_handshaked = false;
960 HandleInterval(&next_exchange, &i_interval);
963 vlc_restorecancel(canc);