aioaudiobookshelf 0.1.0__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.

Files changed (45) hide show
  1. aioaudiobookshelf/__init__.py +72 -0
  2. aioaudiobookshelf/client/__init__.py +189 -0
  3. aioaudiobookshelf/client/_base.py +110 -0
  4. aioaudiobookshelf/client/authors.py +34 -0
  5. aioaudiobookshelf/client/collections_.py +28 -0
  6. aioaudiobookshelf/client/items.py +108 -0
  7. aioaudiobookshelf/client/libraries.py +173 -0
  8. aioaudiobookshelf/client/me.py +103 -0
  9. aioaudiobookshelf/client/playlists.py +29 -0
  10. aioaudiobookshelf/client/podcasts.py +22 -0
  11. aioaudiobookshelf/client/series.py +27 -0
  12. aioaudiobookshelf/client/session.py +35 -0
  13. aioaudiobookshelf/exceptions.py +13 -0
  14. aioaudiobookshelf/helpers.py +56 -0
  15. aioaudiobookshelf/schema/__init__.py +14 -0
  16. aioaudiobookshelf/schema/audio.py +71 -0
  17. aioaudiobookshelf/schema/author.py +46 -0
  18. aioaudiobookshelf/schema/book.py +125 -0
  19. aioaudiobookshelf/schema/calls_authors.py +33 -0
  20. aioaudiobookshelf/schema/calls_collections.py +14 -0
  21. aioaudiobookshelf/schema/calls_items.py +53 -0
  22. aioaudiobookshelf/schema/calls_library.py +103 -0
  23. aioaudiobookshelf/schema/calls_login.py +28 -0
  24. aioaudiobookshelf/schema/calls_me.py +28 -0
  25. aioaudiobookshelf/schema/calls_playlists.py +14 -0
  26. aioaudiobookshelf/schema/calls_series.py +25 -0
  27. aioaudiobookshelf/schema/calls_session.py +17 -0
  28. aioaudiobookshelf/schema/collection.py +36 -0
  29. aioaudiobookshelf/schema/events_socket.py +46 -0
  30. aioaudiobookshelf/schema/file.py +22 -0
  31. aioaudiobookshelf/schema/folder.py +18 -0
  32. aioaudiobookshelf/schema/library.py +221 -0
  33. aioaudiobookshelf/schema/media_progress.py +42 -0
  34. aioaudiobookshelf/schema/playlist.py +74 -0
  35. aioaudiobookshelf/schema/podcast.py +129 -0
  36. aioaudiobookshelf/schema/series.py +45 -0
  37. aioaudiobookshelf/schema/series_books.py +34 -0
  38. aioaudiobookshelf/schema/server.py +76 -0
  39. aioaudiobookshelf/schema/session.py +78 -0
  40. aioaudiobookshelf/schema/user.py +81 -0
  41. aioaudiobookshelf-0.1.0.dist-info/LICENSE +201 -0
  42. aioaudiobookshelf-0.1.0.dist-info/METADATA +32 -0
  43. aioaudiobookshelf-0.1.0.dist-info/RECORD +45 -0
  44. aioaudiobookshelf-0.1.0.dist-info/WHEEL +5 -0
  45. aioaudiobookshelf-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,125 @@
1
+ """Schema for Books."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Annotated
5
+
6
+ from mashumaro.types import Alias
7
+
8
+ from . import _BaseModel
9
+ from .audio import AudioFile, AudioTrack
10
+ from .author import AuthorMinified
11
+ from .file import FileMetadata
12
+ from .series import SeriesSequence
13
+
14
+
15
+ @dataclass(kw_only=True)
16
+ class EBookFile(_BaseModel):
17
+ """EBookFile."""
18
+
19
+ ino: str
20
+ metadata: FileMetadata
21
+ ebook_format: Annotated[str, Alias("ebookFormat")]
22
+ added_at: Annotated[int, Alias("addedAt")] # time in ms since unix epoch
23
+ updated_at: Annotated[int, Alias("updatedAt")] # time in ms since unix epoch
24
+
25
+
26
+ @dataclass(kw_only=True)
27
+ class BookChapter(_BaseModel):
28
+ """
29
+ BookChapter. No variants.
30
+
31
+ https://api.audiobookshelf.org/#book-chapter
32
+ """
33
+
34
+ id_: Annotated[int, Alias("id")]
35
+ start: float
36
+ end: float
37
+ title: str
38
+
39
+
40
+ @dataclass(kw_only=True)
41
+ class _BookMetadataBase(_BaseModel):
42
+ """_BookMetadataBase."""
43
+
44
+ title: str | None = None
45
+ subtitle: str | None = None
46
+ genres: list[str]
47
+ published_year: Annotated[str | None, Alias("publishedYear")] = None
48
+ published_date: Annotated[str | None, Alias("publishedDate")] = None
49
+ publisher: str | None = None
50
+ description: str | None = None
51
+ isbn: str | None = None
52
+ asin: str | None = None
53
+ language: str | None = None
54
+ explicit: bool
55
+
56
+
57
+ @dataclass(kw_only=True)
58
+ class BookMetadata(_BookMetadataBase):
59
+ """BookMetadata."""
60
+
61
+ authors: list[AuthorMinified]
62
+ narrators: list[str]
63
+ series: list[SeriesSequence]
64
+
65
+
66
+ @dataclass(kw_only=True)
67
+ class BookMetadataMinified(_BookMetadataBase):
68
+ """BookMetadataMinified."""
69
+
70
+ title_ignore_prefix: Annotated[str, Alias("titleIgnorePrefix")]
71
+ author_name: Annotated[str, Alias("authorName")]
72
+ author_name_lf: Annotated[str, Alias("authorNameLF")]
73
+ narrator_name: Annotated[str, Alias("narratorName")]
74
+ series_name: Annotated[str, Alias("seriesName")]
75
+
76
+
77
+ @dataclass(kw_only=True)
78
+ class BookMetadataExpanded(BookMetadata, BookMetadataMinified):
79
+ """BookMetadataExpanded."""
80
+
81
+
82
+ @dataclass(kw_only=True)
83
+ class _BookBase(_BaseModel):
84
+ """_BookBase."""
85
+
86
+ tags: list[str]
87
+ cover_path: Annotated[str | None, Alias("coverPath")] = None
88
+
89
+
90
+ @dataclass(kw_only=True)
91
+ class Book(_BookBase):
92
+ """Book."""
93
+
94
+ library_item_id: Annotated[str, Alias("libraryItemId")]
95
+ metadata: BookMetadata
96
+ audio_files: Annotated[list[AudioFile], Alias("audioFiles")]
97
+ chapters: list[BookChapter]
98
+ ebook_file: Annotated[EBookFile | None, Alias("ebookFile")] = None
99
+
100
+
101
+ @dataclass(kw_only=True)
102
+ class BookMinified(_BookBase):
103
+ """BookMinified."""
104
+
105
+ metadata: BookMetadataMinified
106
+ num_tracks: Annotated[int, Alias("numTracks")]
107
+ num_audiofiles: Annotated[int, Alias("numAudioFiles")]
108
+ num_chapters: Annotated[int, Alias("numChapters")]
109
+ duration: float # in s
110
+ size: int # in bytes
111
+ ebook_format: Annotated[str | None, Alias("ebookFormat")] = None
112
+
113
+
114
+ @dataclass(kw_only=True)
115
+ class BookExpanded(_BookBase):
116
+ """BookExpanded."""
117
+
118
+ library_item_id: Annotated[str, Alias("libraryItemId")]
119
+ metadata: BookMetadataExpanded
120
+ audio_files: Annotated[list[AudioFile], Alias("audioFiles")]
121
+ chapters: list[BookChapter]
122
+ ebook_file: Annotated[EBookFile | None, Alias("ebookFile")] = None
123
+ duration: float
124
+ size: int # bytes
125
+ tracks: list[AudioTrack]
@@ -0,0 +1,33 @@
1
+ """Calls to /api/authors."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Annotated
5
+
6
+ from mashumaro.types import Alias
7
+
8
+ from . import _BaseModel
9
+ from .author import Author
10
+ from .library import LibraryItemMinified
11
+
12
+
13
+ @dataclass(kw_only=True)
14
+ class AuthorSeries(_BaseModel):
15
+ """AuthorSeries."""
16
+
17
+ id_: Annotated[str, Alias("id")]
18
+ name: str
19
+ items: list[LibraryItemMinified]
20
+
21
+
22
+ @dataclass(kw_only=True)
23
+ class AuthorWithItems(Author):
24
+ """AuthorWithItems."""
25
+
26
+ library_items: Annotated[list[LibraryItemMinified], Alias("libraryItems")]
27
+
28
+
29
+ @dataclass(kw_only=True)
30
+ class AuthorWithItemsAndSeries(AuthorWithItems):
31
+ """AuthorWithItemsAndSeries."""
32
+
33
+ series: list[AuthorSeries]
@@ -0,0 +1,14 @@
1
+ """Params and responses for collections."""
2
+
3
+ from dataclasses import dataclass
4
+
5
+ from aioaudiobookshelf.schema.collection import CollectionExpanded
6
+
7
+ from . import _BaseModel
8
+
9
+
10
+ @dataclass(kw_only=True)
11
+ class AllCollectionsResponse(_BaseModel):
12
+ """AllCollectionsResponse."""
13
+
14
+ collections: list[CollectionExpanded]
@@ -0,0 +1,53 @@
1
+ """Calls for items."""
2
+
3
+ from dataclasses import dataclass, field
4
+ from typing import Annotated
5
+
6
+ from mashumaro.types import Alias
7
+
8
+ from aioaudiobookshelf.schema import _BaseModel
9
+ from aioaudiobookshelf.schema.library import (
10
+ LibraryItemExpandedBook,
11
+ LibraryItemExpandedPodcast,
12
+ )
13
+ from aioaudiobookshelf.schema.session import DeviceInfo
14
+
15
+
16
+ @dataclass(kw_only=True)
17
+ class PlayParameters(_BaseModel):
18
+ """PlayParameters.
19
+
20
+ https://api.audiobookshelf.org/#play-a-library-item-or-podcast-episode
21
+ """
22
+
23
+ device_info: Annotated[DeviceInfo, Alias("deviceInfo")]
24
+ force_direct_play: Annotated[bool, Alias("forceDirectPlay")] = False
25
+ force_transcode: Annotated[bool, Alias("forceTranscode")] = False
26
+ supported_mime_types: Annotated[list[str], Alias("supportedMimeTypes")] = field(
27
+ default_factory=list
28
+ )
29
+ media_player: Annotated[str, Alias("mediaPlayer")] = "unknown"
30
+
31
+
32
+ PlaybackSessionParameters = PlayParameters
33
+
34
+
35
+ @dataclass(kw_only=True)
36
+ class LibraryItemsBatchParameters(_BaseModel):
37
+ """GetLibraryItemsBatchParameters."""
38
+
39
+ library_item_ids: Annotated[list[str], Alias("libraryItemIds")]
40
+
41
+
42
+ @dataclass(kw_only=True)
43
+ class LibraryItemsBatchBookResponse(_BaseModel):
44
+ """GetLibraryItemsBatchBookResponse."""
45
+
46
+ library_items: Annotated[list[LibraryItemExpandedBook], Alias("libraryItems")]
47
+
48
+
49
+ @dataclass(kw_only=True)
50
+ class LibraryItemsBatchPodcastResponse(_BaseModel):
51
+ """GetLibraryItemsBatchBookResponse."""
52
+
53
+ library_items: Annotated[list[LibraryItemExpandedPodcast], Alias("libraryItems")]
@@ -0,0 +1,103 @@
1
+ """Calls for Libraries."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Annotated
5
+
6
+ from mashumaro.types import Alias
7
+
8
+ from aioaudiobookshelf.schema.author import AuthorExpanded, Narrator
9
+ from aioaudiobookshelf.schema.collection import Collection, CollectionExpanded
10
+ from aioaudiobookshelf.schema.playlist import PlaylistExpanded
11
+ from aioaudiobookshelf.schema.series_books import SeriesBooks, SeriesBooksMinified
12
+
13
+ from . import _BaseModel
14
+ from .library import Library, LibraryFilterData, LibraryItem, LibraryItemMinified
15
+
16
+
17
+ @dataclass(kw_only=True)
18
+ class AllLibrariesResponse(_BaseModel):
19
+ """LibrariesResponse."""
20
+
21
+ libraries: list[Library]
22
+
23
+
24
+ @dataclass(kw_only=True)
25
+ class LibraryWithFilterDataResponse(_BaseModel):
26
+ """LibraryWithFilterDataResponse."""
27
+
28
+ filterdata: LibraryFilterData
29
+ issues: int
30
+ num_user_playlists: Annotated[int, Alias("numUserPlaylists")]
31
+ library: Library
32
+
33
+
34
+ @dataclass(kw_only=True)
35
+ class _LibraryPaginationResponseBase(_BaseModel):
36
+ """Due to options of this API call, some parameters omitted."""
37
+
38
+ total: int
39
+ limit: int
40
+ page: int
41
+
42
+
43
+ @dataclass(kw_only=True)
44
+ class LibraryItemsMinifiedResponse(_LibraryPaginationResponseBase):
45
+ """LibraryItemsMinifiedResponse."""
46
+
47
+ results: list[LibraryItemMinified]
48
+
49
+
50
+ @dataclass(kw_only=True)
51
+ class LibraryItemsResponse(_LibraryPaginationResponseBase):
52
+ """LibraryItemsResponse."""
53
+
54
+ results: list[LibraryItem]
55
+
56
+
57
+ @dataclass(kw_only=True)
58
+ class LibrarySeriesResponse(_LibraryPaginationResponseBase):
59
+ """LibrarySeriesResponse."""
60
+
61
+ results: list[SeriesBooks]
62
+
63
+
64
+ @dataclass(kw_only=True)
65
+ class LibrarySeriesMinifiedResponse(_LibraryPaginationResponseBase):
66
+ """LibrarySeriesMinifiedResponse."""
67
+
68
+ results: list[SeriesBooksMinified]
69
+
70
+
71
+ @dataclass(kw_only=True)
72
+ class LibraryCollectionsResponse(_LibraryPaginationResponseBase):
73
+ """LibraryCollectionsResponse."""
74
+
75
+ results: list[CollectionExpanded]
76
+
77
+
78
+ @dataclass(kw_only=True)
79
+ class LibraryCollectionsMinifiedResponse(_LibraryPaginationResponseBase):
80
+ """LibraryCollectionMinifiedResponse."""
81
+
82
+ results: list[Collection]
83
+
84
+
85
+ @dataclass(kw_only=True)
86
+ class LibraryPlaylistsResponse(_LibraryPaginationResponseBase):
87
+ """LibraryPlaylistsResponse."""
88
+
89
+ results: list[PlaylistExpanded]
90
+
91
+
92
+ @dataclass(kw_only=True)
93
+ class LibraryAuthorsResponse(_BaseModel):
94
+ """LibraryAuthorsResponse."""
95
+
96
+ authors: list[AuthorExpanded]
97
+
98
+
99
+ @dataclass(kw_only=True)
100
+ class LibraryNarratorsResponse(_BaseModel):
101
+ """LibraryNarratorsResponse."""
102
+
103
+ narrators: list[Narrator]
@@ -0,0 +1,28 @@
1
+ """Requests and responses to talk to abs api."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Annotated
5
+
6
+ from mashumaro.mixins.json import DataClassJSONMixin
7
+ from mashumaro.types import Alias
8
+
9
+ from .server import ServerSettings
10
+ from .user import User
11
+
12
+
13
+ @dataclass(kw_only=True)
14
+ class LoginParameters(DataClassJSONMixin):
15
+ """Login params."""
16
+
17
+ username: str
18
+ password: str
19
+
20
+
21
+ @dataclass(kw_only=True)
22
+ class LoginResponse(DataClassJSONMixin):
23
+ """Response to login request."""
24
+
25
+ user: User
26
+ user_default_library_id: Annotated[str, Alias("userDefaultLibraryId")]
27
+ server_settings: Annotated[ServerSettings, Alias("serverSettings")]
28
+ source: Annotated[str, Alias("Source")]
@@ -0,0 +1,28 @@
1
+ """Params and responses for me."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Annotated
5
+
6
+ from mashumaro.types import Alias
7
+
8
+ from aioaudiobookshelf.schema.session import PlaybackSession
9
+
10
+ from . import _BaseModel
11
+
12
+
13
+ @dataclass(kw_only=True)
14
+ class MeListeningSessionsParameters(_BaseModel):
15
+ """MeListeningSessionsParameters."""
16
+
17
+ items_per_page: Annotated[int, Alias("itemsPerPage")] = 10
18
+ page: int = 0
19
+
20
+
21
+ @dataclass(kw_only=True)
22
+ class MeListeningSessionsResponse(_BaseModel):
23
+ """MeListeningSessionsResponse."""
24
+
25
+ total: int
26
+ num_pages: Annotated[int, Alias("numPages")]
27
+ items_per_page: Annotated[int, Alias("itemsPerPage")]
28
+ sessions: list[PlaybackSession]
@@ -0,0 +1,14 @@
1
+ """Params and responses for playlists."""
2
+
3
+ from dataclasses import dataclass
4
+
5
+ from aioaudiobookshelf.schema.playlist import PlaylistExpanded
6
+
7
+ from . import _BaseModel
8
+
9
+
10
+ @dataclass(kw_only=True)
11
+ class AllPlaylistsResponse(_BaseModel):
12
+ """AllPlaylistsResponse."""
13
+
14
+ playlists: list[PlaylistExpanded]
@@ -0,0 +1,25 @@
1
+ """Calls to /api/series."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Annotated
5
+
6
+ from mashumaro.types import Alias
7
+
8
+ from . import _BaseModel
9
+ from .series import Series
10
+
11
+
12
+ @dataclass(kw_only=True)
13
+ class SeriesProgress(_BaseModel):
14
+ """SeriesProgress."""
15
+
16
+ library_item_ids: Annotated[list[str], Alias("libraryItemIds")]
17
+ library_items_ids_finished: Annotated[list[str], Alias("libraryItemIdsFinished")]
18
+ is_finished: Annotated[bool, Alias("isFinished")]
19
+
20
+
21
+ @dataclass(kw_only=True)
22
+ class SeriesWithProgress(Series):
23
+ """SeriesWithProgress."""
24
+
25
+ progress: SeriesProgress
@@ -0,0 +1,17 @@
1
+ """Params and responses for sessions."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Annotated
5
+
6
+ from mashumaro.types import Alias
7
+
8
+ from . import _BaseModel
9
+
10
+
11
+ @dataclass(kw_only=True)
12
+ class CloseOpenSessionsParameters(_BaseModel):
13
+ """CloseOpenSessionsParameters."""
14
+
15
+ current_time: Annotated[float, Alias("currentTime")]
16
+ time_listened: Annotated[float, Alias("timeListened")]
17
+ duration: float
@@ -0,0 +1,36 @@
1
+ """Schema for Collections."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Annotated
5
+
6
+ from mashumaro.types import Alias
7
+
8
+ from . import _BaseModel
9
+ from .library import LibraryItemBook, LibraryItemExpandedBook
10
+
11
+
12
+ @dataclass(kw_only=True)
13
+ class _CollectionBase(_BaseModel):
14
+ """_CollectionBase."""
15
+
16
+ id_: Annotated[str, Alias("id")]
17
+ library_id: Annotated[str, Alias("libraryId")]
18
+ user_id: Annotated[str | None, Alias("userId")] = None
19
+ name: str
20
+ description: str | None = None
21
+ last_update: Annotated[int, Alias("lastUpdate")] # ms epoch
22
+ created_at: Annotated[int, Alias("createdAt")] # ms epoch
23
+
24
+
25
+ @dataclass(kw_only=True)
26
+ class Collection(_CollectionBase):
27
+ """Collection."""
28
+
29
+ books: list[LibraryItemBook]
30
+
31
+
32
+ @dataclass(kw_only=True)
33
+ class CollectionExpanded(_CollectionBase):
34
+ """Collection."""
35
+
36
+ books: list[LibraryItemExpandedBook]
@@ -0,0 +1,46 @@
1
+ """Scheme for socket client."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Annotated
5
+
6
+ from mashumaro.types import Alias
7
+
8
+ from . import _BaseModel
9
+ from .media_progress import MediaProgress
10
+
11
+
12
+ @dataclass(kw_only=True)
13
+ class UserItemProgressUpdatedEvent(_BaseModel):
14
+ """UserItemProgressUpdatedEvent."""
15
+
16
+ id_: Annotated[str, Alias("id")]
17
+ data: MediaProgress
18
+
19
+
20
+ @dataclass(kw_only=True)
21
+ class PodcastEpisodeDownload(_BaseModel):
22
+ """PodcastEpisodeDownload."""
23
+
24
+ id_: Annotated[str, Alias("id")]
25
+ episode_display_title: Annotated[str, Alias("episodeDisplayTitle")]
26
+ url: str
27
+ library_item_id: Annotated[str, Alias("libraryItemId")]
28
+ library_id: Annotated[str, Alias("libraryId")]
29
+ is_finished: Annotated[bool, Alias("isFinished")]
30
+ failed: bool
31
+ started_at: Annotated[int | None, Alias("startedAt")] = None
32
+ created_at: Annotated[int, Alias("createdAt")]
33
+ finished_at: Annotated[int | None, Alias("finishedAt")] = None
34
+ podcast_title: Annotated[str | None, Alias("podcastTitle")] = None
35
+ podcast_explicit: Annotated[bool, Alias("podcastExplicit")]
36
+ season: str | None = None
37
+ episode: str | None = None
38
+ episode_type: Annotated[str, Alias("episodeType")]
39
+ published_at: Annotated[int | None, Alias("publishedAt")] = None
40
+
41
+
42
+ @dataclass(kw_only=True)
43
+ class LibraryItemRemoved(_BaseModel):
44
+ """LibraryItemRemoved."""
45
+
46
+ id_: Annotated[str, Alias("id")]
@@ -0,0 +1,22 @@
1
+ """File schema."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Annotated
5
+
6
+ from mashumaro.types import Alias
7
+
8
+ from . import _BaseModel
9
+
10
+
11
+ @dataclass(kw_only=True)
12
+ class FileMetadata(_BaseModel):
13
+ """FileMetadata."""
14
+
15
+ filename: str
16
+ ext: str
17
+ path: str
18
+ relative_path: Annotated[str, Alias("relPath")]
19
+ size: int # in bytes
20
+ modified_time_ms: Annotated[int, Alias("mtimeMs")]
21
+ changed_time_ms: Annotated[int, Alias("ctimeMs")]
22
+ created_time_ms: Annotated[int, Alias("birthtimeMs")] = 0 # 0 if unknown
@@ -0,0 +1,18 @@
1
+ """Folder Schema."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Annotated
5
+
6
+ from mashumaro.types import Alias
7
+
8
+ from . import _BaseModel
9
+
10
+
11
+ @dataclass(kw_only=True)
12
+ class Folder(_BaseModel):
13
+ """Folder."""
14
+
15
+ id_: Annotated[str, Alias("id")]
16
+ full_path: Annotated[str, Alias("fullPath")]
17
+ library_id: Annotated[str, Alias("libraryId")]
18
+ added_at: Annotated[int, Alias("addedAt")] # ms epoch