It is not a plugin, it is not real coding ... just a simple script that
may be useful for some of you

As I wanted the name of the playing file in conky, I just wrote a small
python script to query Squeezecenter via CLI

Code:
--------------------
    
  #! /usr/bin/python
  
  from telnetlib import Telnet
  from urllib import unquote
  from time import sleep
  
  def query(server, port, player, commands):
  tn = Telnet(server, port)
  
  for command in commands:
  tn.write("%s %s ?\n" % (player, command))
  
  sleep(0.2)
  feedback = tn.read_very_eager().split('\n')
  results = [(cmd,unquote(res)[len(player)+len(cmd)+2:]) \
  for cmd,res in zip(commands, feedback)]
  return dict(results)
  
  if __name__ == "__main__":
  server = "your_server" # according to your server
  port = 9090
  player = "00:XX:XX:XX:XX:XX" # according to your player
  commands = ("album", "artist", "title", "time", "duration")
  
  res = query(server, port, player, commands)
  print "%(artist)s\n%(album)s - %(title)s" % res
  print int(long(res['time'])/long(res['duration'])*100)
  
  
--------------------


conky.rc can be modified that way :

Code:
--------------------
    
  ${color #837b7b}Currently playing: $color
  ${execi 15 ~/src/current_song.py | head -n 2}
  ${execibar 15 ~/src/current_song.py | tail -n 1}
  
--------------------


Simple, but it works :)


-- 
eLR!C

BigDisk > Microclient Sr > [SBR > tweaked TA10.1 > Cabasse Farella |
SBB]
------------------------------------------------------------------------
eLR!C's Profile: http://forums.slimdevices.com/member.php?userid=19360
View this thread: http://forums.slimdevices.com/showthread.php?t=54819

_______________________________________________
discuss mailing list
[email protected]
http://lists.slimdevices.com/lists/listinfo/discuss

Reply via email to