Skip to content

Commit

Permalink
add create_album method
Browse files Browse the repository at this point in the history
  • Loading branch information
tykling committed Nov 10, 2024
1 parent 7e1c28b commit 66a099e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/bma_client_lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
"""Convenience import."""

from .bma_client import BmaClient

__all__ = ["BmaClient"]
15 changes: 12 additions & 3 deletions src/bma_client_lib/bma_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import uuid
from fractions import Fraction
from http import HTTPStatus
from importlib.metadata import PackageNotFoundError, version
from io import BytesIO
from pathlib import Path
from typing import TYPE_CHECKING, TypeAlias
Expand All @@ -14,9 +15,6 @@
import httpx
import magic
from PIL import Image, ImageOps
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version


logger = logging.getLogger("bma_client")

Expand Down Expand Up @@ -325,3 +323,14 @@ def get_exif(self, fname: Path) -> ExifExtractionJobResult:
grouped[group] = {}
grouped[group][key] = str(value)
return grouped

def create_album(self, file_uuids: list[uuid.UUID], title: str, description: str) -> dict[str, str]:
"""Create an album."""
url = self.base_url + "/api/v1/json/albums/create/"
data = {
"files": file_uuids,
"title": title,
"description": description,
}
r = self.client.post(url, json=data).raise_for_status()
return r.json()["bma_response"]

0 comments on commit 66a099e

Please sign in to comment.