Fix extension date
This commit is contained in:
parent
cb1abd0c86
commit
2dc410f9bc
@ -10,20 +10,27 @@ import calendar
|
||||
import shutil
|
||||
from PIL import Image
|
||||
|
||||
# Variables
|
||||
META_CREATED = 36867
|
||||
EXTENSIONS = ('jpg', 'jpeg', 'gif')
|
||||
|
||||
def get_date_created(filename):
|
||||
'''Get date created from create METADATA or file information'''
|
||||
# Not image
|
||||
if not os.path.basename(filename).lower().endswith(EXTENSIONS):
|
||||
return time.strftime('%d/%m/%Y', time.gmtime(os.path.getctime(filename)))
|
||||
# Image
|
||||
image = Image.open(filename)
|
||||
image.verify()
|
||||
# Format date d/m/Y
|
||||
if image._getexif() is not None and META_CREATED in image._getexif():
|
||||
# Metadata
|
||||
if image._getexif() is not None \
|
||||
and META_CREATED in image._getexif():
|
||||
# Get metadata
|
||||
return time.strftime('%d/%m/%Y', datetime.datetime.strptime(image._getexif()[META_CREATED], "%Y:%m:%d %H:%M:%S").timetuple())
|
||||
else:
|
||||
# Create data file
|
||||
# Get create data file
|
||||
return time.strftime('%d/%m/%Y', time.gmtime(os.path.getctime(filename)))
|
||||
|
||||
EXTENSIONS = ('jpg', 'jpeg', 'gif')
|
||||
|
||||
@click.command()
|
||||
@click.argument('path')
|
||||
|
2
setup.py
2
setup.py
@ -2,7 +2,7 @@ from setuptools import setup
|
||||
setup(
|
||||
name = 'Organize-my-photos',
|
||||
py_modules=['organize_my_photos'],
|
||||
version = '1.0.6',
|
||||
version = '1.0.7',
|
||||
python_requires='>3.6',
|
||||
description = 'Terminal program that organizes and organizes the photographs in folders by year, month and day.',
|
||||
author = 'Andros Fenollosa',
|
||||
|
Loading…
Reference in New Issue
Block a user