Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for camera info in filename #405

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions elodie/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self):
# It captures some additional characters like the unicode checkmark \u2713.
# See build failures in Python3 here.
# https://travis-ci.org/jmathai/elodie/builds/483012902
self.whitespace_regex = '[ \t\n\r\f\v]+'
self.whitespace_regex = '[ \t\n\r\f\v,/]+'

# Instantiate a plugins object
self.plugins = Plugins()
Expand Down Expand Up @@ -168,7 +168,7 @@ def get_file_name(self, metadata):
place_name,
)
break
elif part in ('album', 'extension', 'title'):
elif part in ('album', 'extension', 'title', 'camera_make', 'camera_model'):
if metadata[part]:
this_value = re.sub(self.whitespace_regex, '-', metadata[part].strip())
break
Expand Down Expand Up @@ -218,6 +218,8 @@ def get_file_name(self, metadata):
name,
)

name = re.sub('[\?\*\0:|<>]', '_', name)

config = load_config()

if('File' in config and 'capitalization' in config['File'] and config['File']['capitalization'] == 'upper'):
Expand Down Expand Up @@ -588,7 +590,10 @@ def process_file(self, _file, destination, media, **kwargs):
# Set the utime based on what the original file contained
# before we made any changes.
# Then set the utime on the destination file based on metadata.
os.utime(_file, (stat_info_original.st_atime, stat_info_original.st_mtime))
try:
os.utime(_file, (stat_info_original.st_atime, stat_info_original.st_mtime))
except OSError:
pass
self.set_utime_from_metadata(metadata, dest_path)

db = Db()
Expand Down
5 changes: 4 additions & 1 deletion elodie/media/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ def write_metadata(self, **kwargs):

# Create an _original copy just as we do with exiftool
# This is to keep all file processing logic in line with exiftool
copy2(source, source + '_original')
try:
copy2(source, source + '_original')
except:
return

if has_metadata:
# Update the first line of this file in place
Expand Down