| @@ 197-211 (lines=15) @@ | ||
| 194 | return True |
|
| 195 | ||
| 196 | ||
| 197 | def update_time(media, file_path, time_string): |
|
| 198 | """Update time exif metadata of media. |
|
| 199 | """ |
|
| 200 | time_format = '%Y-%m-%d %H:%M:%S' |
|
| 201 | if re.match(r'^\d{4}-\d{2}-\d{2}$', time_string): |
|
| 202 | time_string = '%s 00:00:00' % time_string |
|
| 203 | elif re.match(r'^\d{4}-\d{2}-\d{2} \d{2}:\d{2}\d{2}$', time_string): |
|
| 204 | msg = ('Invalid time format. Use YYYY-mm-dd hh:ii:ss or YYYY-mm-dd') |
|
| 205 | log.error(msg) |
|
| 206 | log.all('{"source":"%s", "error_msg":"%s"}' % (file_path, msg)) |
|
| 207 | sys.exit(1) |
|
| 208 | ||
| 209 | time = datetime.strptime(time_string, time_format) |
|
| 210 | media.set_date_taken(time) |
|
| 211 | return True |
|
| 212 | ||
| 213 | ||
| 214 | @click.command('update') |
|
| @@ 197-211 (lines=15) @@ | ||
| 194 | return True |
|
| 195 | ||
| 196 | ||
| 197 | def update_time(media, file_path, time_string): |
|
| 198 | """Update time exif metadata of media. |
|
| 199 | """ |
|
| 200 | time_format = '%Y-%m-%d %H:%M:%S' |
|
| 201 | if re.match(r'^\d{4}-\d{2}-\d{2}$', time_string): |
|
| 202 | time_string = '%s 00:00:00' % time_string |
|
| 203 | elif re.match(r'^\d{4}-\d{2}-\d{2} \d{2}:\d{2}\d{2}$', time_string): |
|
| 204 | msg = ('Invalid time format. Use YYYY-mm-dd hh:ii:ss or YYYY-mm-dd') |
|
| 205 | log.error(msg) |
|
| 206 | log.all('{"source":"%s", "error_msg":"%s"}' % (file_path, msg)) |
|
| 207 | sys.exit(1) |
|
| 208 | ||
| 209 | time = datetime.strptime(time_string, time_format) |
|
| 210 | media.set_date_taken(time) |
|
| 211 | return True |
|
| 212 | ||
| 213 | ||
| 214 | @click.command('update') |
|