sok.apis.music.musicbrainz_api
MusicBrainz API implementation.
API Documentation: https://musicbrainz.org/doc/MusicBrainz_API Note: Free API, no authentication required. Rate limit: 1 request/second.
MusicBrainzApi
class MusicBrainzApi()Bases: BaseAPI
MusicBrainz API implementation for music metadata.
MusicBrainz is an open music encyclopedia that collects music metadata and makes it available to the public. No API key required.
Initialize MusicBrainz API (no API key required).
SourceAttributes
| Name |
|---|
MIN_INTERVAL |
USER_AGENT |
supported_content_typesproperty
List[ContentType]
Get supported content types.
supported_media_typesproperty
List[MediaType]
Get supported media types.
get_detailsasync
async def get_details( item_id: str, content_type: ContentType, **kwargs,) -> Dict[str, Any]:Get detailed information from MusicBrainz.
Parameters
| Name | Type | Description |
|---|---|---|
item_id | str | MusicBrainz ID (MBID). |
content_type | ContentType | Type of content. |
**kwargs | Additional parameters. |
Returns
Dict[str, Any]Detailed information dictionary.
get_related_itemsasync
async def get_related_items( item_id: str, content_type: ContentType, **kwargs,) -> List[Dict[str, Any]]:Get related items (not supported by MusicBrainz).
Parameters
| Name | Type | Description |
|---|---|---|
item_id | str | MusicBrainz item ID. |
content_type | ContentType | Type of content. |
**kwargs | Additional parameters. |
Returns
List[Dict[str, Any]]Empty list as MusicBrainz doesn't have this endpoint.
searchasync
async def search( query: str, content_type: ContentType, **kwargs,) -> Dict[str, Any]:Search for music on MusicBrainz.
Parameters
| Name | Type | Description |
|---|---|---|
query | str | Search query. |
content_type | ContentType | Type of content (ALBUM, TRACK, ARTIST). |
**kwargs | Additional parameters (max_results). |
Returns
Dict[str, Any]Search results with 'results' key.
Attributes
| Name | Value |
|---|---|
BUSY_RETRIES | 2 |
BUSY_WAIT | 2.0 |
OTHER_RELEASES | {'compilation', 'live', 'remix'} |
logger | logging.getLogger(__name__) |