Library#
- class beets.library.Library(path='library.blb', directory: str | None = None, path_formats=(('default', '$artist/$album/$track $title'),), replacements=None)[source]#
Bases:
DatabaseA database of music containing songs and albums.
- __init__(path='library.blb', directory: str | None = None, path_formats=(('default', '$artist/$album/$track $title'),), replacements=None)[source]#
Public methods summary
add(obj)add_album(items)Create a new album consisting of a list of items.
add_functions(conn)albums([query, sort])Get
Albumobjects matching the query.get_album(item_or_id)Given an album ID or an item associated with an album, return a
Albumobject for the album.Get a
Sortobject for albums from the config option.Get a
Sortobject for items from the config option.get_item(id_)Fetch a
Itemby its ID.items([query, sort])Get
Itemobjects matching the query.load_extension(path)Load an SQLite extension into all open connections.
migration_exists(name, table)Return whether a named migration has been marked complete.
record_migration(name, table)Set completion state for a named migration.
Get a
Transactionobject for interacting directly with the underlying SQLite database.Methods definition
- add_album(items)[source]#
Create a new album consisting of a list of items.
The items are added to the database if they don't yet have an ID. Return a new
Albumobject. The list items must not be empty.
- get_album(item_or_id: Item | int) Album | None[source]#
Given an album ID or an item associated with an album, return a
Albumobject for the album.If no such album exists, return None.
- load_extension(path: str)#
Load an SQLite extension into all open connections.
- migration_exists(name: str, table: str) bool#
Return whether a named migration has been marked complete.
- record_migration(name: str, table: str) None#
Set completion state for a named migration.
- revision = 0#
The current revision of the database. To be increased whenever data is written in a transaction.
- supports_extensions = True#
Whether or not the current version of SQLite supports extensions
- transaction() Transaction#
Get a
Transactionobject for interacting directly with the underlying SQLite database.