import Queue
import shout
import platform
+import tinyurl
from threading import Thread
from tools import *
-version = '0.3.6'
+version = '0.4'
year = datetime.datetime.now().strftime("%Y")
platform_system = platform.system()
if not os.path.exists(self.metadata_dir):
os.makedirs(self.metadata_dir)
+ # A jingle between each media
+ self.jingles_mode = 0
+ if 'jingles' in self.station:
+ self.jingles_mode = int(self.station['jingles']['mode'])
+ self.jingles_shuffle = self.station['jingles']['shuffle']
+ self.jingles_dir = self.station['jingles']['dir']
+ if self.jingles_mode == 1:
+ self.jingles_list = self.get_jingles()
+ self.jingles_length = len(self.jingles_list)
+ self.jingle_id = 0
+
+ # Relay
+ self.relay_mode = 0
+ if 'relay' in self.station:
+ self.relay_mode = int(self.station['relay']['mode'])
+ self.relay_url = self.station['relay']['url']
+
# OSC
self.osc_control_mode = 0
if 'control' in self.station:
# OSC paths and callbacks
self.osc_controller.add_method('/media/next', 'i', self.media_next_callback)
self.osc_controller.add_method('/media/relay', 'i', self.relay_callback)
- self.osc_controller.add_method('/mode/twitter', 'i', self.twitter_callback)
- self.osc_controller.add_method('/mode/jingles', 'i', self.jingles_callback)
+ self.osc_controller.add_method('/twitter', 'i', self.twitter_callback)
+ self.osc_controller.add_method('/jingles', 'i', self.jingles_callback)
# Twitter
self.twitter_mode = 0
+ self.tinyurl = tinyurl.create_one(self.channel.url + '/m3u/' + self.m3u.split(os.sep)[-1])
if 'twitter' in self.station:
self.twitter_mode = int(self.station['twitter']['mode'])
self.twitter_user = self.station['twitter']['user']
self.twitter_pass = self.station['twitter']['pass']
- if self.twitter_mode == 1:
- self.twitter = Twitter(self.twitter_user, self.twitter_pass)
- self.twitter_tags = self.station['twitter']['tags'].split(' ')
- import tinyurl
- self.tinyurl = tinyurl.create_one(self.channel.url + '/m3u/' + self.m3u.split(os.sep)[-1])
-
- # A jingle between each media
- self.jingles_mode = 0
- if 'jingles' in self.station:
- self.jingles_mode = int(self.station['jingles']['mode'])
- self.jingles_shuffle = self.station['jingles']['shuffle']
- self.jingles_dir = self.station['jingles']['dir']
- if self.jingles_mode == 1:
- self.jingles_list = self.get_jingles()
- self.jingles_length = len(self.jingles_list)
- self.jingle_id = 0
-
- # Relay
- self.relay_mode = 0
- if 'relay' in self.station:
- self.relay_mode = int(self.station['relay']['mode'])
- self.relay_url = self.station['relay']['url']
+ self.twitter_tags = self.station['twitter']['tags'].split(' ')
+ self.twitter = Twitter(self.twitter_user, self.twitter_pass)
# The station's player
self.player = Player()
song = artist + ' : ' + title
song = song.encode('utf-8')
artist = artist.encode('utf-8')
- message = 'New track ! %s #%s #%s' % (song.replace('_', ' '), artist.replace(' ', ''), self.short_name)
- self.update_twitter(message)
+ if self.twitter_mode == 1:
+ message = 'New track ! %s #%s #%s' % (song.replace('_', ' '), artist.replace(' ', ''), self.short_name)
+ self.update_twitter(message)
if self.mode_shuffle == 1:
# Shake it, Fuzz it !
' : generating new playlist (' + str(self.lp) + ' tracks)')
self.update_rss(self.media_to_objs(self.playlist), self.rss_playlist_file, '(playlist)')
- if self.jingles_mode == '1' and (self.counter % 2) == 0 and not self.jingles_length == 0:
+ if self.jingles_mode == 1 and (self.counter % 2) == 0 and not self.jingles_length == 0:
media = self.jingles_list[self.jingle_id]
self.jingle_id = (self.jingle_id + 1) % self.jingles_length
else:
f.close()
def update_twitter(self, message):
- if self.twitter_mode == '1':
- 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[:113] + ' ' + self.tinyurl
+ message = message.decode('utf8')
+ self.logger.write('Twitting : "' + message + '"')
+ self.twitter.post(message)
def run(self):
while True:
self.update_rss(self.current_media_obj, self.metadata_file, '')
self.channel.set_metadata({'song': self.song, 'charset': 'utf8',})
self.update_rss(self.current_media_obj, self.rss_current_file, '(currently playing)')
- self.logger.write('DeeFuzzing this file on %s : id = %s, name = %s' \
+ self.logger.write('Deefuzzing this file on %s : id = %s, name = %s' \
% (self.short_name, self.id, self.current_media_obj[0].file_name))
self.player.set_media(self.media)
self.stream = self.player.file_read_slow()
- if not (self.jingles_mode == 1 and (self.counter % 2) == 1):
- message = 'Now playing: %s #%s #%s' % (self.song.replace('_', ' '), self.artist.replace(' ', ''), self.short_name)
+ if (not (self.jingles_mode == 1 and (self.counter % 2) == 1)) and self.twitter_mode == 1:
+ message = 'Now playing : %s #%s #%s' % (self.song.replace('_', ' '), self.artist.replace(' ', ''), self.short_name)
self.update_twitter(message)
self.q.task_done()
--- /dev/null
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2006-2009 Guillaume Pellerin
+
+# <yomguy@parisson.com>
+
+# This software is a computer program whose purpose is to stream audio
+# and video data through icecast2 servers.
+
+# This software is governed by the CeCILL license under French law and
+# abiding by the rules of distribution of free software. You can use,
+# modify and/ or redistribute the software under the terms of the CeCILL
+# license as circulated by CEA, CNRS and INRIA at the following URL
+# "http://www.cecill.info".
+
+# As a counterpart to the access to the source code and rights to copy,
+# modify and redistribute granted by the license, users are provided only
+# with a limited warranty and the software's author, the holder of the
+# economic rights, and the successive licensors have only limited
+# liability.
+
+# In this respect, the user's attention is drawn to the risks associated
+# with loading, using, modifying and/or developing or reproducing the
+# software by the user in light of its specific status of free software,
+# that may mean that it is complicated to manipulate, and that also
+# therefore means that it is reserved for developers and experienced
+# professionals having in-depth computer knowledge. Users are therefore
+# encouraged to load and test the software's suitability as regards their
+# requirements in conditions enabling the security of their systems and/or
+# data to be ensured and, more generally, to use and operate it in the
+# same conditions as regards security.
+
+# The fact that you are presently reading this means that you have had
+# knowledge of the CeCILL license and that you accept its terms.
+
+# Author: Guillaume Pellerin <yomguy@parisson.com>
+
+class Twitter:
+
+ def __init__(self, username, password):
+ import twitter
+ self.username = username
+ self.password = password
+ self.api = twitter.Api(username=self.username, password=self.password)
+
+ def post(self, message):
+ self.api.PostUpdate(message)
+
+
+++ /dev/null
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2006-2009 Guillaume Pellerin
-
-# <yomguy@parisson.com>
-
-# This software is a computer program whose purpose is to stream audio
-# and video data through icecast2 servers.
-
-# This software is governed by the CeCILL license under French law and
-# abiding by the rules of distribution of free software. You can use,
-# modify and/ or redistribute the software under the terms of the CeCILL
-# license as circulated by CEA, CNRS and INRIA at the following URL
-# "http://www.cecill.info".
-
-# As a counterpart to the access to the source code and rights to copy,
-# modify and redistribute granted by the license, users are provided only
-# with a limited warranty and the software's author, the holder of the
-# economic rights, and the successive licensors have only limited
-# liability.
-
-# In this respect, the user's attention is drawn to the risks associated
-# with loading, using, modifying and/or developing or reproducing the
-# software by the user in light of its specific status of free software,
-# that may mean that it is complicated to manipulate, and that also
-# therefore means that it is reserved for developers and experienced
-# professionals having in-depth computer knowledge. Users are therefore
-# encouraged to load and test the software's suitability as regards their
-# requirements in conditions enabling the security of their systems and/or
-# data to be ensured and, more generally, to use and operate it in the
-# same conditions as regards security.
-
-# The fact that you are presently reading this means that you have had
-# knowledge of the CeCILL license and that you accept its terms.
-
-# Author: Guillaume Pellerin <yomguy@parisson.com>
-
-class Twitter:
-
- def __init__(self, username, password):
- import twitter
- self.username = username
- self.password = password
- self.api = twitter.Api(username=self.username, password=self.password)
-
- def post(self, message):
- try:
- self.api.PostUpdate(message)
- except:
- pass
-