start_time = time.time()
server_ping = False
playlist = []
+ media_source = None
lp = 1
player_mode = 1
osc_control_mode = 0
self.logqueue = logqueue
self.m3u = m3u
- if 'station_statusfile' in station:
+ if 'station_statusfile' in self.station:
self.statusfile = station['station_statusfile']
try:
if os.path.exists(self.statusfile):
self.station_dir = self.station['station_dir']
# Media
- self.media_dir = self.station['media']['dir']
+ if 'm3u' in self.station['media'].keys():
+ if not self.station['media']['m3u'].strip() == '':
+ self.media_source = self.station['media']['m3u']
+
+ if 'dir' in self.station['media'].keys():
+ if not self.station['media']['dir'].strip() == '':
+ self.media_source = self.station['media']['dir']
+
+ if 'source' in self.station['media'].keys():
+ if not self.station['media']['source'].strip() == '':
+ self.media_source = self.station['media']['source']
+
self.media_format = self.station['media']['format']
self.shuffle_mode = int(self.station['media']['shuffle'])
self.bitrate = int(self.station['media']['bitrate'])
self.ogg_quality = int(self.station['media']['ogg_quality'])
self.samplerate = int(self.station['media']['samplerate'])
self.voices = int(self.station['media']['voices'])
- self.m3u_playlist_file = []
- if 'm3u' in self.station['media'].keys():
- self.m3u_playlist_file = self.station['media']['m3u']
# Server
if 'mountpoint' in self.station['server'].keys():
self.twitter = Twitter(self.twitter_key, self.twitter_secret)
self.twitter_mode = value
message = "received OSC message '%s' with arguments '%d'" % (path, value)
+
+ # IMPROVEMENT: The URL paths should be configurable because they're
+ # server-implementation specific
self.m3u_url = self.channel.url + '/m3u/' + self.m3u.split(os.sep)[-1]
self.feeds_url = self.channel.url + '/rss/' + self.feeds_playlist_file.split(os.sep)[-1]
self._info(message)
def get_playlist(self):
file_list = []
- if not self.m3u_playlist_file:
- for root, dirs, files in os.walk(self.media_dir):
- for file in files:
- s = file.split('.')
- ext = s[len(s)-1]
- if ext.lower() == self.channel.format and not os.sep+'.' in file:
- file_list.append(root + os.sep + file)
- file_list.sort()
- else:
- self.q.get(1)
- try:
- f = open(self.m3u_playlist_file, 'r')
+
+ try:
+ if os.path.isdir(self.media_source):
+ self.q.get(1)
try:
- for path in f.readlines():
- if '#' != path[0]:
- file_list.append(path[:-1])
+ for root, dirs, files in os.walk(self.media_source):
+ for file in files:
+ s = file.split('.')
+ ext = s[len(s)-1]
+ if ext.lower() == self.channel.format and not os.sep+'.' in file:
+ file_list.append(root + os.sep + file)
+ file_list.sort()
except:
- f.close()
- except:
- pass
- self.q.task_done()
+ pass
+ self.q.task_done()
+
+ if os.path.isfile(self.media_source):
+ self.q.get(1)
+ try:
+ f = open(self.media_source, 'r')
+ try:
+ for path in f.readlines():
+ if '#' != path[0]:
+ file_list.append(path[:-1])
+ except:
+ f.close()
+ except:
+ pass
+ self.q.task_done()
+ except:
+ pass
+
return file_list
def get_jingles(self):
self.q.task_done()
return media
else:
- mess = 'No media in media_dir!'
+ mess = 'No media in source!'
self._err(mess)
self.run_mode = 0
<!-- A path to the directory containing jingles media files.
The files have to be of the same type of the main media files. -->
<dir>/path/to/jingles</dir>
- <!-- If '1', some media will be played between each main track of the playlist. '0' does nothing. -->
+ <!-- If '1', some media will be played between each main track of the
+ playlist. '0' does nothing. -->
<mode>0</mode>
<!-- If '1', the jingle playlist will be randomized. '0' for alphanumeric order -->
<shuffle>1</shuffle>
<media>
<!-- The mean bitrate of the media -->
<bitrate>96</bitrate>
- <!-- The path to the directory containing all the media. It will be analyzed recursively. -->
- <dir>/path/to/mp3/</dir>
+ <!-- The <m3u> option is depreciated. Please use the newer <source> option. -->
+ <m3u>/path/to/m3u_file</m3u>
+ <!-- The <dir> option is depreciated. Please use the newer <source> option.
+ This option overrides the <m3u> option if both are specified. -->
+ <dir>/path/to/mp3_folder</dir>
+ <!-- The path to the folder containing audio files, or the M3U playlist file to
+ use as source audio for this station. This option overrides both the <dir>
+ and <m3u> depreciated options if they are specified. -->
+ <source>/path/to/m3u_file_or_folder</source>
<!-- The audio format of the media. Can be 'mp3' or 'ogg' -->
<format>mp3</format>
- <!-- You can also give a M3U playlist file -->
- <m3u>/path/to/m3u_file</m3u>
<!-- The ogg quality of the ogg vorbis media -->
<ogg_quality>4</ogg_quality>
<!-- The sample rate of the media -->