Skip to content

Commit 5aae612

Browse files
authored
Merge pull request #4805 from arsaboo/tidal_import
Allow importing Tidal album id from MusicBrainz
2 parents d35a8cd + 95898a3 commit 5aae612

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

beets/autotag/mb.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,9 @@ def album_info(release: Dict) -> beets.autotag.hooks.AlbumInfo:
518518
if (any(config['musicbrainz']['external_ids'].get().values())
519519
and release.get('url-relation-list')):
520520
discogs_url, bandcamp_url, spotify_url = None, None, None
521-
deezer_url, beatport_url = None, None
521+
deezer_url, beatport_url, tidal_url = None, None, None
522522
fetch_discogs, fetch_bandcamp, fetch_spotify = False, False, False
523-
fetch_deezer, fetch_beatport = False, False
523+
fetch_deezer, fetch_beatport, fetch_tidal = False, False, False
524524

525525
if config['musicbrainz']['external_ids']['discogs'].get():
526526
fetch_discogs = True
@@ -532,6 +532,8 @@ def album_info(release: Dict) -> beets.autotag.hooks.AlbumInfo:
532532
fetch_deezer = True
533533
if config['musicbrainz']['external_ids']['beatport'].get():
534534
fetch_beatport = True
535+
if config['musicbrainz']['external_ids']['tidal'].get():
536+
fetch_tidal = True
535537

536538
for url in release['url-relation-list']:
537539
if fetch_discogs and url['type'] == 'discogs':
@@ -549,6 +551,9 @@ def album_info(release: Dict) -> beets.autotag.hooks.AlbumInfo:
549551
if fetch_beatport and 'beatport.com' in url['target']:
550552
log.debug('Found link to Beatport release via MusicBrainz')
551553
beatport_url = url['target']
554+
if fetch_tidal and 'tidal.com' in url['target']:
555+
log.debug('Found link to Tidal release via MusicBrainz')
556+
tidal_url = url['target']
552557

553558
if discogs_url:
554559
info.discogs_albumid = extract_discogs_id_regex(discogs_url)
@@ -563,6 +568,8 @@ def album_info(release: Dict) -> beets.autotag.hooks.AlbumInfo:
563568
if beatport_url:
564569
info.beatport_album_id = MetadataSourcePlugin._get_id(
565570
'album', beatport_url, beatport_id_regex)
571+
if tidal_url:
572+
info.tidal_album_id = tidal_url.split('/')[-1]
566573

567574
extra_albumdatas = plugins.send('mb_album_extract', data=release)
568575
for extra_albumdata in extra_albumdatas:

beets/config_default.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ musicbrainz:
134134
spotify: no
135135
deezer: no
136136
beatport: no
137+
tidal: no
137138

138139
match:
139140
strong_rec_thresh: 0.04

beets/importer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
REIMPORT_FRESH_FIELDS_ALBUM = ['data_source']
5555
REIMPORT_FRESH_FIELDS_ITEM = ['data_source', 'bandcamp_album_id',
5656
'spotify_album_id', 'deezer_album_id',
57-
'beatport_album_id']
57+
'beatport_album_id', 'tidal_album_id']
5858

5959
# Global logger.
6060
log = logging.getLogger('beets')

docs/reference/config.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,12 +859,13 @@ to the beets library.
859859
bandcamp: yes
860860
beatport: yes
861861
deezer: yes
862+
tidal: yes
862863

863864

864865
The library fields of the corresponding :ref:`autotagger_extensions` are used
865866
to save the data (``discogs_albumid``, ``bandcamp_album_id``,
866-
``spotify_album_id``, ``beatport_album_id``, ``deezer_album_id``). On
867-
re-imports existing data will be overwritten.
867+
``spotify_album_id``, ``beatport_album_id``, ``deezer_album_id``,
868+
``tidal_album_id``). On re-imports existing data will be overwritten.
868869

869870
The default of all options is ``no``.
870871

0 commit comments

Comments
 (0)