bootstrap
This commit is contained in:
parent
e8e5a492e9
commit
b7f8d1fe8a
3 changed files with 35 additions and 9 deletions
|
@ -11,3 +11,13 @@ def findeNew():
|
||||||
def extractNew():
|
def extractNew():
|
||||||
for f in ArchiveFile.select(ArchiveFile.q.extracted == False):
|
for f in ArchiveFile.select(ArchiveFile.q.extracted == False):
|
||||||
f.extractAll()
|
f.extractAll()
|
||||||
|
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
'''
|
|
@ -142,6 +142,7 @@ class Archive(SQLObject):
|
||||||
return dict(result="file removed")
|
return dict(result="file removed")
|
||||||
return dict(result="not in archive")
|
return dict(result="not in archive")
|
||||||
|
|
||||||
|
#FIXME this fails for old frontends because it notifies the frontend
|
||||||
def importFrontend(self):
|
def importFrontend(self):
|
||||||
if self.baseUrlFrontend:
|
if self.baseUrlFrontend:
|
||||||
dto = socket.getdefaulttimeout()
|
dto = socket.getdefaulttimeout()
|
||||||
|
@ -152,13 +153,22 @@ class Archive(SQLObject):
|
||||||
socket.setdefaulttimeout(dto)
|
socket.setdefaulttimeout(dto)
|
||||||
for f in files:
|
for f in files:
|
||||||
meta = files[f]
|
meta = files[f]
|
||||||
|
fname = join(self.basePath, f)
|
||||||
|
if exists(fname):
|
||||||
|
stats = oxdb_import.oxdb_file_stats(fname)
|
||||||
|
meta['date'] = stats['date']
|
||||||
meta['path'] = f
|
meta['path'] = f
|
||||||
meta = oxdb_import.oxdb_file_metadata(meta)
|
|
||||||
meta['video'] = ''
|
meta['video'] = ''
|
||||||
meta['audio'] = ''
|
meta['audio'] = ''
|
||||||
meta['length'] = 0
|
meta['length'] = 0
|
||||||
meta['bpp'] = 0
|
meta['bpp'] = 0
|
||||||
|
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
|
||||||
|
else:
|
||||||
|
print "remove", f
|
||||||
|
self.removeFile({'md5sum':meta['md5sum']})
|
||||||
|
|
||||||
def importFiles(self):
|
def importFiles(self):
|
||||||
stats = {'skipped': 0, 'added': 0, 'remove':0}
|
stats = {'skipped': 0, 'added': 0, 'remove':0}
|
||||||
|
@ -190,6 +200,12 @@ class Archive(SQLObject):
|
||||||
print stats
|
print stats
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
|
'''
|
||||||
|
notify frontend about each file we have.
|
||||||
|
'''
|
||||||
|
def bootstrapFrontend(self):
|
||||||
|
for f in self.files:
|
||||||
|
self.notifyFrontend('add', f.md5sum)
|
||||||
|
|
||||||
class ArchiveFile(SQLObject):
|
class ArchiveFile(SQLObject):
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -41,7 +41,7 @@ class OXDb:
|
||||||
|
|
||||||
def oxdb_md5sum(fname):
|
def oxdb_md5sum(fname):
|
||||||
'''Returns an md5 hash for file'''
|
'''Returns an md5 hash for file'''
|
||||||
msum = None
|
md5sum = None
|
||||||
if os.path.exists(fname):
|
if os.path.exists(fname):
|
||||||
f = file(fname, 'rb')
|
f = file(fname, 'rb')
|
||||||
m = md5.new()
|
m = md5.new()
|
||||||
|
|
Loading…
Reference in a new issue