From: Guillaume Pellerin Date: Thu, 20 May 2010 11:50:52 +0000 (+0000) Subject: fix twitter posting, few bugs X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=d44a2e5f08e7a570bddb9ef3ca37bb4af2cb0ca6;p=deefuzzer.git fix twitter posting, few bugs --- diff --git a/tools/osc_next.py b/tools/osc_next.py deleted file mode 100644 index 21a91ee..0000000 --- a/tools/osc_next.py +++ /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 index 0000000..21a91ee --- /dev/null +++ b/tools/osc_player_next.py @@ -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) diff --git a/tools/station.py b/tools/station.py index c673931..db66c5a 100644 --- a/tools/station.py +++ b/tools/station.py @@ -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*) :'