oxdbarchive/oxdbarchive/cron.py

48 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from model import *
import cache
def cronDaily():
findNew()
extractNew()
def findNew():
archive = Archive.get(1)
archive.findNew()
def extractFrames():
for f in ArchiveFile.select(ArchiveFile.q.extracted == False):
f.extractFrames()
def extractTimelines():
for f in ArchiveFile.select(ArchiveFile.q.extracted == False):
f.extractTimeline()
def extractNew():
for f in ArchiveFile.select(ArchiveFile.q.extracted == False):
f.extractAll()
def cleanClipMovieCache():
cache = os.path.abspath('oxdb/cache/mini/')
for d, p, files in os.walk(cache):
for f in files:
md5sum = f.replace('.avi', '')
try:
fm = ArchiveFile.byMd5sum(md5sum)
except:
os.remove(os.path.join(cache, d, f))
#possible fuctions:
def extractSubtitles():
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