This commit is contained in:
parent
31db4e661a
commit
f7be8f323f
|
@ -111,18 +111,24 @@ class FileSystem(object):
|
||||||
if(metadata is None):
|
if(metadata is None):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# If the file has EXIF title we use that in the file name
|
# First we check if we have metadata['original_name'].
|
||||||
# (i.e. my-favorite-photo-img_1234.jpg)
|
# We have to do this for backwards compatibility because
|
||||||
# We want to remove the date prefix we add to the name.
|
# we original did not store this back into EXIF.
|
||||||
# This helps when re-running the program on file which were already
|
if(metadata['original_name'] is not None):
|
||||||
# processed.
|
base_name = os.path.splitext(metadata['original_name'])[0]
|
||||||
base_name = re.sub(
|
else:
|
||||||
'^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}-',
|
# If the file has EXIF title we use that in the file name
|
||||||
'',
|
# (i.e. my-favorite-photo-img_1234.jpg)
|
||||||
metadata['base_name']
|
# We want to remove the date prefix we add to the name.
|
||||||
)
|
# This helps when re-running the program on file which were already
|
||||||
if(len(base_name) == 0):
|
# processed.
|
||||||
base_name = metadata['base_name']
|
base_name = re.sub(
|
||||||
|
'^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}-',
|
||||||
|
'',
|
||||||
|
metadata['base_name']
|
||||||
|
)
|
||||||
|
if(len(base_name) == 0):
|
||||||
|
base_name = metadata['base_name']
|
||||||
|
|
||||||
if(
|
if(
|
||||||
'title' in metadata and
|
'title' in metadata and
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
|
@ -191,6 +191,20 @@ def test_get_file_name_with_title():
|
||||||
|
|
||||||
assert file_name == helper.path_tz_fix('2015-12-05_00-59-26-with-title-some-title.jpg'), file_name
|
assert file_name == helper.path_tz_fix('2015-12-05_00-59-26-with-title-some-title.jpg'), file_name
|
||||||
|
|
||||||
|
def test_get_file_name_with_original_name_exif():
|
||||||
|
filesystem = FileSystem()
|
||||||
|
media = Photo(helper.get_file('with-filename-in-exif.jpg'))
|
||||||
|
file_name = filesystem.get_file_name(media)
|
||||||
|
|
||||||
|
assert file_name == helper.path_tz_fix('2015-12-05_00-59-26-foobar.jpg'), file_name
|
||||||
|
|
||||||
|
def test_get_file_name_with_original_name_title_exif():
|
||||||
|
filesystem = FileSystem()
|
||||||
|
media = Photo(helper.get_file('with-filename-and-title-in-exif.jpg'))
|
||||||
|
file_name = filesystem.get_file_name(media)
|
||||||
|
|
||||||
|
assert file_name == helper.path_tz_fix('2015-12-05_00-59-26-foobar-foobar-title.jpg'), file_name
|
||||||
|
|
||||||
def test_get_folder_path_plain():
|
def test_get_folder_path_plain():
|
||||||
filesystem = FileSystem()
|
filesystem = FileSystem()
|
||||||
media = Photo(helper.get_file('plain.jpg'))
|
media = Photo(helper.get_file('plain.jpg'))
|
||||||
|
|
Loading…
Reference in New Issue