Merge pull request #4805 from arsaboo/tidal_import

Allow importing Tidal album id from MusicBrainz
This commit is contained in:
Adrian Sampson 2023-05-30 15:42:47 -07:00 committed by GitHub
commit 5aae612f45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 5 deletions

View file

@ -518,9 +518,9 @@ def album_info(release: Dict) -> beets.autotag.hooks.AlbumInfo:
if (any(config['musicbrainz']['external_ids'].get().values())
and release.get('url-relation-list')):
discogs_url, bandcamp_url, spotify_url = None, None, None
deezer_url, beatport_url = None, None
deezer_url, beatport_url, tidal_url = None, None, None
fetch_discogs, fetch_bandcamp, fetch_spotify = False, False, False
fetch_deezer, fetch_beatport = False, False
fetch_deezer, fetch_beatport, fetch_tidal = False, False, False
if config['musicbrainz']['external_ids']['discogs'].get():
fetch_discogs = True
@ -532,6 +532,8 @@ def album_info(release: Dict) -> beets.autotag.hooks.AlbumInfo:
fetch_deezer = True
if config['musicbrainz']['external_ids']['beatport'].get():
fetch_beatport = True
if config['musicbrainz']['external_ids']['tidal'].get():
fetch_tidal = True
for url in release['url-relation-list']:
if fetch_discogs and url['type'] == 'discogs':
@ -549,6 +551,9 @@ def album_info(release: Dict) -> beets.autotag.hooks.AlbumInfo:
if fetch_beatport and 'beatport.com' in url['target']:
log.debug('Found link to Beatport release via MusicBrainz')
beatport_url = url['target']
if fetch_tidal and 'tidal.com' in url['target']:
log.debug('Found link to Tidal release via MusicBrainz')
tidal_url = url['target']
if discogs_url:
info.discogs_albumid = extract_discogs_id_regex(discogs_url)
@ -563,6 +568,8 @@ def album_info(release: Dict) -> beets.autotag.hooks.AlbumInfo:
if beatport_url:
info.beatport_album_id = MetadataSourcePlugin._get_id(
'album', beatport_url, beatport_id_regex)
if tidal_url:
info.tidal_album_id = tidal_url.split('/')[-1]
extra_albumdatas = plugins.send('mb_album_extract', data=release)
for extra_albumdata in extra_albumdatas:

View file

@ -134,6 +134,7 @@ musicbrainz:
spotify: no
deezer: no
beatport: no
tidal: no
match:
strong_rec_thresh: 0.04

View file

@ -54,7 +54,7 @@ HISTORY_KEY = 'taghistory'
REIMPORT_FRESH_FIELDS_ALBUM = ['data_source']
REIMPORT_FRESH_FIELDS_ITEM = ['data_source', 'bandcamp_album_id',
'spotify_album_id', 'deezer_album_id',
'beatport_album_id']
'beatport_album_id', 'tidal_album_id']
# Global logger.
log = logging.getLogger('beets')

View file

@ -859,12 +859,13 @@ to the beets library.
bandcamp: yes
beatport: yes
deezer: yes
tidal: yes
The library fields of the corresponding :ref:`autotagger_extensions` are used
to save the data (``discogs_albumid``, ``bandcamp_album_id``,
``spotify_album_id``, ``beatport_album_id``, ``deezer_album_id``). On
re-imports existing data will be overwritten.
``spotify_album_id``, ``beatport_album_id``, ``deezer_album_id``,
``tidal_album_id``). On re-imports existing data will be overwritten.
The default of all options is ``no``.