You've already forked photo-importer
							
							
				mirror of
				https://github.com/sashacmc/photo-importer.git
				synced 2025-10-30 23:37:37 +02:00 
			
		
		
		
	Time by exif added
This commit is contained in:
		| @@ -1,2 +1,6 @@ | ||||
| # photo-importer | ||||
| Command line tools for photo importing/renaming/rotating | ||||
|  | ||||
| #Dependencies | ||||
| python3-exif | ||||
| exiftran | ||||
|   | ||||
							
								
								
									
										22
									
								
								fileprop.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										22
									
								
								fileprop.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| @@ -2,9 +2,14 @@ | ||||
|  | ||||
| import os | ||||
| import re | ||||
| import stat | ||||
| import time | ||||
| import logging | ||||
| import exifread | ||||
| import datetime | ||||
|  | ||||
| import config | ||||
|  | ||||
|  | ||||
| class FileProp(object): | ||||
|     OTHER = 0 | ||||
| @@ -90,7 +95,16 @@ class FileProp(object): | ||||
|         return None | ||||
|  | ||||
|     def __time_by_exif(self, fullname): | ||||
|         return None | ||||
|         try: | ||||
|             with open(fullname, 'rb') as f: | ||||
|                 tags = exifread.process_file(f) | ||||
|                 strtime = tags['EXIF DateTimeOriginal'].values | ||||
|                 return datetime.datetime.strptime(strtime, '%Y:%m:%d %H:%M:%S') | ||||
|         except (OSError, KeyError): | ||||
|             return None | ||||
|  | ||||
|     def __time_by_attr(self, fullname): | ||||
|         self.__time = time.localtime(os.stat(fullname)[stat.ST_MTIME]) | ||||
|  | ||||
|     def out_name(self): | ||||
|         if self.__time: | ||||
| @@ -107,3 +121,9 @@ class FileProp(object): | ||||
|  | ||||
|     def ok(self): | ||||
|         return self.__ok | ||||
|  | ||||
| if __name__ == '__main__': | ||||
|     import sys | ||||
|  | ||||
|     fp = FileProp(config.Config(False), sys.argv[1]) | ||||
|     print(fp.type(), fp.time(), fp.ok()) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user