Skip to content

Commit f2a3a27

Browse files
committed
group uploaded files in an album, add missing __init__.py file, bump django-client-lib to v0.5.0
1 parent 80aef65 commit f2a3a27

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ classifiers = [
1313
]
1414
dependencies = [
1515
"typer-slim==0.12.5",
16-
"bma-client-lib>=0.4.1",
16+
"bma-client-lib>=0.5.0",
1717
]
1818
name = "bma-cli"
1919
description = "BornHack Media Archive CLI Tool"

src/bma_cli/__init__.py

Whitespace-only changes.

src/bma_cli/bma_cli.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sys
66
import time
77
import uuid
8+
from datetime import UTC, datetime
89
from importlib.metadata import version as get_version
910
from pathlib import Path
1011
from 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:
119120
def 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

Comments
 (0)