/
/
/
1"""Shared constants for the MusicBrainz provider."""
2
3from __future__ import annotations
4
5from music_assistant_models.enums import LinkType, ProviderFeature
6
7LUCENE_SPECIAL = r'([+\-&|!(){}\[\]\^"~*?:\\\/])'
8
9# A recording search lists only a few of the releases a song appeared on, and for a much
10# reissued song those can all be reissues. The release group knows when it was first
11# released, but a group that predates the listed releases by only a few years is usually
12# just a single issued ahead of its album or a regional edition, where the listed release
13# is the safer answer. Only a wider gap means the search saw nothing but reissues.
14# Measured against hand-dated songs: a smaller gap corrects as often as it misleads.
15MIN_FIRST_RELEASE_CORRECTION_YEARS = 5
16
17SUPPORTED_FEATURES: set[ProviderFeature] = {
18 ProviderFeature.ARTIST_METADATA,
19 ProviderFeature.RECOMMENDATIONS,
20}
21
22# Mapping from MusicBrainz URL relation "type" slug to our LinkType enum.
23# See https://musicbrainz.org/relationships/artist-url for the full set.
24URL_RELATION_TYPE_MAPPING: dict[str, LinkType] = {
25 "wikipedia": LinkType.WIKIPEDIA,
26 "allmusic": LinkType.ALLMUSIC,
27 "last.fm": LinkType.LASTFM,
28 "official homepage": LinkType.WEBSITE,
29}
30
31# Social network relations use a single MB type but multiple destinations,
32# so we sniff the URL host to pick a more specific LinkType.
33SOCIAL_HOST_MAPPING: tuple[tuple[str, LinkType], ...] = (
34 ("facebook.com", LinkType.FACEBOOK),
35 ("instagram.com", LinkType.INSTAGRAM),
36 ("tiktok.com", LinkType.TIKTOK),
37 ("twitter.com", LinkType.TWITTER),
38 ("x.com", LinkType.TWITTER),
39)
40