Browse Source

support custom root container

make the media folder the root container so we don't have a single
media node at the top..

[git-p4: depot-paths = "//depot/": change = 777]
replace/4e84fdb41ea781c7a8f872baa423e8b3be4045a7
John-Mark Gurney 18 years ago
parent
commit
adab67e8a2
2 changed files with 5 additions and 7 deletions
  1. +4
    -4
      ContentDirectory.py
  2. +1
    -3
      pymediaserv

+ 4
- 4
ContentDirectory.py View File

@@ -64,13 +64,13 @@ class ContentDirectoryControl(UPnPPublisher, dict):
assert isinstance(self[item], Container)
return self.children[item][:]

def __init__(self, title, *args):
def __init__(self, title, *args, **kwargs):
super(ContentDirectoryControl, self).__init__(*args)
fakeparent = '-1'
self.nextID = 0
self.children = { fakeparent: []}
self[fakeparent] = Container(None, None, '-1', 'fake')
root = self.addContainer(fakeparent, title)
root = self.addContainer(fakeparent, title, **kwargs)
assert root == '0'
del self[fakeparent]
del self.children[fakeparent]
@@ -227,8 +227,8 @@ class ContentDirectoryControl(UPnPPublisher, dict):
(`ContainerID`, `ObjectID`))

class ContentDirectoryServer(resource.Resource):
def __init__(self, title):
def __init__(self, title, *args, **kwargs):
resource.Resource.__init__(self)
self.putChild('scpd.xml', static.File('content-directory-scpd.xml'))
self.control = ContentDirectoryControl(title)
self.control = ContentDirectoryControl(title, *args, **kwargs)
self.putChild('control', self.control)

+ 1
- 3
pymediaserv View File

@@ -65,7 +65,7 @@ class RootDevice(static.Data):
static.Data.__init__(self, d, 'text/xml')

root = WebServer()
cds = ContentDirectoryServer('My Media Server')
cds = ContentDirectoryServer('My Media Server', klass = FSDirectory, path = 'media', urlbase = urlbase) # This sets up the root to be the media dir so we don't have to enumerate the directory
root.putChild('ContentDirectory', cds)
cds = cds.control
root.putChild('ConnectionManager', ConnectionManagerServer())
@@ -88,8 +88,6 @@ medianode.contentTypes.update( {
})
root.putChild('media', medianode)

cds.addContainer('0', 'media', klass = FSDirectory, path = 'media', urlbase = urlbase)

site = server.Site(root)
reactor.listenTCP(listenPort, site)



Loading…
Cancel
Save