From 5a116a1be372360a99a44638e0be8a3c4f9e6ff9 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 12 Jul 2007 22:00:18 +0000 Subject: [PATCH] remove just needs md5sum --- oxdbarchive/model.py | 23 +++++++++++------------ oxdbarchive/oxdb_utils.py | 8 ++++++++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/oxdbarchive/model.py b/oxdbarchive/model.py index 29e9d87..4fe3fad 100644 --- a/oxdbarchive/model.py +++ b/oxdbarchive/model.py @@ -22,7 +22,7 @@ from scrapeit.utils import read_url import cache import oxdb_import -from oxdb_utils import oxdb_title, oxdb_director, oxdb_id +from oxdb_utils import oxdb_title, oxdb_director, oxdb_id, oxdb_makedir from subtitles import * import midentify @@ -168,7 +168,7 @@ class Archive(SQLObject): print self.addFile(meta), f else: print "remove", f - self.removeFile({'md5sum':meta['md5sum']}) + self.removeFile(meta['md5sum']) def importFiles(self): stats = {'skipped': 0, 'added': 0, 'remove':0} @@ -380,8 +380,7 @@ class ArchiveFile(SQLObject): def _get_frameFolder(self): f = join(cache.cache_root, 'frame', self.md5sum[:4], self.md5sum) - if not exists(f): - os.makedirs(f) + oxdb_makedir(f) return f def _get_timelineFile(self): @@ -431,8 +430,7 @@ class ArchiveFile(SQLObject): if self.movieFile: return self.movieFile.extractFrame(position, img_folder) movie_file = self.mini_movie_file - if not exists(img_folder): - os.makedirs(img_folder) + oxdb_makedir(img_folder) position = position.replace('.', ':') extract_frame(movie_file, position, img_folder, offset = 0, redo = False) @@ -441,8 +439,8 @@ class ArchiveFile(SQLObject): if self.movieFile: return self.movieFile.extractFrames(img_folder) movie_file = self.absolutePath - if not exists(img_folder): - os.makedirs(img_folder) + + oxdb_makedir(img_folder) extract_subtitles(movie_file, self.srt.encode('utf-8'), img_folder, width=100, offset=self.offset) def extractClipMovie(self, force = False): @@ -461,8 +459,8 @@ class ArchiveFile(SQLObject): if exists(mini_movie_file) and not force: print "clip exists, skipping extraction", mini_movie_file return - if not exists(dirname(mini_movie_file)): - os.makedirs(dirname(mini_movie_file)) + oxdb_makedir(dirname(mini_movie_file)) + options = '' options += " -ovc lavc -lavcopts vcodec=mjpeg" options += " -af volnorm=1 -oac mp3lame -lameopts br=64:mode=3 -af resample=44100" @@ -496,8 +494,9 @@ class ArchiveFile(SQLObject): if exists(t): print "skipping, ", self.path return - if not exists(dirname(t)): - os.makedirs(dirname(t)) + + oxdb_makedir(dirname(t)) + #this fails in tg-admin shell #extractTimelineScript = abspath(join(dirname(__file__), "tools/extract_timeline.py")) extractTimelineScript = abspath(join(dirname(cache.cache_root), "tools/extract_timeline.py")) diff --git a/oxdbarchive/oxdb_utils.py b/oxdbarchive/oxdb_utils.py index 7066142..63e7854 100644 --- a/oxdbarchive/oxdb_utils.py +++ b/oxdbarchive/oxdb_utils.py @@ -208,3 +208,11 @@ languages = ('be', 'bg', 'ba', 'wo', 'bn', 'bo', 'bh', 'bi', 'ji', 'br', 'ja', 'la', 'ln', 'lo', 'tt', 'tr', 'ts', 'lv', 'to', 'lt', 'tk', 'th', 'ti', 'tg', 'te', 'ta', 'aa', 'ab', 'uk', 'af', 'vi', 'is', 'am', 'it', 'iw', 'vo', 'ik', 'ar', 'in', 'ay', 'az', 'ie', 'qu', 'st', 'tw') + +def oxdb_makedir(folder): + if not exists(folder): + try: + os.makedirs(folder) + except os.error, e: + if e.errno != errno.EEXIST or not os.path.isdir(folder): + raise \ No newline at end of file