-
Notifications
You must be signed in to change notification settings - Fork 5
/
photos_export.py
executable file
·77 lines (59 loc) · 2.01 KB
/
photos_export.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /usr/bin/env python3
import clean_albums
import extract_photos
import set_exif
import albums_data
import folder_structure
import group_versions
import album_folder
import sys
import os
from argparse import ArgumentParser
def output(thing):
print('>>> %s' % thing)
def askyesno():
answer = None
while answer not in ("yes", "no"):
answer = input("Enter yes or no: ")
if answer == "yes":
return True
elif answer == "no":
return False
else:
print("Please enter yes or no.")
def run(lib_dir, output_dir, digikam_dir):
temp_dir = os.path.join(output_dir, "temporaryfolder")
output('Extracting photos')
extract_photos.run(lib_dir, temp_dir)
output('Cleaning album names')
clean_albums.run(temp_dir)
output('Setting EXIF metadata')
set_exif.run(temp_dir)
if digikam_dir is not None:
output('Grouping Versions...')
group_versions.run(digikam_dir, temp_dir)
output('Exporting Folder Structure')
folder_structure.run(lib_dir, temp_dir)
output('Exporting Albums Structure Information')
albums_data.run(lib_dir, temp_dir)
output('Moving Photos to final destination.')
album_folder.run(temp_dir, output_dir)
# Usage: ./photos_export.py <photo_library> <output_dir> <digikam_dir>
# digikam_dir may be any dir, if you want to ignore it.
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument(
'photoslib_dir',
help='Path of where the .json and photos were exported')
parser.add_argument(
'output_dir',
help='Path to where the albums and the files will be created/moved')
parser.add_argument('digikamdb_dir', nargs='?',
help='Path to where Digikam DB is located')
try:
args = parser.parse_args()
except Exception as error:
print("Argument error: ", error)
sys.exit(2)
# run(sys.argv[1], sys.argv[2], sys.argv[3])
run(args.photoslib_dir, args.output_dir, args.digikamdb_dir)