From 4830a3bc5c46b91571a005d2f451dd19db18afef Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 4 Dec 2007 15:38:34 +0000 Subject: [PATCH] extracted saves state of minimovie now, do not try to extract timeline if minimovie is not done or failed --- oxdbarchive/midentify.py | 1 + oxdbarchive/model.py | 28 +++++++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/oxdbarchive/midentify.py b/oxdbarchive/midentify.py index 3460c50..fc78663 100644 --- a/oxdbarchive/midentify.py +++ b/oxdbarchive/midentify.py @@ -8,6 +8,7 @@ import sys _audio_codec_map = { 'ffmp3': 'mp3', 'mad': 'mp3', + 'faad': 'aac' } _video_codec_map = { diff --git a/oxdbarchive/model.py b/oxdbarchive/model.py index 3753366..8836158 100644 --- a/oxdbarchive/model.py +++ b/oxdbarchive/model.py @@ -190,12 +190,12 @@ class Archive(SQLObject): for key in ('bpp', 'size', 'length', 'date'): meta[key] = int(float(meta[key])) meta['date'] = datetime.fromtimestamp(meta['date']) - print self.addFile(meta), f + print self.addFile(meta), f.encode('utf-8') stats['added'] += 1 md5sum_on_disk.append(meta['md5sum']) for f in oxdb_files: if oxdb_files[f]['md5sum'] not in md5sum_on_disk: - print "remove", f + print "remove", f.encode('utf-8') self.removeFile(oxdb_files[f]['md5sum']) stats['remove'] += 1 print stats @@ -208,6 +208,19 @@ class Archive(SQLObject): for f in self.files: self.notifyFrontend('add', f.md5sum) + def cleanupFrontend(self): + dto = socket.getdefaulttimeout() + socket.setdefaulttimeout(256) + data = read_url("%s/list" % self.baseUrlFrontend) + files = simplejson.loads(data)['files'] + socket.setdefaulttimeout(dto) + md5sums = [str(f['md5sum']) for f in files.values()] + for md5sum in md5sums: + try: + f = ArchiveFile.byMd5sum(md5sum) + except SQLObjectNotFound: + self.notifyFrontend('remove', md5sum) + def fillFrontend(self): dto = socket.getdefaulttimeout() socket.setdefaulttimeout(256) @@ -429,12 +442,11 @@ class ArchiveFile(SQLObject): def extractAll(self, force = False): if not self.extracted or force: self.updateMeta() - self.extractClipMovie() - self.extractTimeline() + self.extractClipMovie(force) + self.extractTimeline(force) #enable this later #self.extractFrames() #self.extractClips() - self.extracted = True def extractClip(self, inpoint, outpoint=-1, flash_folder=-1): if flash_folder == -1: @@ -506,7 +518,9 @@ class ArchiveFile(SQLObject): options += ' -o "%s"' % mini_movie_file cmd = "mencoder %s >/dev/null 2>&1" % options #print cmd.encode('utf-8') - os.system(cmd.encode('utf-8')) + r = os.system(cmd.encode('utf-8')) + if r == 0: + self.extracted = True def removeTimeline(self): if exists(self.timelineFile): @@ -522,7 +536,7 @@ class ArchiveFile(SQLObject): if self.height <= 0: return - if not exists(self.mini_movie_file): + if not (self.extracted and exists(self.mini_movie_file)): print "mini movie missing, skipping", self.path return