From 5ce2e924444ed8b99505a8170fa54b766f42d233 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Sat, 1 Mar 2008 02:08:19 -0800 Subject: [PATCH] prevent duplicate mime-types from being added... also, don't add the video types when the file isn't a video.. [git-p4: depot-paths = "//depot/": change = 1131] --- FSStorage.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/FSStorage.py b/FSStorage.py index a797122..393467a 100644 --- a/FSStorage.py +++ b/FSStorage.py @@ -13,7 +13,7 @@ import os import sets import stat -from DIDLLite import Container, StorageFolder, Item, VideoItem, AudioItem, TextItem, ImageItem, Resource +from DIDLLite import Container, StorageFolder, Item, VideoItem, AudioItem, TextItem, ImageItem, Resource, ResourceList from twisted.web import resource, server, static from twisted.python import log from twisted.internet import abstract, interfaces, process, protocol, reactor @@ -204,11 +204,15 @@ class FSItem(FSObject, Item): def doUpdate(self): #print 'FSItem doUpdate:', `self` - self.res = Resource(self.url, 'http-get:*:%s:*' % self.mimetype) - self.res.size = os.path.getsize(self.FSpath) - self.res = [ self.res ] - self.res.append(Resource(self.url + '/mpeg2', 'http-get:*:%s:*' % 'video/mpeg')) - self.res.append(Resource(self.url + '/xvid', 'http-get:*:%s:*' % 'video/x-msvideo')) + self.res = ResourceList() + r = Resource(self.url, 'http-get:*:%s:*' % self.mimetype) + r.size = os.path.getsize(self.FSpath) + self.res.append(r) + if self.mimetype.split('/', 1)[0] == 'video': + self.res.append(Resource(self.url + '/mpeg2', + 'http-get:*:%s:*' % 'video/mpeg')) + self.res.append(Resource(self.url + '/xvid', + 'http-get:*:%s:*' % 'video/x-msvideo')) Item.doUpdate(self) def ignoreFiles(path, fobj): @@ -258,7 +262,7 @@ def dofileadd(cd, parent, path, name): if klass is None or klass is IgnoreFile: return - #log.msg('matched:', os.path.join(path, name), `i`, `klass`) + print 'matched:', os.path.join(path, name), `i`, `klass` return cd.addItem(parent, klass, name, **kwargs) class FSDirectory(FSObject, StorageFolder):