1#!/usr/bin/env python
2
3import socket
4
5MS2 = """<?xml version="1.0" encoding="utf-8" standalone="no"?>
6<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
7  <s:Body>
8    <u:GetVolume xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">
9      <InstanceID>0</InstanceID>
10      <Channel>Master</Channel>
11    </u:GetVolume>
12
13  """ + """<u:GetMute>
14      <InstanceID>0</InstanceID>
15      <Channel>Master</Channel>
16    </u:GetMute>"""*100 + """
17  </s:Body>
18</s:Envelope>"""
19
20#1000000
21
22MS1 = """POST /upnp/service/RenderingControl/Control HTTP/1.1\r\nHOST: 192.168.1.44:50000
23Content-Length: """ + str(len(MS2)) + """
24Content-type: text/xml; charset="utf-8"
25SOAPACTION: "urn:schemas-upnp-org:service:RenderingControl:1#GetVolume"
26USER-AGENT: Linux/4.14.150_s5, UPnP/1.0, Portable SDK for UPnP devices/1.12.0
27CONNECTION: close
28
29"""
30# print(MS1 + MS2)
31address = ("192.168.0.3", 49152)
32skt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
33skt.connect(address)
34
35skt.send(MS1.encode() + MS2.encode())
36d = skt.recv(999)
37print(d.decode())
38
39