/
/
/
1"""Constants for the music controller."""
2
3from __future__ import annotations
4
5from typing import Final
6
7CONF_RESET_DB = "reset_db"
8DEFAULT_SYNC_INTERVAL = 12 * 60 # default sync interval in minutes
9CONF_SYNC_INTERVAL = "sync_interval"
10CONF_DELETED_PROVIDERS = "deleted_providers"
11
12DB_SCHEMA_VERSION: Final[int] = 58
13
14# tracks longer that this will not be included in radio mode
15RADIO_TRACK_MAX_DURATION_SECS: Final[int] = 20 * 60
16DYNAMIC_RADIO_BASE_SAMPLE_SIZE: Final[int] = 5
17DYNAMIC_RADIO_DYNAMIC_TARGET: Final[int] = 50
18
19CACHE_CATEGORY_SEARCH_RESULTS: Final[int] = 10
20
21# max time to wait for a single provider's search results before
22# contributing empty results for it, so one slow provider can never block
23# the whole search; the provider search itself continues in the background
24# so its result is cached and available for a next search request
25SEARCH_PROVIDER_SOFT_TIMEOUT: Final[int] = 8
26# absolute max time a (background) provider search may run,
27# rate limited providers can be very slow to respond
28SEARCH_PROVIDER_HARD_TIMEOUT: Final[int] = 120
29# how long to cache raw per-provider search results; streaming catalogs barely
30# change so they can be cached a lot longer than local providers where the
31# user may add or change content at any time
32SEARCH_CACHE_EXPIRATION_STREAMING_PROVIDER: Final[int] = 24 * 3600
33SEARCH_CACHE_EXPIRATION_LOCAL_PROVIDER: Final[int] = 900
34# how long to cache combined search results (fast path for repeated searches)
35SEARCH_CACHE_EXPIRATION_COMBINED: Final[int] = 600
36
37# max time to wait for a single recommendation row's item fetch before skipping
38# the row, so one slow provider row can never block an items request
39RECOMMENDATIONS_ITEMS_TIMEOUT: Final[int] = 30
40
41# max time to wait for a single provider's recommendation rows; rows are
42# contractually fast (no live backend calls) so a short timeout suffices
43RECOMMENDATIONS_ROWS_TIMEOUT: Final[int] = 5
44
45# how long after a provider is loaded its library sync runs for the first time,
46# leaving the rest of the startup work room to settle first
47INITIAL_SYNC_DELAY: Final[int] = 10
48
49DATABASE_CLEANUP_TASK_ID: Final[str] = "music_database_cleanup"
50PROVIDER_MAPPING_CORRECTION_TASK_ID: Final[str] = "music_provider_mapping_correction"
51MUSIC_SYNC_COMPLETION_CHECK_TASK_ID: Final[str] = "music_sync_completion_check"
52TRACK_RECONCILIATION_TASK_ID: Final[str] = "music_track_reconciliation"
53
54# number of duplicate track candidate pairs examined per reconciliation run
55TRACK_RECONCILIATION_BATCH_SIZE: Final[int] = 100
56
57# where the duplicate track walk left off, stored so a restart resumes instead of starting
58# over: the pair last examined as [item_id, item_id], or an empty list once the walk has
59# reached the end of the library
60CONF_TRACK_RECONCILIATION_CURSOR: Final[str] = "track_reconciliation_cursor"
61# whether a sync has added content that the walk still owes another pass
62CONF_TRACK_RECONCILIATION_RESCAN_DUE: Final[str] = "track_reconciliation_rescan_due"
63# max difference in seconds between two track durations to still consider them the same
64# recording; matches the widest duration window compare_track is willing to accept
65TRACK_RECONCILIATION_MAX_DURATION_DELTA: Final[int] = 8
66