|
|
@@ -50,18 +50,18 @@ from ContentDirectory import ContentDirectoryServer |
|
|
|
from ConnectionManager import ConnectionManagerServer |
|
|
|
|
|
|
|
class WebServer(resource.Resource): |
|
|
|
def __init__(self): |
|
|
|
resource.Resource.__init__(self) |
|
|
|
def __init__(self): |
|
|
|
resource.Resource.__init__(self) |
|
|
|
|
|
|
|
class RootDevice(static.Data): |
|
|
|
def __init__(self): |
|
|
|
r = { |
|
|
|
'hostname': socket.gethostname(), |
|
|
|
'uuid': uuid, |
|
|
|
'urlbase': urlbase, |
|
|
|
} |
|
|
|
d = file('root-device.xml').read() % r |
|
|
|
static.Data.__init__(self, d, 'text/xml') |
|
|
|
def __init__(self): |
|
|
|
r = { |
|
|
|
'hostname': socket.gethostname(), |
|
|
|
'uuid': uuid, |
|
|
|
'urlbase': urlbase, |
|
|
|
} |
|
|
|
d = file('root-device.xml').read() % r |
|
|
|
static.Data.__init__(self, d, 'text/xml') |
|
|
|
|
|
|
|
root = WebServer() |
|
|
|
cds = ContentDirectoryServer('My Media Server') |
|
|
@@ -122,7 +122,7 @@ def addFSPath(cds, parent, dpath): |
|
|
|
cds[item].res = Resource('%s%s' % (urlbase, fpath), 'http-get:*:%s:*' % mt) |
|
|
|
cds[item].res.size = os.path.getsize(fpath) |
|
|
|
except KeyError: |
|
|
|
pass |
|
|
|
pass |
|
|
|
|
|
|
|
addFSPath(cds, '0', 'media') |
|
|
|
|
|
|
@@ -131,24 +131,24 @@ 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', |
|
|
|
urlbase + 'root-device.xml') |
|
|
|
'upnp:rootdevice', |
|
|
|
urlbase + 'root-device.xml') |
|
|
|
|
|
|
|
s.register(uuid, |
|
|
|
uuid, |
|
|
|
urlbase + 'root-device.xml') |
|
|
|
uuid, |
|
|
|
urlbase + 'root-device.xml') |
|
|
|
|
|
|
|
s.register('%s::urn:schemas-upnp-org:device:MediaServer:1' % uuid, |
|
|
|
'urn:schemas-upnp-org:device:MediaServer:1', |
|
|
|
urlbase + 'root-device.xml') |
|
|
|
'urn:schemas-upnp-org:device:MediaServer:1', |
|
|
|
urlbase + 'root-device.xml') |
|
|
|
|
|
|
|
s.register('%s::urn:schemas-upnp-org:service:ConnectionManager:1' % uuid, |
|
|
|
'urn:schemas-upnp-org:device:ConnectionManager:1', |
|
|
|
urlbase + 'root-device.xml') |
|
|
|
'urn:schemas-upnp-org:device:ConnectionManager:1', |
|
|
|
urlbase + 'root-device.xml') |
|
|
|
|
|
|
|
s.register('%s::urn:schemas-upnp-org:service:ContentDirectory:1' % uuid, |
|
|
|
'urn:schemas-upnp-org:device:ContentDirectory:1', |
|
|
|
urlbase + 'root-device.xml') |
|
|
|
'urn:schemas-upnp-org:device:ContentDirectory:1', |
|
|
|
urlbase + 'root-device.xml') |
|
|
|
|
|
|
|
# Main loop |
|
|
|
|
|
|
|