From c50afd3a7a79b5912f20c24124ade4e8968c1bb2 Mon Sep 17 00:00:00 2001 From: hubobel Date: Mon, 10 Jul 2017 19:37:21 +0200 Subject: [PATCH] =?UTF-8?q?XML=20von=20Soundtouchger=C3=A4ten=20auslesen?= =?UTF-8?q?=20und=20durchsuchen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Soundtouch.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Soundtouch.py diff --git a/Soundtouch.py b/Soundtouch.py new file mode 100644 index 0000000..d186188 --- /dev/null +++ b/Soundtouch.py @@ -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("") + 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")) \ No newline at end of file