API for Albums

The Albums Class

class digikamdb.albums.Albums(digikam)[source]

Bases: DigikamTable

Offers access to the albums in the Digikam instance.

Albums represents all albums present in the Digikam database. It is usually accessed through the Digikam property albums.

Usage:

dk = Digikam(...)
myalbum = dk.albums[42]                             # by id
for album in dk.albums:                             # iterate
    print(album.relativePath)
Parameters:

digikam (Digikam) – Digikam object for access to database and other classes.

See also

find(path, exact=False)[source]

Finds albums by path name.

Parameters:
  • path (str | bytes | PathLike) – Path to album(s). Can be given as any type that the os.path functions understand.

  • exact (bool) – If true, look for exactly one album. If false, and path contains subdirectories, these are also returned.

Returns:

The found albums. If exact == True, the album object is returned, or None if it was not found. If exact == False, returns a list with the found albums.

Raises:

DigikamDataIntegrityError – Database contains overlapping roots.

Return type:

Album | List[Album]

The Album Class (mapped)

class _sqla.Album(**kwargs)

Bases: DigikamObject

Represents a row in the table Albums.

See also

property abspath: str

The album folder’s absolute path (read-only)

versionchanged:: 0.3.5

Converted to lowercase for case-insensitive roots (except mountpoint).

property caption: str

The album’s caption (description)

property collection: str

The album’s collection

This property is named Category in Digikam.

property date: date

The album’s date (read-only)

The date can be set in Digikam

property icon: Image | None

The album’s icon, if set

property id: int

The album’s id (read-only)

property images: List[Image]

The album’s images (no setter)

property modificationDate: datetime

The album’s modification date (read-only)

Raises:

DigikamVersionError – If DBVersion < 14

Added in version 0.2.2.

property relativePath: str

The album’s path relative to the root (read-only)

property root: AlbumRoot

The album collection’s root object (no setter)

The AlbumRoots Class

class digikamdb.albumroots.AlbumRoots(digikam, override=None)[source]

Bases: DigikamTable

Offers access to the album roots in the Digikam instance.

AlbumRoots represents all album roots present in the Digikam database. It is usually accessed through the Digikam property albumroots.

Usage:

dk = Digikam(...)
myroot = dk.albumroots[2]                           # by id
for root in dk.albumroots:                          # iterate
    print(root.relativePath)
Parameters:
  • digikam (Digikam) – Digikam object

  • override (Mapping | None) – Dict containing override information (Digikam passes its parameter root_override here)

See also

add(path, label=None, status=AlbumRootStatus.LocationAvailable, type_=AlbumRootType.UndefinedType, check_dir=True, use_uuid=True)[source]

Adds a new album root.

If check_dir is False, the identifier will be of path= type, and use_uuid is ignored. The identifier and relativePath are derifed from path.

To add albums and images in the new album root, start Digikam and scand for new objects.

Parameters:
  • path (str) – Path to new album root.

  • label (str | None) – Label of the new album root.

  • check_dir (bool) – Check if the directory exists and is not a subdir of another album root or vice versa.

  • status (AlbumRootStatus) – The new root’s status.

  • use_uuid (bool) – Use UUID of filesystem as identifier. If false, the is used as identifier.

  • type_ (AlbumRootType)

Returns:

The newly created AlbumRoot object.

Return type:

AlbumRoot

Note

The Digikam parameter root_override is ignored by this method.

The AlbumRoot Class (mapped)

class _sqla.AlbumRoot(**kwargs)

Bases: DigikamObject

Digikam Album Root

The location can be accessed with abspath.

Changed in version 0.3.5: * path in root checks if a path is a subdirectory (and thus a Digikam album) of the album root. The reverse is checked by issubdir().

See also

issubdir(path)

Checks if album root is a subdir of path.

Added in version 0.3.5.

Parameters:

path (str)

Return type:

bool

property abspath: str

The album root’s absolute path (read-only)

The result can be modified if root_override is specified in the Digikam constructor.

versionchanged:: 0.3.5

Converted to lowercase for case-insensitive roots (except mountpoint).

property albums: Iterable[Album]

The albums belonging to this root (no setter)

property caseSensitivity: bool

Indicates if this album root is case sensitive.

Raises:

DigikamVersionError – If DBVersion < 16

Added in version 0.2.2.

property id: int

The album root’s id (read-only)

property identifier: str

The album root’s identifier

This often contains the UUID of the file system that containst the album root.

property label: str

The album root’s label

property mountpoint: str

The volume’s mount point (read-only)

The result can be modified if root_override is specified in the Digikam constructor.

Changed in version 0.3.4: * Works if identifier contains multiple parameters. * Process mountpath parameter.

override = None
property specificPath: str

The album root’s path relative to identifier, starting with /

property status: AlbumRootStatus

The album root’s status (read-only)

This property is dynamically set by Digikam and only valid when Digikam is running.

property type: AlbumRootType

The album root’s type (hardwired, removable or network)

Types of special properties

class digikamdb.types.AlbumRootStatus(value)[source]

Bases: IntEnum

Class for AlbumRoot.status

LocationAvailable = 0
LocationUnavailable = 2
LocationHidden = 1
class digikamdb.types.AlbumRootType(value)[source]

Bases: IntEnum

Class for AlbumRoot.type

UndefinedType = 0
VolumeHardWired = 1
VolumeRemovable = 2
Network = 3