Async library for Audiobookshelf
Project description
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.
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 = 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aioaudiobookshelf-0.1.4.tar.gz.
File metadata
- Download URL: aioaudiobookshelf-0.1.4.tar.gz
- Upload date:
- Size: 25.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af95c903d509b3ac82c71bfbb0d35558e11f79cc46ab7cfe020f9431fe2921bc
|
|
| MD5 |
a1b6b718905de470c3c5cd0467f58185
|
|
| BLAKE2b-256 |
7984709b4aa7ca2a1de21640e31850053575f5f4c17d2dd26ea3d772c39005d9
|
File details
Details for the file aioaudiobookshelf-0.1.4-py3-none-any.whl.
File metadata
- Download URL: aioaudiobookshelf-0.1.4-py3-none-any.whl
- Upload date:
- Size: 37.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1b4d76275310e72fc3815c209f5b858cb5aad5ce3447ea88f84a24789d22325
|
|
| MD5 |
7b668dcebd0ea241cd705432235aebdc
|
|
| BLAKE2b-256 |
34f627a51b40d0eb0cfd511207c8cc810d0ba125d2e9d3866f132988271f6b27
|