diff --git a/ordigi/collection.py b/ordigi/collection.py index 98bc30e..21d6f17 100644 --- a/ordigi/collection.py +++ b/ordigi/collection.py @@ -519,7 +519,7 @@ class SortMedias: # change media file_path to dest_path if not self.dry_run: - updated = self.medias.update_exif_data(metadata) + updated = self.medias.update_exif_data(metadata, imp) if updated: checksum = utils.checksum(dest_path) metadata['checksum'] = checksum diff --git a/ordigi/media.py b/ordigi/media.py index 71c0f73..e1999dc 100644 --- a/ordigi/media.py +++ b/ordigi/media.py @@ -62,7 +62,7 @@ class ExifMetadata: ] tags_keys['latitude_ref'] = ['EXIF:GPSLatitudeRef'] tags_keys['longitude_ref'] = ['EXIF:GPSLongitudeRef'] - tags_keys['original_name'] = ['XMP:OriginalFileName'] + tags_keys['original_name'] = ['EXIF:OriginalFileName', 'XMP:OriginalFileName'] # Remove ignored tag from list for tag_regex in self.ignore_tags: @@ -742,7 +742,7 @@ class Medias: yield src_path, metadata - def update_exif_data(self, metadata): + def update_exif_data(self, metadata, imp=False): file_path = self.root / metadata['file_path'] exif = WriteExif( @@ -752,8 +752,8 @@ class Medias: ) updated = False - if metadata['original_name'] in (None, ''): - exif.set_value('original_name', metadata['filename']) + if imp and metadata['original_name'] in (None, ''): + exif.set_key_values('original_name', metadata['filename']) updated = True if self.exif_opt['album_from_folder']: exif.set_album_from_folder() diff --git a/tests/test_collection.py b/tests/test_collection.py index 332dfe3..0ad6734 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -218,7 +218,8 @@ class TestCollection: ) assert not summary.errors # Ensure files remain the same - assert collection._checkcomp(dest_path, src_checksum) + if not imp: + assert collection._checkcomp(dest_path, src_checksum) if imp == 'copy': assert src_path.exists()