-
Notifications
You must be signed in to change notification settings - Fork 0
/
mirror.py
29 lines (23 loc) · 1005 Bytes
/
mirror.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
#!/usr/bin/python
import argparse
import traceback
from smugsync.Smugmug import Smugmug
def main():
parser = argparse.ArgumentParser(description='SmugMug mirror script', fromfile_prefix_chars='@')
parser.add_argument('-a', '--apikey', type=str, help='api key', required=True)
parser.add_argument('-o', '--oauthsecret', type=str, help='oauth secret', required=True)
parser.add_argument('-n', '--appname', type=str, help='app name', required=True)
parser.add_argument('-p', '--path', type=str, help='output path', required=True)
args = parser.parse_args()
smugmug = Smugmug(api_key=args.apikey, oauth_secret=args.oauthsecret, app_name=args.appname)
smugmug.authenticate()
user = smugmug.get_authorized_user()
albums = smugmug.get_albums(user)
smugmug.mirror_albums(albums, args.path)
if __name__ == "__main__":
try:
main()
except Exception as e:
print('Exception: ' + e.message)
tb = traceback.format_exc()
print(tb)