-
Notifications
You must be signed in to change notification settings - Fork 0
/
flickr-backup.py
executable file
·53 lines (42 loc) · 1.39 KB
/
flickr-backup.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
#!/usr/bin/env python
"""
Command line tool to process the backup files provided by Flickr.
"""
import argparse
import logging
from flickr.handlers import FlickrAlbumsHandler
logger = logging.getLogger("flickr_backup")
def setup_argparse() -> argparse.ArgumentParser:
"""
Setups the argparse tool.
"""
parser = argparse.ArgumentParser(description="Flickr backup files utility.")
parser.add_argument("photos_dir", action="store", help="Folder where photos are located.")
parser.add_argument(
"-o", "--output_dir", action="store", help="Output folder. Defaults to 'photos_dir'."
)
parser.add_argument(
"-a",
"--album_json",
action="store",
help="Folder where the 'albums.json' is located. Defaults to 'photos_dir'.",
)
parser.add_argument(
"-v", "--verbosity", action="store_true", help="Adds verbosity.",
)
return parser
if __name__ == "__main__":
# Arguments parsing
parser = setup_argparse()
args = parser.parse_args()
if not args.verbosity:
logger.setLevel(logging.INFO)
if args.album_json:
flickr_albums = FlickrAlbumsHandler(
args.album_json, args.photos_dir, output_dir=args.output_dir
)
else:
flickr_albums = FlickrAlbumsHandler(
args.photos_dir, args.photos_dir, output_dir=args.output_dir
)
flickr_albums.make()