]> git.parisson.com Git - deefuzzer.git/commitdiff
fix twitter posting, few bugs
authorGuillaume Pellerin <yomguy@parisson.com>
Thu, 20 May 2010 11:50:52 +0000 (11:50 +0000)
committerGuillaume Pellerin <yomguy@parisson.com>
Thu, 20 May 2010 11:50:52 +0000 (11:50 +0000)
tools/osc_next.py [deleted file]
tools/osc_player_next.py [new file with mode: 0644]
tools/station.py

diff --git a/tools/osc_next.py b/tools/osc_next.py
deleted file mode 100644 (file)
index 21a91ee..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import liblo, sys
-
-# send all messages to port 1234 on the local machine
-try:
-    target = liblo.Address(1234)
-except liblo.AddressError, err:
-    sys.exit(err)
-
-# send message "/foo/message1" with int, float and string arguments
-liblo.send(target, "/media/next", 1)
diff --git a/tools/osc_player_next.py b/tools/osc_player_next.py
new file mode 100644 (file)
index 0000000..21a91ee
--- /dev/null
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import liblo, sys
+
+# send all messages to port 1234 on the local machine
+try:
+    target = liblo.Address(1234)
+except liblo.AddressError, err:
+    sys.exit(err)
+
+# send message "/foo/message1" with int, float and string arguments
+liblo.send(target, "/media/next", 1)
index c673931bc16593244a48f648a2fe98970755b06e..db66c5a242051bfe4b3d6686155c21dab93a78aa 100644 (file)
@@ -197,9 +197,9 @@ class Station(Thread):
     def twitter_callback(self, path, value):
         value = value[0]
         self.twitter_mode = value
-        self.tinyurl = tinyurl.create_one(self.channel.url + '/m3u/' + self.m3u.split(os.sep)[-1])
         message = "Received OSC message '%s' with arguments '%d'" % (path, value)
-        self.tinyurl = tinyurl.create_one(self.channel.url + '/m3u/' + self.m3u.split(os.sep)[-1])
+        self.m3u_tinyurl = tinyurl.create_one(self.channel.url + '/m3u/' + self.m3u.split(os.sep)[-1])
+        self.rss_tinyurl = tinyurl.create_one(self.channel.url + '/rss/' + self.rss_playlist_file.split(os.sep)[-1])
         self.logger.write(message)
 
     def jingles_callback(self, path, value):
@@ -293,7 +293,9 @@ class Station(Thread):
                         if self.twitter_mode == 1:
                             artist_names = artist.split(' ')
                             artist_tags = ' #'.join(list(set(artist_names)-set(['&', '-'])))
-                            message = '#newtrack ! %s #%s on #%s' % (song.replace('_', ' '), artist_tags, self.short_name)
+                            message = '#newtrack ! %s #%s on #%s RSS : ' % (song.replace('_', ' '), artist_tags, self.short_name)
+                            message = message[:113] + self.rss_tinyurl
+                            message = message.decode('utf8')
                             self.update_twitter(message)
 
                 if self.shuffle_mode == 1:
@@ -395,12 +397,16 @@ class Station(Thread):
             artist_names = self.artist.split(' ')
             artist_tags = ' #'.join(list(set(artist_names)-set(['&', '-'])))
             message = '♫ %s %s on #%s #%s' % (self.prefix, self.song, self.short_name, artist_tags)
-        tags = '#' + ' #'.join(self.twitter_tags)
-        message = message + ' ' + tags
-        message = message[:113] + ' ' + self.tinyurl
-        message = message.decode('utf8')
-        self.logger.write('Twitting : "' + message + '"')
-        self.twitter.post(message)
+            tags = '#' + ' #'.join(self.twitter_tags)
+            message = message + ' ' + tags
+            message = message[:107] + ' M3U : ' + self.m3u_tinyurl
+            message = message.decode('utf8')
+        try:
+            self.twitter.post(message)
+            self.logger.write('Twitting : "' + message + '"')
+        except:
+            self.logger.write('ERROR Twitting : "' + message + '"')
+            pass
 
     def set_relay_mode(self):
         self.prefix = '#nowplaying (relaying *LIVE*) :'