Add get_exif_metadata_caching method in ReadExif

This commit is contained in:
Cédric Leporcq 2022-01-29 08:05:36 +01:00
parent b0969f62af
commit 957e436309
2 changed files with 11 additions and 3 deletions

View File

@ -107,14 +107,18 @@ class ReadExif(ExifMetadata):
if exif_metadata: if exif_metadata:
self.exif_metadata = exif_metadata self.exif_metadata = exif_metadata
else: else:
self.exif_metadata = self.get_exif_metadata() self.exif_metadata = self.get_exif_metadata_caching()
def get_exif_metadata(self): def get_exif_metadata(self):
"""Get metadata from exiftool.""" """Get metadata from exiftool."""
return ExifToolCaching(self.file_path).asdict() return ExifToolCaching(self.file_path).asdict()
def get_exif_metadata_caching(self):
"""Get metadata from exiftool."""
return ExifToolCaching(self.file_path).asdict()
def get_key_values(self, key): def get_key_values(self, key):
""" """
Get tags values of a key Get tags values of a key

View File

@ -9,7 +9,7 @@ import inquirer
from ordigi import LOG from ordigi import LOG
from ordigi import constants from ordigi import constants
from ordigi.collection import Collection, FPath, Paths from ordigi.collection import Collection, FPath, Paths
from ordigi.exiftool import ExifToolCaching, exiftool_is_running, terminate_exiftool from ordigi.exiftool import ExifTool, ExifToolCaching, exiftool_is_running, terminate_exiftool
from ordigi.geolocation import GeoLocation from ordigi.geolocation import GeoLocation
from ordigi.media import Media, ReadExif from ordigi.media import Media, ReadExif
from ordigi import utils from ordigi import utils
@ -268,3 +268,7 @@ class TestCollection:
date = collection.db.sqlite.get_metadata_data('test_exif/photo.rw2', date = collection.db.sqlite.get_metadata_data('test_exif/photo.rw2',
'DateOriginal') 'DateOriginal')
assert date == '2021-03-12 08:12:35' assert date == '2021-03-12 08:12:35'
# Check if exif value is set
file_path = path.joinpath('test_exif/photo.rw2')
date = ExifTool(file_path).asdict()['EXIF:DateTimeOriginal']
assert date == '2021-03-12 08:12:35'