diff --git a/ContentDirectory.py b/ContentDirectory.py index 3ade39c..3a30c9d 100644 --- a/ContentDirectory.py +++ b/ContentDirectory.py @@ -145,13 +145,20 @@ class ContentDirectoryControl(UPnPPublisher, dict): if BrowseFlag == 'BrowseDirectChildren': ch = self.getchildren(ObjectID)[StartingIndex: StartingIndex + RequestedCount] - filter(lambda x, d = didl: d.addItem(x) and None, filter(lambda x, s = self: s[x.id].checkUpdate(), ch)) + # filter out the ones that don't exist anymore, we need + # to check against None, since some dirs might be empty + # (of valid content) but exist. + ochup = filter(lambda x, s = self: + s[x.id].checkUpdate() is not None, ch) + filter(lambda x, d = didl: d.addItem(x) and None, ochup) + total = len(self.getchildren(ObjectID)) else: didl.addItem(self[ObjectID]) + total = 1 result = {'BrowseResponse': {'Result': didl.toString() , 'NumberReturned': didl.numItems(), - 'TotalMatches': didl.numItems(), + 'TotalMatches': total, 'UpdateID': self[ObjectID].updateID }} #log.msg('Returning: %s' % result)