diff options
author | waker <wakeroid@gmail.com> | 2009-08-28 22:16:44 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2009-08-28 22:16:44 +0200 |
commit | 6cbf2a0e521d827495ca8979f84e0c4b4cae65b5 (patch) | |
tree | d6dafba1efd8b6891e8c9079e2e044779f634529 /plugins/lastfm | |
parent | a1146a1ce3983d05fed52d7a763e79856dcc6f9b (diff) |
lastfm plugin WIP
Diffstat (limited to 'plugins/lastfm')
-rw-r--r-- | plugins/lastfm/lastfm.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/plugins/lastfm/lastfm.c b/plugins/lastfm/lastfm.c index d0f53d48..6c8b2896 100644 --- a/plugins/lastfm/lastfm.c +++ b/plugins/lastfm/lastfm.c @@ -24,6 +24,7 @@ #include "../../deadbeef.h" #define TESTMODE 1 +#define LFM_IGNORE_RULES 0 static DB_misc_t plugin; static DB_functions_t *deadbeef; @@ -292,6 +293,7 @@ lastfm_songfinished (DB_event_song_t *ev, uintptr_t data) { return 0; } +#if !LFM_IGNORE_RULES // check submission rules // must be played for >=240sec of half the total time if (ev->song->playtime < 240 && ev->song->playtime < ev->song->duration/2) { @@ -302,6 +304,7 @@ lastfm_songfinished (DB_event_song_t *ev, uintptr_t data) { if (ev->song->duration < 30) { return 0; } +#endif deadbeef->mutex_lock (lfm_mutex); // find free place in queue @@ -340,21 +343,24 @@ lfm_send_nowplaying (void) { static void lfm_send_submissions (void) { - if (auth () < 0) { - return; - } for (;;) { int i; - deadbeef->mutex_lock (lfm_mutex); +// deadbeef->mutex_lock (lfm_mutex); for (i = 0; i < LFM_SUBMISSION_QUEUE_SIZE; i++) { if (lfm_subm_queue[i][0]) { break; } } - deadbeef->mutex_unlock (lfm_mutex); +// deadbeef->mutex_unlock (lfm_mutex); if (i == LFM_SUBMISSION_QUEUE_SIZE) { break; } + if (auth () < 0) { + break; + } + char s[100]; + snprintf (s, sizeof (s), "&s=%s", lfm_sess); + strcat (lfm_subm_queue[i], s); int status = curl_req_send (lfm_submission_url, lfm_subm_queue[i]); if (!status) { if (strncmp (lfm_reply, "OK", 2)) { @@ -362,9 +368,10 @@ lfm_send_submissions (void) { lfm_sess[0] = 0; } else { - deadbeef->mutex_lock (lfm_mutex); + fprintf (stderr, "submission successful, response:\n%s\n", lfm_reply); +// deadbeef->mutex_lock (lfm_mutex); lfm_subm_queue[i][0] = 0; - deadbeef->mutex_unlock (lfm_mutex); +// deadbeef->mutex_unlock (lfm_mutex); } } curl_req_cleanup (); |