Skip to main content

aioaudiobookshelf

Async python library to interact with Audiobookshelf (ABS).

This lib's primary goal is to be used within the Audiobookshelf music provider in Music Assistant, but it can be used independently. Calls to endpoints not needed for the provider will be added over time.

Not all endpoints are yet implemented.

Issues

If you are facing issues with this lib or the audiobookshelf provider, please use our support repository for reporting them.

Releases

Releases can be found on pypi, and are tagged.

Basic usage

ABS has a rest api, documented here and additionally uses socket.io, see here for some event driven functionality. Accessibility to the endpoints is determined by the user types, which may be root, admin, user, guest. This lib is not tested with a guest user.

As of 0.1.2 this lib has two different clients, the UserClient and the SocketClient. Admin endpoints are not yet implemented. The user client handles calls to the Rest API, the socket client allows to subscribe to certain events.

To authenticate the socket client, you always need the user's token, username and password are not enough. The user client can be authenticated by username and password, which yields the token.

Usage example:

import asyncio
import logging
import os

import aiohttp

from aioaudiobookshelf import SessionConfiguration, get_user_client
from aioaudiobookshelf.schema.library import LibraryItemMinifiedBook, LibraryItemMinifiedPodcast

ABS_HOST = os.environ.get("ABS_HOST")
ABS_USER = os.environ.get("ABS_USER")
ABS_PASSWORD = os.environ.get("ABS_PASSWORD")


async def abs_basics():
    assert ABS_HOST is not None
    assert ABS_USER is not None
    assert ABS_PASSWORD is not None

    logger = logging.getLogger()
    logger.setLevel(logging.INFO)

    async with aiohttp.ClientSession() as session:
        client = await get_user_client(
            session_config=SessionConfiguration(
                session=session, url=ABS_HOST, logger=logger, pagination_items_per_page=30
            ),
            username=ABS_USER,
            password=ABS_PASSWORD,
        )

        # get libraries
        libraries = await client.get_all_libraries()

        # get library items
        for library in libraries:
            async for response in client.get_library_items(library_id=library.id_):
                if not response.results:
                    break
                for lib_item_minified in response.results:
                    if isinstance(lib_item_minified, LibraryItemMinifiedPodcast):
                        ...
                    if isinstance(lib_item_minified, LibraryItemMinifiedBook):
                        ...

        # get a single podcast
        podcast_id = "dda96167-eaad-4012-83e1-149c6700d3e8"
        podcast_expanded = await client.get_library_item_podcast(podcast_id=podcast_id, expanded=True)


asyncio.run(abs_basics())

Have a look into aioaudiobookshelf/client/*.py to see which endpoints are currently implemented. And the provider implementation shows, how the lib can potentially be used.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioaudiobookshelf-0.1.24.tar.gz (30.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aioaudiobookshelf-0.1.24-py3-none-any.whl (44.5 kB view details)

Uploaded Python 3

File details

Details for the file aioaudiobookshelf-0.1.24.tar.gz.

File metadata

  • Download URL: aioaudiobookshelf-0.1.24.tar.gz
  • Upload date:
  • Size: 30.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for aioaudiobookshelf-0.1.24.tar.gz
Algorithm Hash digest
SHA256 469df77d10ebc2df3d06f9ed3d83195c32981ceed0a0e05922b9e3f38fe78856
MD5 294e4181d2c03ed4dcc3fbda575ec070
BLAKE2b-256 0f20b81452bc2a0acd1937c6e4665da4bfd5d0e76c7e86bff7a10e48b6e80e7d

See more details on using hashes here.

File details

Details for the file aioaudiobookshelf-0.1.24-py3-none-any.whl.

File metadata

File hashes

Hashes for aioaudiobookshelf-0.1.24-py3-none-any.whl
Algorithm Hash digest
SHA256 dfa7ad29365e2287112821918684cf9da2d9c4725ff7fe33fea8dedbe02f8c82
MD5 45050e206f3a9b10bd85cd2d78bc5ddc
BLAKE2b-256 b3e39d4e49d57847364251a624bc87c51abb67b18daa6d5884a7fc560d427b74

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.25

2 files

This release

0.1.24 This release

2 files

0.1.22

2 files

0.1.21

2 files

0.1.20

2 files

0.1.19

2 files

0.1.18

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page