import Frontend data
This commit is contained in:
parent
8ca0a45bcb
commit
e8e5a492e9
2 changed files with 24 additions and 42 deletions
|
|
@ -14,9 +14,12 @@ import time
|
|||
import math
|
||||
from glob import glob
|
||||
import shutil
|
||||
|
||||
from scrapeit.utils import read_url
|
||||
import socket
|
||||
|
||||
|
||||
import simplejson
|
||||
from scrapeit.utils import read_url
|
||||
|
||||
import cache
|
||||
import oxdb_import
|
||||
from oxdb_utils import oxdb_title, oxdb_director, oxdb_id
|
||||
|
|
@ -139,6 +142,24 @@ class Archive(SQLObject):
|
|||
return dict(result="file removed")
|
||||
return dict(result="not in archive")
|
||||
|
||||
def importFrontend(self):
|
||||
if self.baseUrlFrontend:
|
||||
dto = socket.getdefaulttimeout()
|
||||
socket.setdefaulttimeout(100)
|
||||
url = "%s/%s" % (self.baseUrlFrontend, 'list')
|
||||
result = read_url(url)
|
||||
files = simplejson.loads(result)['files']
|
||||
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
|
||||
|
||||
def importFiles(self):
|
||||
stats = {'skipped': 0, 'added': 0, 'remove':0}
|
||||
print self.basePath
|
||||
|
|
@ -155,7 +176,7 @@ class Archive(SQLObject):
|
|||
else:
|
||||
meta = oxdb_import.oxdb_file_metadata(meta)
|
||||
#FIXME: check input
|
||||
for key in ['bpp', 'size', 'length', 'date']:
|
||||
for key in ('bpp', 'size', 'length', 'date'):
|
||||
meta[key] = int(float(meta[key]))
|
||||
meta['date'] = datetime.fromtimestamp(meta['date'])
|
||||
print self.addFile(meta), f
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue