Guest User

Untitled

a guest
Oct 11th, 2020
7
316 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def setVolume(mediaLevel):
  2.     postdata = '<?xml version="1.0"?>\
  3.             <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
  4.             <s:Body>\
  5.             <u:SetVolume xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">\
  6.             <InstanceID>0</InstanceID>\
  7.             <Channel>Master</Channel>\
  8.             <DesiredVolume>' + mediaLevel +  '</DesiredVolume>\
  9.             </u:SetVolume>\
  10.             </s:Body>\
  11.             </s:Envelope>'
  12.     method = 'urn:schemas-upnp-org:service:RenderingControl:1#SetVolume'
  13.     server_ip = "%d.%d.%d.%d" % tuple(config.plugins.sonoscontrol.ip.value)
  14.     url = 'http://'+server_ip+':1400/MediaRenderer/RenderingControl/Control'
  15.     headers = {"Content-Type": 'text/xml; charset="utf-8"', "SOAPACTION": method}
  16.     getPage(url, method='POST', headers=headers, postdata=postdata)
  17.  
  18.  
  19.     def loadPage(self):
  20.         server_ip = "%d.%d.%d.%d" % tuple(config.plugins.sonoscontrol.ip.value)
  21.         url = 'http://'+server_ip+':1400/MediaRenderer/AVTransport/Control'
  22.         method = 'urn:schemas-upnp-org:service:AVTransport:1#GetPositionInfo'
  23.         headers = {"Content-Type": 'text/xml; charset="utf-8"', "SOAPACTION": method}
  24.         postdata = '<?xml version="1.0"?>\
  25.                 <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
  26.                 <s:Body>\
  27.                 <u:GetPositionInfo xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">\
  28.                 <InstanceID>0</InstanceID>\
  29.                 <Channel>Master</Channel>\
  30.                 </u:GetPositionInfo>\
  31.                 </s:Body>\
  32.                 </s:Envelope>'
  33.         getPage(url, method='POST', headers=headers, postdata=postdata).addCallback(self.getData)
  34.  
  35.     def getData(self, data):
  36.         data = str(self.html_parser.unescape(data))
  37.         track_duration = re.findall('<TrackDuration>(.*?)</TrackDuration>', data, re.S)
  38.         if track_duration[0] != "NOT_IMPLEMENTED":
  39.             track_album = []
  40.             track_cover = re.findall('<upnp:albumArtURI>(.*?)</upnp:albumArtURI>', data, re.S)
  41.             track_title = re.findall('<dc:title>(.*?)</dc:title>', data, re.S)
  42.             track_artist = re.findall('<dc:creator>(.*?)</dc:creator>', data, re.S)
  43.             track_album = re.findall('<upnp:album>(.*?)</upnp:album>', data, re.S)
RAW Paste Data