From 28b6fb3cb53b6bee3a5f1ede5baefa860bd00c4b Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 26 Jul 2007 08:36:47 +0000 Subject: [PATCH] extractSubtitles from idx/rar pics --- oxdbarchive/cron.py | 17 ++++++++++------- oxdbarchive/model.py | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/oxdbarchive/cron.py b/oxdbarchive/cron.py index a832e46..64bb6ce 100644 --- a/oxdbarchive/cron.py +++ b/oxdbarchive/cron.py @@ -3,7 +3,7 @@ # vi:si:et:sw=2:sts=2:ts=2 from model import * - +import cache def cronDaily(): findNew() @@ -40,10 +40,13 @@ def cleanClipMovieCache(): os.remove(os.path.join(cache, d, f)) #possible fuctions: -''' def extractSubtitles(): - #look for rar / sub or vob / sub subtitles and extract them with - #tools/subtitles.py path_to_file - #import srt after - -''' \ No newline at end of file + extractSubtitlesScript = abspath(join(dirname(cache.cache_root), "tools/subtitles.py")) + for f in ArchiveFile.select(LIKE(ArchiveFile.q.path, '%' + '.idx')): + base = f.absolutePath.replace('.idx', '') + srtFile = f.absolutePath.replace('.idx', '.srt') + if not os.path.exists(srtFile): + cmd = 'python "%s" "%s"' % (extractSubtitlesScript, base) + os.system(cmd) + #only one subtitle at a time + return diff --git a/oxdbarchive/model.py b/oxdbarchive/model.py index 60104f6..7dc322f 100644 --- a/oxdbarchive/model.py +++ b/oxdbarchive/model.py @@ -48,7 +48,7 @@ class Archive(SQLObject): socket.setdefaulttimeout(100) url = "%s/%s?md5sum=%s" % (self.baseUrlFrontend, action, md5sum) result = read_url(url) - print "Frontend:", result + #print "Frontend:", result['result'] socket.setdefaulttimeout(dto) def _get_files(self): @@ -491,7 +491,7 @@ class ArchiveFile(SQLObject): options += ' "%s"' % movie_file.replace('"', '\\"') options += ' -o "%s"' % mini_movie_file cmd = "mencoder %s >/dev/null 2>&1" % options - print cmd.encode('utf-8') + #print cmd.encode('utf-8') os.system(cmd.encode('utf-8')) def removeTimeline(self):