music-assistant-server

2.9 KBPY
constants.py
2.9 KB91 lines • python
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# CONFIG
13CONF_URL = "url"
14CONF_USERNAME = "username"
15CONF_PASSWORD = "password"
16CONF_OLD_TOKEN = "token"
17CONF_API_TOKEN = "api_token"  # with jwt api token (>= v2.26)
18CONF_VERIFY_SSL = "verify_ssl"
19# optionally hide podcasts with no episodes
20CONF_HIDE_EMPTY_PODCASTS = "hide_empty_podcasts"
21
22# CACHE
23CACHE_CATEGORY_LIBRARIES = 0
24CACHE_KEY_LIBRARIES = "libraries"
25
26
27# BROWSE
28class AbsBrowsePaths(StrEnum):
29    """Path prefixes for browse view."""
30
31    LIBRARIES_BOOK = "lb"
32    LIBRARIES_PODCAST = "lp"
33    AUTHORS = "a"
34    NARRATORS = "n"
35    SERIES = "s"
36    COLLECTIONS = "c"
37    AUDIOBOOKS = "b"
38
39
40class AbsBrowseItemsBookTranslationKey(StrEnum):
41    """translation keys in browse view for books."""
42
43    AUTHORS = "authors"
44    NARRATORS = "narrators"
45    SERIES = "series_plural"
46    COLLECTIONS = "collections"
47    AUDIOBOOKS = "audiobooks"
48
49
50class AbsBrowseItemsPodcastTranslationKey(StrEnum):
51    """Folder names in browse view for podcasts."""
52
53    PODCASTS = "podcasts"
54
55
56ABS_BROWSE_ITEMS_TO_PATH: dict[str, str] = {
57    AbsBrowseItemsBookTranslationKey.AUTHORS: AbsBrowsePaths.AUTHORS,
58    AbsBrowseItemsBookTranslationKey.NARRATORS: AbsBrowsePaths.NARRATORS,
59    AbsBrowseItemsBookTranslationKey.SERIES: AbsBrowsePaths.SERIES,
60    AbsBrowseItemsBookTranslationKey.COLLECTIONS: AbsBrowsePaths.COLLECTIONS,
61    AbsBrowseItemsBookTranslationKey.AUDIOBOOKS: AbsBrowsePaths.AUDIOBOOKS,
62}
63
64ABS_SHELF_ID_ICONS: dict[str, str] = {
65    AbsShelfId.LISTEN_AGAIN: "mdi-book-refresh-outline",
66    AbsShelfId.CONTINUE_LISTENING: "mdi-clock-outline",
67    AbsShelfId.CONTINUE_SERIES: "mdi-play-box-multiple-outline",
68    AbsShelfId.RECOMMENDED: "mdi-lightbulb-outline",
69    AbsShelfId.RECENTLY_ADDED: "mdi-plus-box-multiple-outline",
70    AbsShelfId.EPISODES_RECENTLY_ADDED: "mdi-plus-box-multiple-outline",
71    AbsShelfId.RECENT_SERIES: "mdi-bookshelf",
72    AbsShelfId.NEWEST_AUTHORS: "mdi-plus-box-multiple-outline",
73    AbsShelfId.NEWEST_EPISODES: "mdi-plus-box-multiple-outline",
74    AbsShelfId.DISCOVER: "mdi-magnify",
75}
76
77# for some keys there already is a good MA variant
78# note: recommendation keys are in a subdict
79ABS_SHELF_ID_TRANSLATION_KEY: dict[str, str] = {
80    AbsShelfId.LISTEN_AGAIN: "listen_again",
81    AbsShelfId.CONTINUE_LISTENING: "in_progress_items",
82    AbsShelfId.CONTINUE_SERIES: "in_progress_series",
83    AbsShelfId.RECOMMENDED: "recommended",
84    AbsShelfId.RECENTLY_ADDED: "recently_added",
85    AbsShelfId.EPISODES_RECENTLY_ADDED: "episodes_recently_added",
86    AbsShelfId.RECENT_SERIES: "recent_series",
87    AbsShelfId.NEWEST_AUTHORS: "newest_authors",
88    AbsShelfId.NEWEST_EPISODES: "newest_episodes",
89    AbsShelfId.DISCOVER: "discover",
90}
91