dtlib.py : ne crash pas si une image n'a pas de donnée exif
This commit is contained in:
parent
557719baf6
commit
00270fdc18
37
dtlib.py
37
dtlib.py
@ -6,28 +6,32 @@ from datetime import datetime
|
||||
|
||||
def extractor(dt_file, start, end):
|
||||
catalog = {}
|
||||
unknow_files = 0
|
||||
conn = sqlite3.connect(dt_file)
|
||||
cursor = conn.cursor()
|
||||
req = "SELECT id, model, lens, exposure, aperture, iso, focal_length, datetime_taken, width, height FROM images;"
|
||||
cursor.execute(req)
|
||||
res = cursor.fetchall()
|
||||
for data in res:
|
||||
img_date = datetime.strptime(data[7], "%Y:%m:%d %H:%M:%S")
|
||||
if start <= img_date <= end:
|
||||
catalog.update({
|
||||
data[0]:
|
||||
{
|
||||
'camera': data[1],
|
||||
'lens': data[2],
|
||||
'shutter': float(data[3]*1000),
|
||||
'aperture': round(float(data[4]), 1),
|
||||
'iso': int(data[5]),
|
||||
'focal': float(data[6]),
|
||||
'datetime': img_date,
|
||||
'height': int(data[9]),
|
||||
'width': int(data[8])
|
||||
}
|
||||
})
|
||||
if not data[7]:
|
||||
unknow_files += 1
|
||||
else:
|
||||
img_date = datetime.strptime(data[7], "%Y:%m:%d %H:%M:%S")
|
||||
if start <= img_date <= end:
|
||||
catalog.update({
|
||||
data[0]:
|
||||
{
|
||||
'camera': data[1],
|
||||
'lens': data[2],
|
||||
'shutter': float(data[3]*1000),
|
||||
'aperture': round(float(data[4]), 1),
|
||||
'iso': int(data[5]),
|
||||
'focal': float(data[6]),
|
||||
'datetime': img_date,
|
||||
'height': int(data[9]),
|
||||
'width': int(data[8])
|
||||
}
|
||||
})
|
||||
cameras, lenses, focals, apertures, shutter_speeds = {}, {}, {}, {}, {}
|
||||
isos, dimensions, cameras_lenses, dates = {}, {}, {}, {}
|
||||
cameras_list, lenses_list, focals_list, apertures_list, shutter_speeds_list = [], [], [], [], []
|
||||
@ -76,6 +80,7 @@ def extractor(dt_file, start, end):
|
||||
dates.update({date: dates_list.count(date)})
|
||||
return {
|
||||
"total": len(catalog.keys()),
|
||||
"unknows": unknow_files,
|
||||
"date": dates,
|
||||
"cameras": cameras,
|
||||
"lenses": lenses,
|
||||
|
Loading…
Reference in New Issue
Block a user