changeset 1236:fc478bfe6fe6 trunk

[svn] - disconnect the scrobbler client from metatag logically
author nenolod
date Wed, 14 Jun 2006 22:30:04 -0700
parents 7918849bad3e
children 17630223d25b
files ChangeLog Plugins/General/scrobbler/queue.c Plugins/General/scrobbler/queue.h Plugins/General/scrobbler/scrobbler.c Plugins/General/scrobbler/scrobbler.h Plugins/General/scrobbler/xmms_scrobbler.c
diffstat 6 files changed, 61 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jun 14 22:17:20 2006 -0700
+++ b/ChangeLog	Wed Jun 14 22:30:04 2006 -0700
@@ -1,3 +1,15 @@
+2006-06-15 05:17:20 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [1384]
+  - more sanity for input_get_song_tuple()
+  - playlist_get_tuple(gint pos)
+  
+
+  Changes:        Modified:
+  +3 -0           trunk/audacious/input.c  
+  +28 -0          trunk/audacious/playlist.c  
+  +1 -0           trunk/audacious/playlist.h  
+
+
 2006-06-15 05:08:37 +0000  William Pitcock <nenolod@nenolod.net>
   revision [1382]
   - get_song_tuple implementation
--- a/Plugins/General/scrobbler/queue.c	Wed Jun 14 22:17:20 2006 -0700
+++ b/Plugins/General/scrobbler/queue.c	Wed Jun 14 22:30:04 2006 -0700
@@ -22,23 +22,30 @@
 	free(item);
 }
 
-void q_put(metatag_t *meta, int len)
+void q_put(TitleInput *tuple, int len)
 {
 	item_t *item;
-		
+
 	item = malloc(sizeof(item_t));
-	item->artist = fmt_escape((char*)meta->artist);
-	item->title = fmt_escape((char*)meta->title);
+
+	item->artist = fmt_escape(tuple->performer);
+	item->title = fmt_escape(tuple->track_name);
 	item->utctime = fmt_escape(fmt_timestr(time(NULL), 1));
 	snprintf(item->len, sizeof(item->len), "%d", len);
-	if(meta->mb == NULL)
+
+#ifdef NOTYET
+	if(tuple->mb == NULL)
+#endif
 		item->mb = fmt_escape("");
+#ifdef NOTYET
 	else
-		item->mb = fmt_escape((char*)meta->mb);
-	if(meta->album == NULL)
+		item->mb = fmt_escape((char*)tuple->mb);
+#endif
+
+	if(tuple->album_name == NULL)
 		item->album = fmt_escape("");
 	else
-		item->album = fmt_escape((char*)meta->album);
+		item->album = fmt_escape((char*)tuple->album_name);
 
 	q_nitems++;
 
--- a/Plugins/General/scrobbler/queue.h	Wed Jun 14 22:17:20 2006 -0700
+++ b/Plugins/General/scrobbler/queue.h	Wed Jun 14 22:30:04 2006 -0700
@@ -1,6 +1,8 @@
 #ifndef QUEUE_H
 #define QUEUE_H 1
 
+#include "libaudacious/titlestring.h"
+
 #define I_ARTIST(i) i->artist
 #define I_TITLE(i) i->title
 #define I_TIME(i) i->utctime
@@ -18,7 +20,7 @@
 	int numtries;
 	void *next;
 } item_t;
-void q_put(metatag_t *, int);
+void q_put(TitleInput *, int);
 item_t *q_put2(char *, char *, char *, char *, char *, char *);
 item_t *q_peek(void);
 item_t *q_peekall(int);
--- a/Plugins/General/scrobbler/scrobbler.c	Wed Jun 14 22:17:20 2006 -0700
+++ b/Plugins/General/scrobbler/scrobbler.c	Wed Jun 14 22:30:04 2006 -0700
@@ -737,10 +737,10 @@
 	pdebug("scrobbler starting up", DEBUG);
 }
 
-void sc_addentry(GMutex *mutex, metatag_t *meta, int len)
+void sc_addentry(GMutex *mutex, TitleInput *tuple, int len)
 {
 	g_mutex_lock(mutex);
-	q_put(meta, len);
+	q_put(tuple, len);
 	/*
 	 * This will help make sure the queue will be saved on a nasty
 	 * segfault...
--- a/Plugins/General/scrobbler/scrobbler.h	Wed Jun 14 22:17:20 2006 -0700
+++ b/Plugins/General/scrobbler/scrobbler.h	Wed Jun 14 22:30:04 2006 -0700
@@ -1,9 +1,11 @@
 #ifndef NET_H
 #define NET_H 1
 
+#include "libaudacious/titlestring.h"
+
 int sc_idle(GMutex *);
 void sc_init(char *, char *);
-void sc_addentry(GMutex *, metatag_t *, int);
+void sc_addentry(GMutex *, TitleInput *, int);
 void sc_cleaner(void);
 int sc_catch_error(void);
 char *sc_fetch_error(void);
--- a/Plugins/General/scrobbler/xmms_scrobbler.c	Wed Jun 14 22:17:20 2006 -0700
+++ b/Plugins/General/scrobbler/xmms_scrobbler.c	Wed Jun 14 22:30:04 2006 -0700
@@ -8,6 +8,7 @@
 
 #include <audacious/plugin.h>
 #include <audacious/prefswin.h>
+#include <audacious/playlist.h>
 #include <libaudacious/configdb.h>
 #include <libaudacious/beepctrl.h>
 
@@ -367,9 +368,12 @@
 
 static void *xs_thread(void *data __attribute__((unused)))
 {
-	int run = 1, i;
+	int run = 1;
+#if 0
+	int i;
 	char *charpos, *dirname;
 	gboolean direxists;
+#endif
 	submit_t dosubmit;
 	
 	while (run) {
@@ -384,12 +388,31 @@
 		dosubmit = get_song_status();
 
 		if(dosubmit.dosubmit) {
+#if 0
 			char *fname, /**title, *artist,*/ *tmp = NULL; /**sep*/
 			int track = 0;
 			metatag_t *meta;
+#endif
+			TitleInput *tuple;
 
 			pdebug("Submitting song.", DEBUG);
-			
+
+			tuple = playlist_get_tuple(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);
+				sc_addentry(m_scrobbler, tuple,
+					dosubmit.len/1000);
+			}
+			else
+				pdebug("tuple does not contain an artist or a title, not submitting.", DEBUG);
+#if 0			
 			meta = metatag_new();
 
 			fname = xmms_remote_get_playlist_file(0,dosubmit.pos_c);
@@ -469,6 +492,7 @@
 			/* g_free(tmp); */
 			g_free(fname);
 			metatag_delete(meta);
+#endif
 		}
 		g_mutex_lock(m_scrobbler);
 		run = going;