From 5cb409cf08b9f0c40508963f3c0abeb9d2dcb90e Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Sun, 17 Jan 2010 01:09:10 +0000 Subject: [PATCH] fix twitting new track --- tools/station.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/station.py b/tools/station.py index d767946..733a215 100644 --- a/tools/station.py +++ b/tools/station.py @@ -251,7 +251,9 @@ class Station(Thread): song = song.encode('utf-8') artist = artist.encode('utf-8') if self.twitter_mode == 1: - message = 'New track ! %s #%s #%s' % (song.replace('_', ' '), artist.replace(' ', ''), self.short_name) + artist_names = artist.split(' ') + artist_tags = ' #'.join(list(set(artist_names)-set(['&', '-']))) + message = 'New track ! %s %s on #%s' % (song.replace('_', ' '), artist_tags, self.short_name) self.update_twitter(message) if self.mode_shuffle == 1: @@ -348,10 +350,11 @@ class Station(Thread): rss.write_xml(f, 'utf-8') f.close() - def update_twitter(self): - 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) + def update_twitter(self, message=None): + if not message: + 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 -- 2.39.5