コード例 #1
0
ファイル: juice_mqtt.py プロジェクト: OldIronHorse/juice-mqtt
      'album': track.get('album', None),
      'album_id': track.get('album_id', None),
      'artist': track.get('artist', None),
      'artist_id': track.get('artist_id', None),
      'title': player.get('current_title', None), 
      'volume': player['volume'],
      'playlist': player['playlist'],
      'playlist_cur_index': player.get('playlist_cur_index', None)
  }
  last_status[player['name']] = status
  client.publish('squeezebox/players/' + player['name'],
    json.dumps(status), retain=True, qos=1)
  client.publish('squeezebox/display/' + player['name'], 
    '{}\t{}\t{}'.format(track.get('title','---'),
                        track.get('artist','---'),
                        track.get('album','---')).encode('ascii','ignore'),
    retain=True, qos=1)

if __name__ == '__main__':
  client = mqtt.Client('juice-bridge')
  client.connect('euterpe3')
  client.on_message = onMQTTMsg
  #client.on_log = lambda client,ussrdata,level,buf: print("log:",level,buf)
  client.loop_start()
  client.subscribe("squeezebox/command/#")
  server = juice.connect('euterpe3', 9090)
  players = juice.get_players(server)
  for player in players:
    server.write(msg_format.player_status(player['id'], subscribe=0, start=0, page_size=9999).encode('ascii'))
  juice.loop_start(server, onSBMsg)
コード例 #2
0
ファイル: playlists.py プロジェクト: OldIronHorse/juice
def get_status(server, player_id):
    request = msg_format.player_status(player_id, start=0, page_size=9999)
    server.write(request.encode('ascii'))
    response = server.read_until(b'\n')
    msg = parse_msg(response.decode('ascii'))
    return msg
コード例 #3
0
 def test_defaults(self):
     self.assertEqual('00:12:34:56:78:90 status - 100 tags:ales\n',
                      msg_format.player_status('00:12:34:56:78:90'))
コード例 #4
0
 def test_subscribe_defaults(self):
     self.assertEqual(
         '00:12:34:56:78:90 status - 100 tags:ales subscribe:0\n',
         msg_format.player_status('00:12:34:56:78:90', subscribe=0))
コード例 #5
0
def status(server, player_id):
  server.write(msg_format.player_status(player_id, start=0, page_size=9999).encode('ascii'))
  return parse_msg(server.read_until(b'\n').decode('ascii'))