Skip to content

Commit 66a099e

Browse files
committed
add create_album method
1 parent 7e1c28b commit 66a099e

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/bma_client_lib/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
"""Convenience import."""
2+
13
from .bma_client import BmaClient
4+
5+
__all__ = ["BmaClient"]

src/bma_client_lib/bma_client.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import uuid
77
from fractions import Fraction
88
from http import HTTPStatus
9+
from importlib.metadata import PackageNotFoundError, version
910
from io import BytesIO
1011
from pathlib import Path
1112
from typing import TYPE_CHECKING, TypeAlias
@@ -14,9 +15,6 @@
1415
import httpx
1516
import magic
1617
from PIL import Image, ImageOps
17-
from importlib.metadata import PackageNotFoundError
18-
from importlib.metadata import version
19-
2018

2119
logger = logging.getLogger("bma_client")
2220

@@ -325,3 +323,14 @@ def get_exif(self, fname: Path) -> ExifExtractionJobResult:
325323
grouped[group] = {}
326324
grouped[group][key] = str(value)
327325
return grouped
326+
327+
def create_album(self, file_uuids: list[uuid.UUID], title: str, description: str) -> dict[str, str]:
328+
"""Create an album."""
329+
url = self.base_url + "/api/v1/json/albums/create/"
330+
data = {
331+
"files": file_uuids,
332+
"title": title,
333+
"description": description,
334+
}
335+
r = self.client.post(url, json=data).raise_for_status()
336+
return r.json()["bma_response"]

0 commit comments

Comments
 (0)