/usr/lib/exaile/xl/radio.py is in exaile 0.3.2.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | # Copyright (C) 2008-2010 Adam Olsen
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# The developers of the Exaile media player hereby grant permission
# for non-GPL compatible GStreamer and Exaile plugins to be used and
# distributed together with GStreamer and Exaile. This permission is
# above and beyond the permissions granted by the GPL license by which
# Exaile is covered. If you modify this code, you may extend this
# exception to your version of the code, but you are not obligated to
# do so. If you do not wish to do so, delete this exception statement
# from your version.
from xl import playlist, event, providers, trax
class RadioManager(providers.ProviderHandler):
"""
Radio Station Manager
Simple usage:
>>> manager = RadioManager()
>>> manager.add_station(RadioStation())
>>> lists = manager.get_lists('test_station')
>>> pl = lists[0].get_playlist()
>>> print pl.get_tracks()[0]['title'][0]
Test Track
>>>
"""
def __init__(self):
"""
Initializes the radio manager
"""
providers.ProviderHandler.__init__(self, "radio")
self.stations = {}
def add_station(self, station):
"""
Adds a station to the manager
@param station: The station to add
"""
providers.register(self.servicename, station)
def on_provider_added(self, station):
if not station.name in self.stations:
self.stations[station.name] = station
event.log_event('station_added', self, station)
def remove_station(self, station):
"""
Removes a station from the manager
@param station: The station to remvoe
"""
providers.unregister(self.servicename, station)
def on_provider_removed(self, station):
if station.name in self.stations:
del self.stations[station.name]
event.log_event('station_removed', self, station)
def search(self, station, keyword):
if station in self.stations:
return self.stations[station].search(keyword)
else:
return None
def get_lists(self, station, no_cache=False):
"""
Loads the lists for the specified station
@param station: The name of the station
"""
if station in self.stations:
return self.stations[station].get_lists(no_cache=no_cache)
else:
return None
def load_lists(self, station):
"""
Gets the rlists for the specified station
@param station: The name of the station
"""
if station in self.stations:
return self.stations[station].load_lists()
else:
return None
class RadioList(object):
def __init__(self, name, station=None):
"""
Initializes the rlist
"""
self.name = name
self.station = station
def set_name(self, name):
self.name = name
def get_name(self):
return self.name
def get_items(self, no_cache=False):
"""
Returns subrlists
"""
return []
def __str__(self):
"""
Returns a string representation of the list
"""
return self.name
class RadioItem(object):
"""
Radio Items
"""
def __init__(self, name, station=None):
"""
Initializes the radio item
"""
self.name = name
self.station = station
def get_playlist(self):
tr = trax.Track()
tr['title'] = 'Test Track'
pl = playlist.Playlist('Test Playlist')
pl.add_tracks([tr])
return pl
def __str__(self):
"""
Returns a string representation of the item
"""
return self.name
class RadioStation(object):
name = 'test_station'
def __init__(self):
"""
Initialize the radio station
"""
pass
def get_lists(self, no_cache=False):
"""
Returns the rlists for this radio station
"""
return [RadioItem('TestCategory')]
def search(self, keyword):
return None
def __str__(self):
"""
Returns a stream representation of this station
"""
name = self.__class__.__name__
name = name.replace('RadioStation', ' Radio')
return name
|