Package: lastfmsubmitd
Version: 0.33-2
Tags: patch

When lastfmsubmitd has unsubmitted submissions in the spool dir (e.g. if
connection has been down), they get submitted in no particular order. In
fact, the order in which Python's os.listdir returns the files, which is
"in arbitrary order" (http://docs.python.org/lib/os-file-dir.html). This
triggers last.fm's spam protection, which says that songs have to be
submitted in chronological order (except in the unlikely event that the
files are in fact returned in chronological order).

This one-line patch solves this issue by sorting the spool each time it
is polled. I'm not great with python though, so I'm not completely
positive that it will always work as intended (particularly, I don't
know if the 'time' field always contains something valid and
comparable). In my testing though (using lastmp), it has worked
perfectly, in situations where it would normally fail.

-- 
Jonas Häggqvist
rasher(at)rasher(dot)dk
--- lastfmsubmitd.old   2007-02-08 20:14:44.000000000 +0100
+++ lastfmsubmitd       2007-02-08 20:13:25.000000000 +0100
@@ -104,6 +104,8 @@
                             n += 1
                     except ValueError, e:
                         self.log.warning('Invalid data, ignoring: %s' % e)
+        # Keep the entries sorted so we always submit the oldest first
+        self.subs.sort(lambda x,y: cmp(x['time'], y['time']))
         return n
 
     def sync(self):

Reply via email to