tryin first-pass of file metdata into Photos class

This commit is contained in:
2021-01-10 17:12:22 +11:00
parent 89eb73dab6
commit 0fe9a595b3

View File

@@ -23,9 +23,9 @@ class Photos(db.Model):
id = db.Column(db.Integer, db.Sequence('photos_id_seq'), primary_key=True )
name = db.Column(db.String, unique=True, nullable=False )
type = db.Column(db.String, unique=False, nullable=False)
size = db.Column(db.Integer, unique=False, nullable=False)
# size = db.Column(db.Integer, unique=False, nullable=False)
# hash might not be unique, this could be the source of dupe problems
hash = db.Column(db.Integer, unique=True, nullable=False)
#hash = db.Column(db.Integer, unique=True, nullable=False)
def __repr__(self):
return "<id: {}, name: {}>".format(self.id, self.name )
@@ -38,7 +38,6 @@ def photos():
sets = Settings.query.filter(Settings.name=="import_path").all()
paths= sets[0].value.split("#")
file_list=[]
file_types = {}
view_path=""
for p in paths:
if p.startswith('c:'):
@@ -48,14 +47,17 @@ def photos():
file_list.append(glob.glob(view_path + '**', recursive=True))
for file in file_list[0]:
if os.path.isdir(file):
file_types[file] = 'Directory'
ftype = 'Directory'
elif isImage(file):
file_types[file] = 'Image'
ftype = 'Image'
elif isVideo(file):
file_types[file] = 'Video'
ftype = 'Video'
else:
file_types[file] = 'File'
print(file_types)
ftype = 'File'
# fhash=... (file)
# fsize = ... (file)
file_list.append( Photos( name=file, type=ftype ))
return render_template("photos.html", page_title='View Photos', view_path=view_path, alert=st.GetAlert(), message=st.GetMessage() )