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():
|
||||
for f in ArchiveFile.select(ArchiveFile.q.extracted == False):
|
||||
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="not in archive")
|
||||
|
||||
#FIXME this fails for old frontends because it notifies the frontend
|
||||
def importFrontend(self):
|
||||
if self.baseUrlFrontend:
|
||||
dto = socket.getdefaulttimeout()
|
||||
|
@ -152,13 +153,22 @@ class Archive(SQLObject):
|
|||
socket.setdefaulttimeout(dto)
|
||||
for f in files:
|
||||
meta = files[f]
|
||||
meta['path'] = f
|
||||
meta = oxdb_import.oxdb_file_metadata(meta)
|
||||
meta['video'] = ''
|
||||
meta['audio'] = ''
|
||||
meta['length'] = 0
|
||||
meta['bpp'] = 0
|
||||
print self.addFile(meta), f
|
||||
fname = join(self.basePath, f)
|
||||
if exists(fname):
|
||||
stats = oxdb_import.oxdb_file_stats(fname)
|
||||
meta['date'] = stats['date']
|
||||
meta['path'] = f
|
||||
meta['video'] = ''
|
||||
meta['audio'] = ''
|
||||
meta['length'] = 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
|
||||
else:
|
||||
print "remove", f
|
||||
self.removeFile({'md5sum':meta['md5sum']})
|
||||
|
||||
def importFiles(self):
|
||||
stats = {'skipped': 0, 'added': 0, 'remove':0}
|
||||
|
@ -189,7 +199,13 @@ class Archive(SQLObject):
|
|||
stats['remove'] += 1
|
||||
print 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):
|
||||
'''
|
||||
|
|
|
@ -41,7 +41,7 @@ class OXDb:
|
|||
|
||||
def oxdb_md5sum(fname):
|
||||
'''Returns an md5 hash for file'''
|
||||
msum = None
|
||||
md5sum = None
|
||||
if os.path.exists(fname):
|
||||
f = file(fname, 'rb')
|
||||
m = md5.new()
|
||||
|
|
Loading…
Reference in a new issue