changeset 553:269841b8fb31 trunk

[svn] - submit gerpok tracks on immediate playback begin
author nenolod
date Sat, 27 Jan 2007 06:35:52 -0800
parents 91bc67e7800b
children 7deaaa08706a
files ChangeLog src/scrobbler/plugin.c
diffstat 2 files changed, 37 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Jan 27 06:10:29 2007 -0800
+++ b/ChangeLog	Sat Jan 27 06:35:52 2007 -0800
@@ -1,3 +1,12 @@
+2007-01-27 14:10:29 +0000  Michael Farber <01mf02@gmail.com>
+  revision [1190]
+  - adapted plugin to use new formatter (without xmms_ prefix)
+  
+  
+  trunk/src/song_change/song_change.c |   32 ++++++++++++++++----------------
+  1 file changed, 16 insertions(+), 16 deletions(-)
+
+
 2007-01-26 06:52:52 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [1188]
   - change some references for long to int, reported by and patch by 
--- a/src/scrobbler/plugin.c	Sat Jan 27 06:10:29 2007 -0800
+++ b/src/scrobbler/plugin.c	Sat Jan 27 06:35:52 2007 -0800
@@ -35,7 +35,7 @@
 
 typedef struct submit_t
 {
-	int dosubmit, pos_c, len;
+	int dosubmit, pos_c, len, gerpok;
 } submit_t;
 
 static void init(void);
@@ -248,7 +248,7 @@
 	struct timeval timetmp;
 
 	/* clear dosubmit */
-	dosubmit.dosubmit = dosubmit.pos_c = dosubmit.len = 0;
+	dosubmit.dosubmit = dosubmit.pos_c = dosubmit.len = dosubmit.gerpok = 0;
 
 	/* current music number */
 	pos_c = xmms_remote_get_playlist_pos(XS_CS);
@@ -277,15 +277,6 @@
 	/* repeat setting */
 	repeat = xmms_remote_is_repeat(XS_CS);
 
-	/*
-#ifdef MAKE_XMMS
-	// advance setting (required xmms-1.2.11 or over)
-	advance = xmms_remote_is_advance(XS_CS);
-#else
-	advance = 1;
-#endif
-	*/
-
 	if( ps_p == ps_stop && ps_c == ps_stop )        playstate = stopping;
 	else if( ps_p == ps_stop && ps_c == ps_play )   playstate = start;
 	/* else if( ps_p == ps_stop && ps_c == ps_pause ) ; */
@@ -324,6 +315,7 @@
 	switch( playstate ){
 	case start:
 	  pdebug("*** START ***", SUB_DEBUG);
+	  dosubmit.gerpok = 1;
 	  break;
 	case stop:
 	  pdebug("*** STOP ***", SUB_DEBUG);
@@ -437,6 +429,9 @@
 	  }
 	}
 
+	if (playstate != start)
+		dosubmit.gerpok = 0;
+
 	g_free(file_p);
 
 	/* keep current value for next iteration */
@@ -478,6 +473,28 @@
 		/* Check for ability to submit */
 		dosubmit = get_song_status();
 
+		if(dosubmit.gerpok) {
+			TitleInput *tuple;
+
+			pdebug("Submitting song.", DEBUG);
+
+			tuple = playlist_get_tuple(playlist_get_active(), dosubmit.pos_c);
+
+			if (ishttp(tuple->file_name))
+				continue;
+
+			if(tuple->performer != NULL && tuple->track_name != NULL)
+			{
+				pdebug(fmt_vastr(
+					"submitting artist: %s, title: %s",
+					tuple->performer, tuple->track_name), DEBUG);
+				gerpok_sc_addentry(m_scrobbler, tuple,
+					dosubmit.len/1000);
+			}
+			else
+				pdebug("tuple does not contain an artist or a title, not submitting.", DEBUG);			
+		}
+
 		if(dosubmit.dosubmit) {
 			TitleInput *tuple;
 
@@ -495,8 +512,6 @@
 					tuple->performer, tuple->track_name), DEBUG);
 				sc_addentry(m_scrobbler, tuple,
 					dosubmit.len/1000);
-				gerpok_sc_addentry(m_scrobbler, tuple,
-					dosubmit.len/1000);
 				hatena_sc_addentry(m_scrobbler, tuple,
 					dosubmit.len/1000);
 			}