aioaudiobookshelf 0.1.8__py3-none-any.whl → 0.1.11__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of aioaudiobookshelf might be problematic. Click here for more details.

@@ -8,7 +8,7 @@ from aioaudiobookshelf.exceptions import LoginError, TokenIsMissingError
8
8
  from aioaudiobookshelf.helpers import get_login_response
9
9
  from aioaudiobookshelf.schema.calls_login import AuthorizeResponse
10
10
 
11
- __version__ = "0.1.8"
11
+ __version__ = "0.1.11"
12
12
 
13
13
 
14
14
  async def _get_authorize_response(*, session_config: SessionConfiguration) -> AuthorizeResponse:
@@ -73,6 +73,7 @@ class BaseClient:
73
73
  ssl=self.session_config.verify_ssl,
74
74
  headers=self.session_config.headers,
75
75
  raise_for_status=True,
76
+ timeout=self.session_config.timeout,
76
77
  )
77
78
 
78
79
  try:
@@ -82,17 +83,16 @@ class BaseClient:
82
83
  if self.session_config.auto_refresh:
83
84
  self.logger.debug("Auto refreshing tokens.")
84
85
  await self.refresh()
86
+ # TODO: remove redundant clause
87
+ try:
88
+ response = await _request()
89
+ except ClientResponseError as inner_exc:
90
+ raise ApiError(f"API POST call to {endpoint} failed.") from inner_exc
85
91
  else:
86
92
  raise AccessTokenExpiredError from exc
87
93
  else:
88
94
  raise ApiError(f"API POST call to {endpoint} failed.") from exc
89
95
 
90
- # TODO: remove redundant clause
91
- try:
92
- response = await _request()
93
- except ClientResponseError as exc:
94
- raise ApiError(f"API POST call to {endpoint} failed.") from exc
95
-
96
96
  return await response.read()
97
97
 
98
98
  async def _get(self, endpoint: str, params: dict[str, str | int] | None = None) -> bytes:
@@ -104,6 +104,7 @@ class BaseClient:
104
104
  params=params,
105
105
  ssl=self.session_config.verify_ssl,
106
106
  headers=self.session_config.headers,
107
+ timeout=self.session_config.timeout,
107
108
  )
108
109
 
109
110
  response = await _request()
@@ -132,6 +133,7 @@ class BaseClient:
132
133
  ssl=self.session_config.verify_ssl,
133
134
  headers=self.session_config.headers,
134
135
  raise_for_status=True,
136
+ timeout=self.session_config.timeout,
135
137
  )
136
138
 
137
139
  try:
@@ -141,16 +143,15 @@ class BaseClient:
141
143
  if self.session_config.auto_refresh:
142
144
  self.logger.debug("Auto refreshing tokens.")
143
145
  await self.refresh()
146
+ try:
147
+ await _request()
148
+ except ClientResponseError as inner_exc:
149
+ raise ApiError(f"API PATCH call to {endpoint} failed.") from inner_exc
144
150
  else:
145
151
  raise AccessTokenExpiredError from exc
146
152
  else:
147
153
  raise ApiError(f"API PATCH call to {endpoint} failed.") from exc
148
154
 
149
- try:
150
- await _request()
151
- except ClientResponseError as exc:
152
- raise ApiError(f"API PATCH call to {endpoint} failed.") from exc
153
-
154
155
  async def _delete(self, endpoint: str) -> None:
155
156
  """DELETE request to abs api."""
156
157
 
@@ -160,6 +161,7 @@ class BaseClient:
160
161
  ssl=self.session_config.verify_ssl,
161
162
  headers=self.session_config.headers,
162
163
  raise_for_status=True,
164
+ timeout=self.session_config.timeout,
163
165
  )
164
166
 
165
167
  try:
@@ -169,16 +171,15 @@ class BaseClient:
169
171
  if self.session_config.auto_refresh:
170
172
  self.logger.debug("Auto refreshing tokens.")
171
173
  await self.refresh()
174
+ try:
175
+ await _request()
176
+ except ClientResponseError as inner_exc:
177
+ raise ApiError(f"API DELETE call to {endpoint} failed.") from inner_exc
172
178
  else:
173
179
  raise AccessTokenExpiredError from exc
174
180
  else:
175
181
  raise ApiError(f"API DELETE call to {endpoint} failed.") from exc
176
182
 
177
- try:
178
- await _request()
179
- except ClientResponseError as exc:
180
- raise ApiError(f"API DELETE call to {endpoint} failed.") from exc
181
-
182
183
  async def refresh(self) -> None:
183
184
  """Refresh tokens."""
184
185
  await self.session_config.refresh()
@@ -1,10 +1,19 @@
1
1
  """Calls to /api/authors."""
2
2
 
3
+ from enum import StrEnum
4
+
3
5
  from aioaudiobookshelf.client._base import BaseClient
4
6
  from aioaudiobookshelf.schema.author import Author
5
7
  from aioaudiobookshelf.schema.calls_authors import AuthorWithItems, AuthorWithItemsAndSeries
6
8
 
7
9
 
10
+ class AuthorImageFormat(StrEnum):
11
+ """AuthorImageFormat."""
12
+
13
+ JPEG = "jpeg"
14
+ WEBP = "webp"
15
+
16
+
8
17
  class AuthorsClient(BaseClient):
9
18
  """AuthorsClient."""
10
19
 
@@ -31,4 +40,18 @@ class AuthorsClient(BaseClient):
31
40
 
32
41
  # update author
33
42
  # match author
34
- # get author image
43
+ async def get_author_image(
44
+ self,
45
+ *,
46
+ author_id: str,
47
+ width: int = 400,
48
+ height: int | None = None,
49
+ format_: AuthorImageFormat = AuthorImageFormat.JPEG,
50
+ raw: bool = False,
51
+ ) -> bytes:
52
+ """Get image of author. If height is None, image is scaled proportionally."""
53
+ endpoint = f"/api/authors/{author_id}/image"
54
+ params = {"width": width, "format": format_.value, "raw": int(raw)}
55
+ if height:
56
+ params["height"] = height
57
+ return await self._get(endpoint, params=params)
@@ -1,7 +1,10 @@
1
1
  """Calls to /api/session."""
2
2
 
3
3
  from aioaudiobookshelf.client._base import BaseClient
4
- from aioaudiobookshelf.schema.calls_session import CloseOpenSessionsParameters
4
+ from aioaudiobookshelf.schema.calls_session import (
5
+ CloseOpenSessionsParameters,
6
+ SyncOpenSessionParameters,
7
+ )
5
8
  from aioaudiobookshelf.schema.session import PlaybackSessionExpanded
6
9
 
7
10
 
@@ -24,7 +27,11 @@ class SessionClient(BaseClient):
24
27
  )
25
28
  return psession
26
29
 
27
- # sync open session
30
+ async def sync_open_session(
31
+ self, *, session_id: str, parameters: SyncOpenSessionParameters
32
+ ) -> None:
33
+ """Sync an open session."""
34
+ await self._post(f"/api/session/{session_id}/sync", data=parameters.to_dict())
28
35
 
29
36
  async def close_open_session(
30
37
  self, *, session_id: str, parameters: CloseOpenSessionsParameters | None = None
@@ -4,7 +4,7 @@ import asyncio
4
4
  import logging
5
5
  from dataclasses import dataclass
6
6
 
7
- from aiohttp.client import ClientSession
7
+ from aiohttp.client import DEFAULT_TIMEOUT, ClientSession, ClientTimeout
8
8
  from aiohttp.client_exceptions import ClientResponseError
9
9
 
10
10
  from aioaudiobookshelf.exceptions import (
@@ -32,6 +32,7 @@ class SessionConfiguration:
32
32
  refresh_token: str | None = None # > v2.26
33
33
  auto_refresh: bool = True # automatically refresh access token, should it be expired.
34
34
  pagination_items_per_page: int = 10
35
+ timeout: ClientTimeout = DEFAULT_TIMEOUT
35
36
  logger: logging.Logger | None = None
36
37
 
37
38
  @property
@@ -18,7 +18,7 @@ class EBookFile(_BaseModel):
18
18
 
19
19
  ino: str
20
20
  metadata: FileMetadata
21
- ebook_format: Annotated[str, Alias("ebookFormat")]
21
+ ebook_format: Annotated[str | None, Alias("ebookFormat")] = None
22
22
  added_at: Annotated[int, Alias("addedAt")] # time in ms since unix epoch
23
23
  updated_at: Annotated[int, Alias("updatedAt")] # time in ms since unix epoch
24
24
 
@@ -15,3 +15,6 @@ class CloseOpenSessionsParameters(_BaseModel):
15
15
  current_time: Annotated[float, Alias("currentTime")]
16
16
  time_listened: Annotated[float, Alias("timeListened")]
17
17
  duration: float
18
+
19
+
20
+ SyncOpenSessionParameters = CloseOpenSessionsParameters
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aioaudiobookshelf
3
- Version: 0.1.8
3
+ Version: 0.1.11
4
4
  Summary: Async library for Audiobookshelf
5
5
  Author-email: Fabian Munkes <105975993+fmunkes@users.noreply.github.com>
6
6
  License: Apache-2.0
@@ -1,9 +1,9 @@
1
- aioaudiobookshelf/__init__.py,sha256=qJeq9-dgajENDo6mWUr_LJ8NRSQFFFooL1cjgHMd6wI,3507
1
+ aioaudiobookshelf/__init__.py,sha256=xebDvWxDTQNfKKQi9I9V7yKxke3WZoBks6e2nYDPle8,3508
2
2
  aioaudiobookshelf/exceptions.py,sha256=G3z99KrxHoSoj7kpSRVpa7Rp_RkL3jmW6266ak8h_p0,661
3
3
  aioaudiobookshelf/helpers.py,sha256=gvoBWsu6PSiGYyXe5BH9TP6WydzAMp_6Ye9RUivvk9Y,2700
4
4
  aioaudiobookshelf/client/__init__.py,sha256=6xwDrY0xWWC8cXHn5GK3Mc1jPpmmtfJ9HGO9aryKL8U,7993
5
- aioaudiobookshelf/client/_base.py,sha256=eQjybEvl79GmvLUCJKTJmuivrF9fTo6SEt_W0BHYbSw,7183
6
- aioaudiobookshelf/client/authors.py,sha256=8bXN0NsPvH1rvF166xUu7rVC-0P0Sp4N7oxZrO666nc,1129
5
+ aioaudiobookshelf/client/_base.py,sha256=J_RjItJFaq17Po66aEzwrpq6PiCns3xYXWAtewy48K0,7584
6
+ aioaudiobookshelf/client/authors.py,sha256=9F8_tiTqh-5Srn_5I0wdEa1qs_495UctzSF6OlxFOJw,1808
7
7
  aioaudiobookshelf/client/collections_.py,sha256=Z3r7dxHhzMm_cGCMRJkVzN5-Eesftib3d0bs4iXmmzY,879
8
8
  aioaudiobookshelf/client/items.py,sha256=4yWy7Shd6sbKj4MSGYJXklXs-yZH2q95qGIm4L-PS5o,3624
9
9
  aioaudiobookshelf/client/libraries.py,sha256=VK1VqX9V6_8PAhPVx-eIPOgsS8t_U1a6iFML2nOyi14,6852
@@ -11,12 +11,12 @@ aioaudiobookshelf/client/me.py,sha256=cYmXNoFJHZgEI6Ds19Pf6gNQMBVOqrtcKmiyXHFFIL
11
11
  aioaudiobookshelf/client/playlists.py,sha256=sTsmuBqjSlKyTo31mc9Ha-WtzX7bh0hH7n1BcnlO7YY,875
12
12
  aioaudiobookshelf/client/podcasts.py,sha256=f1ECD43cn4EIwWpRvwM_RosfzDr8popFDFbRYgCZQxs,684
13
13
  aioaudiobookshelf/client/series.py,sha256=bS4RO8k1Im5wpeKt0oNcBSeeZCRIGCi9otTCEOy7xMo,820
14
- aioaudiobookshelf/client/session.py,sha256=YWv4GkrW5fMbq1AdnMOWQHM_YzAH1U6varzsyXlP0Jc,1249
15
- aioaudiobookshelf/client/session_configuration.py,sha256=AbDYT2OixncuStLz0ovMF83RNuyHTKKHdzaJKqSL7X0,3881
14
+ aioaudiobookshelf/client/session.py,sha256=1eMI_caj6dSTtyC3aqKgLCDqWLEOodFtBkEGoqTOmnw,1508
15
+ aioaudiobookshelf/client/session_configuration.py,sha256=_Y-uDA9iW87siiN9xe-pCOxMS0V41Fl6MGWY4EuZ1tA,3958
16
16
  aioaudiobookshelf/schema/__init__.py,sha256=vEEwPVweT0j2VqlBj2V34Xk5J9OBZ7zkd6eLOUx-RdU,358
17
17
  aioaudiobookshelf/schema/audio.py,sha256=PFKkGsZgJSDYJS-7VwoTvYTcVfR8ip8qOuE8hQa9TtE,2105
18
18
  aioaudiobookshelf/schema/author.py,sha256=OZGcCUHOfXvN8N2SRUiIRnDS2Lz3UrQFWOaOZ1sKV0U,976
19
- aioaudiobookshelf/schema/book.py,sha256=Ckfc_eC6jXtQnQQzl0QaB0edp91G8gIiUJTE7IfctuM,3372
19
+ aioaudiobookshelf/schema/book.py,sha256=mf_PZqClvbfoxUQtm88Cqz14xT-594NZPi6nkQe1_Hk,3386
20
20
  aioaudiobookshelf/schema/calls_authors.py,sha256=eIvdyEcrmXuOxFJuCX39cGU9HSZprl40yKn8s2VjfAM,703
21
21
  aioaudiobookshelf/schema/calls_collections.py,sha256=nXurha41Y1atAuOWG9aXJbYo66qgcFUaW02QPEVdo4w,319
22
22
  aioaudiobookshelf/schema/calls_items.py,sha256=KF8s6WNbsVUIxAuN9TZBBGsysnxfw-FQWM9XRTljOpo,1547
@@ -25,7 +25,7 @@ aioaudiobookshelf/schema/calls_login.py,sha256=DpIBtAzg5uQtS0CLDfEXHkOh_RGfDI5ep
25
25
  aioaudiobookshelf/schema/calls_me.py,sha256=jdpvExRytoqX8FHkzq4N9RtKn50cmTc_B693e9lLCHQ,693
26
26
  aioaudiobookshelf/schema/calls_playlists.py,sha256=Ll1scstd1NNc6PXgkhmWUfqSzIR07LKzqBCEvrVHACE,305
27
27
  aioaudiobookshelf/schema/calls_series.py,sha256=aUdlTR01UE2APN0pGS1h7x0ydsREqZf53mKaHq2zeh4,597
28
- aioaudiobookshelf/schema/calls_session.py,sha256=j2NLUwS4820SwzqPXksteTACXtUXvNtio_wBfvwHHM0,416
28
+ aioaudiobookshelf/schema/calls_session.py,sha256=E90uPxkZrV1FUTSYS9owbzTm8HaRjH4CRmb88XrGqOA,474
29
29
  aioaudiobookshelf/schema/collection.py,sha256=fB1VFQXE0hzM_NyWEHj9A11VztD_8rYo4t9OWkDj-Lc,883
30
30
  aioaudiobookshelf/schema/events_socket.py,sha256=r24ssixH0dWfyOhv0K5P6GgzGrbYC9Yh8Y2w76-bkeM,1420
31
31
  aioaudiobookshelf/schema/file.py,sha256=frymCwsiqOh6fnZPBnkUz1pfyUuKkH4ssRd2WHpsajk,639
@@ -40,8 +40,8 @@ aioaudiobookshelf/schema/server.py,sha256=yWBRxtwtX1USs43yGFuDIM3jfWbmduW3GRahis
40
40
  aioaudiobookshelf/schema/session.py,sha256=jqCHNUthuzE6jhgG3UwFgagl1HA_rfDwn6Te38jaqC8,2684
41
41
  aioaudiobookshelf/schema/shelf.py,sha256=npPr5iacm6b5FfJYF9_lFZaitJNJ3SVvBOScbxlF5MQ,5064
42
42
  aioaudiobookshelf/schema/user.py,sha256=cm2Oev9i062mjM3Ku-yaAjm_o4-sJOkJTczdq43_qrY,2485
43
- aioaudiobookshelf-0.1.8.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
44
- aioaudiobookshelf-0.1.8.dist-info/METADATA,sha256=lnsXI8B8rQsaaoQ2NCDEpd4hD8s9lSPX25r6COqV69o,4405
45
- aioaudiobookshelf-0.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
46
- aioaudiobookshelf-0.1.8.dist-info/top_level.txt,sha256=2_I2_xz98xmVIT84pcF3tlq3NdZNKskfs7BqUmYZylk,18
47
- aioaudiobookshelf-0.1.8.dist-info/RECORD,,
43
+ aioaudiobookshelf-0.1.11.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
44
+ aioaudiobookshelf-0.1.11.dist-info/METADATA,sha256=uMPo-whmeNF-pi58S6OOA-7vejepwzgNS4lcTfodzvM,4406
45
+ aioaudiobookshelf-0.1.11.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
46
+ aioaudiobookshelf-0.1.11.dist-info/top_level.txt,sha256=2_I2_xz98xmVIT84pcF3tlq3NdZNKskfs7BqUmYZylk,18
47
+ aioaudiobookshelf-0.1.11.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5