/
/
/
1"""Constants for Audiobookshelf provider."""
2
3from enum import StrEnum
4
5from aioaudiobookshelf.schema.shelf import ShelfId as AbsShelfId
6from aiohttp.client import ClientTimeout
7
8# AIOHTTP
9# we use twice the default values
10AIOHTTP_TIMEOUT = ClientTimeout(total=10 * 60, sock_connect=60)
11
12# expire after 5 min of not using them
13STREAMDETAILS_EXPIRATION_S = 300
14
15# CONFIG
16CONF_URL = "url"
17CONF_USERNAME = "username"
18CONF_PASSWORD = "password"
19CONF_OLD_TOKEN = "token"
20CONF_API_TOKEN = "api_token" # with jwt api token (>= v2.26)
21CONF_VERIFY_SSL = "verify_ssl"
22# optionally hide podcasts with no episodes
23CONF_HIDE_EMPTY_PODCASTS = "hide_empty_podcasts"
24
25# CACHE
26CACHE_CATEGORY_LIBRARIES = 0
27CACHE_KEY_LIBRARIES = "libraries"
28
29
30# BROWSE
31class AbsBrowsePaths(StrEnum):
32 """Path prefixes for browse view."""
33
34 LIBRARIES_BOOK = "lb"
35 LIBRARIES_PODCAST = "lp"
36 AUTHORS = "a"
37 NARRATORS = "n"
38 SERIES = "s"
39 COLLECTIONS = "c"
40 AUDIOBOOKS = "b"
41 PODCASTS = "p"
42 PLAYLISTS = "pl"
43
44
45class AbsBrowseItemsBookTranslationKey(StrEnum):
46 """translation keys in browse view for books."""
47
48 AUTHORS = "authors"
49 NARRATORS = "narrators"
50 SERIES = "series_plural"
51 SERIES_ENTRY = "series_entry"
52 COLLECTIONS = "collections"
53 PLAYLISTS = "playlists" # not abs specific
54 AUDIOBOOKS = "audiobooks" # not abs specific
55 AUDIOBOOKS_LIBRARY = "audiobooks_library"
56
57
58class AbsBrowseItemsPodcastTranslationKey(StrEnum):
59 """Folder names in browse view for podcasts."""
60
61 PLAYLISTS = "playlists" # not abs specific
62 PODCASTS = "podcasts" # not abs specific
63 PODCASTS_LIBRARY = "podcasts_library"
64
65
66ABS_BROWSE_ITEMS_BOOK_TO_PATH: dict[str, str] = {
67 AbsBrowseItemsBookTranslationKey.AUTHORS: AbsBrowsePaths.AUTHORS,
68 AbsBrowseItemsBookTranslationKey.NARRATORS: AbsBrowsePaths.NARRATORS,
69 AbsBrowseItemsBookTranslationKey.SERIES: AbsBrowsePaths.SERIES,
70 AbsBrowseItemsBookTranslationKey.SERIES_ENTRY: AbsBrowsePaths.SERIES,
71 AbsBrowseItemsBookTranslationKey.COLLECTIONS: AbsBrowsePaths.COLLECTIONS,
72 AbsBrowseItemsBookTranslationKey.AUDIOBOOKS: AbsBrowsePaths.AUDIOBOOKS,
73 AbsBrowseItemsBookTranslationKey.AUDIOBOOKS_LIBRARY: AbsBrowsePaths.AUDIOBOOKS,
74 AbsBrowseItemsBookTranslationKey.PLAYLISTS: AbsBrowsePaths.PLAYLISTS,
75}
76
77ABS_BROWSE_ITEMS_PODCAST_TO_PATH: dict[str, str] = {
78 AbsBrowseItemsPodcastTranslationKey.PODCASTS: AbsBrowsePaths.PODCASTS,
79 AbsBrowseItemsPodcastTranslationKey.PODCASTS_LIBRARY: AbsBrowsePaths.PODCASTS,
80 AbsBrowseItemsPodcastTranslationKey.PLAYLISTS: AbsBrowsePaths.PLAYLISTS,
81}
82
83ABS_SHELF_ID_ICONS: dict[str, str] = {
84 AbsShelfId.LISTEN_AGAIN: "mdi-book-refresh-outline",
85 AbsShelfId.CONTINUE_LISTENING: "mdi-clock-outline",
86 AbsShelfId.CONTINUE_SERIES: "mdi-play-box-multiple-outline",
87 AbsShelfId.RECOMMENDED: "mdi-lightbulb-outline",
88 AbsShelfId.RECENTLY_ADDED: "mdi-plus-box-multiple-outline",
89 AbsShelfId.EPISODES_RECENTLY_ADDED: "mdi-plus-box-multiple-outline",
90 AbsShelfId.RECENT_SERIES: "mdi-bookshelf",
91 AbsShelfId.NEWEST_AUTHORS: "mdi-plus-box-multiple-outline",
92 AbsShelfId.NEWEST_EPISODES: "mdi-plus-box-multiple-outline",
93 AbsShelfId.DISCOVER: "mdi-magnify",
94}
95
96# for some keys there already is a good MA variant
97# note: recommendation keys are in a subdict
98ABS_SHELF_ID_TRANSLATION_KEY: dict[str, str] = {
99 AbsShelfId.LISTEN_AGAIN: "listen_again",
100 AbsShelfId.CONTINUE_LISTENING: "in_progress_items",
101 AbsShelfId.CONTINUE_SERIES: "in_progress_series",
102 AbsShelfId.RECOMMENDED: "recommended",
103 AbsShelfId.RECENTLY_ADDED: "recently_added",
104 AbsShelfId.EPISODES_RECENTLY_ADDED: "episodes_recently_added",
105 AbsShelfId.RECENT_SERIES: "recent_series",
106 AbsShelfId.NEWEST_AUTHORS: "newest_authors",
107 AbsShelfId.NEWEST_EPISODES: "newest_episodes",
108 AbsShelfId.DISCOVER: "discover",
109}
110