18 from os.path
import dirname, abspath
25 sys.path.append(abspath(dirname(__file__)))
26 Mopidy = __import__(
'mopidypost').Mopidy
32 Callback method to connect to mopidy if server is not available 35 url =
'http://localhost:6680' 36 if self.
config is not None:
37 url = self.config.get(
'url', url)
42 LOG.debug(
'Could not connect to server, will retry quietly')
45 self.bus.emit(
Message(
'MopidyServiceConnect'))
48 LOG.info(
'Connected to mopidy server')
50 def __init__(self, config, bus, name='mopidy'):
57 self.bus.on(
'MopidyServiceConnect', self.
_connect)
58 self.bus.emit(
Message(
'MopidyServiceConnect'))
62 Return supported uri's if mopidy server is found, 63 otherwise return empty list indicating this service 64 doesn't support anything. 67 return [
'file',
'http',
'https',
'local',
'spotify',
'gmusic']
72 self.mopidy.clear_list()
75 self.mopidy.add_list(tracks)
77 def play(self, repeat=False):
80 TODO: Add repeat support. 85 if self.mopidy.is_playing():
86 self.mopidy.clear_list()
102 self.mopidy.previous()
105 self.mopidy.lower_volume()
108 self.mopidy.restore_volume()
111 info = self.mopidy.currently_playing()
113 ret[
'name'] = info.get(
'name',
'')
115 ret[
'artist'] = info[
'album'][
'artists'][0][
'name']
116 ret[
'album'] = info[
'album'].
get(
'name',
'')
124 backends = base_config.get(
'backends', [])
125 services = [(b, backends[b])
for b
in backends
126 if backends[b][
'type'] ==
'mopidy' and 127 backends[b].
get(
'active',
True)]
128 instances = [
MopidyService(s[1], bus, s[0])
for s
in services]
def play(self, repeat=False)
def _connect(self, message)
def load_service(base_config, bus)
def __init__(self, config, bus, name='mopidy')
def add_list(self, tracks)
def get(phrase, lang=None, context=None)