XML von Soundtouchgeräten auslesen und durchsuchen
This commit is contained in:
parent
ad5460501f
commit
c50afd3a7a
1 changed files with 39 additions and 0 deletions
39
Soundtouch.py
Normal file
39
Soundtouch.py
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
class soundtouch():
|
||||||
|
def __init__(self):
|
||||||
|
self.url="http://10.0.1.27:8090/"
|
||||||
|
def Webaufruf(self,befehl):
|
||||||
|
try:
|
||||||
|
self.urli=self.url+befehl
|
||||||
|
antwort = urllib.request.urlopen(self.urli)
|
||||||
|
b = (antwort.read())
|
||||||
|
self.xmlString = b.decode("utf-8")
|
||||||
|
return self.xmlString
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
def now_playing(self):
|
||||||
|
return self.Webaufruf("now_playing")
|
||||||
|
return antwort
|
||||||
|
def info(self):
|
||||||
|
return self.Webaufruf("info")
|
||||||
|
def sources(self):
|
||||||
|
return self.Webaufruf("sources")
|
||||||
|
def presets(self):
|
||||||
|
return self.Webaufruf("presets")
|
||||||
|
def volume(self):
|
||||||
|
return self.Webaufruf("volume")
|
||||||
|
def suche (self,suchstring):
|
||||||
|
string = self.info()
|
||||||
|
anfang = string.find("<"+suchstring+">") + len("<"+suchstring+">")
|
||||||
|
ende = string.find("</"+suchstring+">")
|
||||||
|
if ende != -1:
|
||||||
|
return string[anfang:ende]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
bose=soundtouch()
|
||||||
|
print(bose.info())
|
||||||
|
print(bose.volume())
|
||||||
|
print(bose.now_playing())
|
||||||
|
print(bose.suche("serialNumber"))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue