55import sys
66import time
77import uuid
8+ from datetime import UTC , datetime
89from importlib .metadata import version as get_version
910from pathlib import Path
1011from typing import TypedDict
@@ -34,7 +35,7 @@ class BaseJob(TypedDict):
3435 """Base class inherited by ImageConversionJob and ImageExifExtractionJob."""
3536
3637 job_type : str
37- uuid : uuid .UUID
38+ job_uuid : uuid .UUID
3839 basefile_uuid : uuid .UUID
3940 user_uuid : uuid .UUID
4041 client_uuid : uuid .UUID
@@ -119,12 +120,14 @@ def grind() -> None:
119120def upload (files : list [str ]) -> None :
120121 """Loop over files and upload each."""
121122 client , config = init ()
123+ file_uuids = []
122124 for f in files :
123125 pf = Path (f )
124126 click .echo (f"Uploading file { f } ..." )
125127 result = client .upload_file (path = pf , file_license = config ["license" ], attribution = config ["attribution" ])
126128 metadata = result ["bma_response" ]
127129 click .echo (f"File { metadata ['uuid' ]} uploaded OK!" )
130+ file_uuids .append (metadata ["uuid" ])
128131 # check for jobs
129132 if metadata ["jobs_unfinished" ] == 0 :
130133 continue
@@ -142,6 +145,11 @@ def upload(files: list[str]) -> None:
142145 klass = getattr (sys .modules [__name__ ], j ["job_type" ])
143146 job = klass (** j )
144147 handle_job (f = pf , job = job , client = client , config = config )
148+ click .echo (f"Finished uploading { len (file_uuids )} files, creating album..." )
149+ now = datetime .isoformat (datetime .now (tz = UTC ))
150+ album = client .create_album (file_uuids = file_uuids , title = f"Created-{ now } " , description = f"Created-{ now } " )
151+ url = f"{ client .base_url } /albums/{ album ['uuid' ]} /"
152+ click .echo (f"Created album { album ['uuid' ]} with the uploaded file(s) see it at { url } " )
145153 click .echo ("Done!" )
146154
147155
0 commit comments