From 25dd7972fe0a49304e345616558a8c0330636eb5 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Thu, 9 Feb 2006 00:26:10 -0800 Subject: [PATCH] dynamicly change the root device's xml description... [git-p4: depot-paths = "//depot/": change = 719] --- pymediaserv | 22 +++++++++++++++------- root-device.xml | 23 +++++++++++++---------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/pymediaserv b/pymediaserv index e64ce59..ba201d0 100755 --- a/pymediaserv +++ b/pymediaserv @@ -6,6 +6,7 @@ # (c) 2005, Tim Potter import random +import socket import string import sys from twisted.python import log @@ -37,6 +38,7 @@ port.joinGroup(SSDP_ADDR) port.setLoopbackMode(0) # don't get our own sends uuid = 'uuid:' + generateuuid() +urlbase = 'http://%s:%d/' % (listenAddr, listenPort) # Create SOAP server @@ -48,9 +50,15 @@ class WebServer(resource.Resource): def __init__(self): resource.Resource.__init__(self) -class RootDevice(static.File): +class RootDevice(static.Data): def __init__(self): - static.File.__init__(self, 'root-device.xml', defaultType = 'text/xml') + r = { + 'hostname': socket.gethostname(), + 'uuid': uuid, + 'urlbase': urlbase, + } + d = file('root-device.xml').read() % r + static.Data.__init__(self, d, 'text/xml') root = WebServer() root.putChild('ContentDirectory', ContentDirectoryServer()) @@ -69,23 +77,23 @@ reactor.listenTCP(listenPort, site) # we need to do this after the children are there, since we send notifies s.register('%s::upnp:rootdevice' % uuid, 'upnp:rootdevice', - 'http://%s:%d/root-device.xml' % (listenAddr, listenPort)) + urlbase + 'root-device.xml') s.register(uuid, uuid, - 'http://%s:%d/root-device.xml' % (listenAddr, listenPort)) + urlbase + 'root-device.xml') s.register('%s::urn:schemas-upnp-org:device:MediaServer:1' % uuid, 'urn:schemas-upnp-org:device:MediaServer:1', - 'http://%s:%d/root-device.xml' % (listenAddr, listenPort)) + urlbase + 'root-device.xml') s.register('%s::urn:schemas-upnp-org:service:ConnectionManager:1' % uuid, 'urn:schemas-upnp-org:device:ConnectionManager:1', - 'http://%s:%d/root-device.xml' % (listenAddr, listenPort)) + urlbase + 'root-device.xml') s.register('%s::urn:schemas-upnp-org:service:ContentDirectory:1' % uuid, 'urn:schemas-upnp-org:device:ContentDirectory:1', - 'http://%s:%d/root-device.xml' % (listenAddr, listenPort)) + urlbase + 'root-device.xml') # Main loop diff --git a/root-device.xml b/root-device.xml index f74caba..5e6bc32 100644 --- a/root-device.xml +++ b/root-device.xml @@ -4,32 +4,35 @@ 1 0 +%(urlbase)s urn:schemas-upnp-org:device:MediaServer:1 -1.0 -Python Media Server -Zensonic -http://www.redsonic.com -UPnP/AV 1.0 Compliant Media Server +PyMedS (%(hostname)s) +JMGDIE +http://www.funkthat.com/ +hopefully a UPnP/AV 1.0 Compliant Media Server PC-MediaServer-DSM -103 -0000001 -uuid:XVKKBUKYRDLGJQDTPOT +1 +about:blank +0 +uuid:%(uuid)s + urn:schemas-upnp-org:service:ConnectionManager:1 -urn:upnp-org:serviceId:CMGR_0-99 +urn:upnp-org:serviceId:ConnectionManager ConnectionManager/scpd.xml ConnectionManager/control ConnectionManager/event urn:schemas-upnp-org:service:ContentDirectory:1 -urn:upnp-org:serviceId:CDS_0-99 +urn:upnp-org:serviceId:ContenDirectory ContentDirectory/scpd.xml ContentDirectory/control ContentDirectory/event +