gh-2 Write to EXIF from earlier of modified or access time if no date is found in EXIF
This commit is contained in:
parent
67a47db73d
commit
f67314f6bc
|
@ -98,7 +98,7 @@ def _update(params):
|
||||||
|
|
||||||
if(time_format is not None):
|
if(time_format is not None):
|
||||||
time = datetime.strptime(time_string, time_format)
|
time = datetime.strptime(time_string, time_format)
|
||||||
media.set_datetime(time)
|
media.set_date_taken(time)
|
||||||
updated = True
|
updated = True
|
||||||
|
|
||||||
if(params['--album'] is not None):
|
if(params['--album'] is not None):
|
||||||
|
|
|
@ -158,7 +158,9 @@ class FileSystem:
|
||||||
self.create_directory(dest_directory)
|
self.create_directory(dest_directory)
|
||||||
|
|
||||||
if(move == True):
|
if(move == True):
|
||||||
|
stat = os.stat(_file)
|
||||||
shutil.move(_file, dest_path)
|
shutil.move(_file, dest_path)
|
||||||
|
os.utime(dest_path, (stat.st_atime, stat.st_mtime))
|
||||||
else:
|
else:
|
||||||
shutil.copy2(_file, dest_path)
|
shutil.copy2(_file, dest_path)
|
||||||
|
|
||||||
|
|
|
@ -335,7 +335,6 @@ class Media(object):
|
||||||
name = 'Video'
|
name = 'Video'
|
||||||
|
|
||||||
for i in classes:
|
for i in classes:
|
||||||
print i.__name__
|
|
||||||
if(name == i.__name__):
|
if(name == i.__name__):
|
||||||
return i(_file)
|
return i(_file)
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Photo(Media):
|
||||||
|
|
||||||
@returns, boolean
|
@returns, boolean
|
||||||
"""
|
"""
|
||||||
def set_datetime(self, time):
|
def set_date_taken(self, time):
|
||||||
if(time is None):
|
if(time is None):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ class Video(Media):
|
||||||
|
|
||||||
# If the time wasn't found in EXIF we need to add it there since the modified/access times frequently change
|
# If the time wasn't found in EXIF we need to add it there since the modified/access times frequently change
|
||||||
if(time_found_in_exif == False):
|
if(time_found_in_exif == False):
|
||||||
self.set_datetime(datetime.fromtimestamp(seconds_since_epoch))
|
self.set_date_taken(datetime.fromtimestamp(seconds_since_epoch))
|
||||||
|
|
||||||
return time.gmtime(seconds_since_epoch)
|
return time.gmtime(seconds_since_epoch)
|
||||||
|
|
||||||
|
@ -155,11 +155,16 @@ class Video(Media):
|
||||||
|
|
||||||
@returns, boolean
|
@returns, boolean
|
||||||
"""
|
"""
|
||||||
def set_datetime(self, time):
|
def set_date_taken(self, date_taken_as_datetime):
|
||||||
if(time is None):
|
if(time is None):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
result = self.__update_using_plist(time=time)
|
source = self.source
|
||||||
|
|
||||||
|
result = self.__update_using_plist(time=date_taken_as_datetime)
|
||||||
|
if(result == True):
|
||||||
|
os.utime(source, (int(time.time()), time.mktime(date_taken_as_datetime.timetuple())))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue