From 711a1c11133d0cd0f256e55e46eb2d73c8dc1506 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sat, 19 May 2012 16:13:15 -0700 Subject: [PATCH] apply artist credits & add to database (GC-286) --- beets/autotag/__init__.py | 12 +++++---- beets/library.py | 49 ++++++++++++++++++---------------- docs/changelog.rst | 5 ++++ docs/reference/pathformat.rst | 16 +++++++---- test/rsrc/test.blb | Bin 7168 -> 7168 bytes test/test_autotag.py | 24 ++++++++++++++--- 6 files changed, 70 insertions(+), 36 deletions(-) diff --git a/beets/autotag/__init__.py b/beets/autotag/__init__.py index e3ebfa26f..f384ad5ae 100644 --- a/beets/autotag/__init__.py +++ b/beets/autotag/__init__.py @@ -106,6 +106,8 @@ def apply_item_metadata(item, track_info): """Set an item's metadata from its matched TrackInfo object. """ item.artist = track_info.artist + item.artist_sort = track_info.artist_sort + item.artist_credit = track_info.artist_credit item.title = track_info.title item.mb_trackid = track_info.track_id if track_info.artist_id: @@ -130,12 +132,12 @@ def apply_metadata(items, album_info, per_disc_numbering=False): item.album = album_info.album item.tracktotal = len(items) - # Artist sort names. - if track_info.artist_sort: - item.artist_sort = track_info.artist_sort - else: - item.artist_sort = album_info.artist_sort + # Artist sort and credit names. + item.artist_sort = track_info.artist_sort or album_info.artist_sort + item.artist_credit = track_info.artist_credit or \ + album_info.artist_credit item.albumartist_sort = album_info.artist_sort + item.albumartist_credit = album_info.artist_credit # Release date. if album_info.year: diff --git a/beets/library.py b/beets/library.py index da4b4dd1e..33adcab3f 100644 --- a/beets/library.py +++ b/beets/library.py @@ -46,9 +46,11 @@ ITEM_FIELDS = [ ('title', 'text', True, True), ('artist', 'text', True, True), ('artist_sort', 'text', True, True), + ('artist_credit', 'text', True, True), ('album', 'text', True, True), ('albumartist', 'text', True, True), ('albumartist_sort', 'text', True, True), + ('albumartist_credit', 'text', True, True), ('genre', 'text', True, True), ('composer', 'text', True, True), ('grouping', 'text', True, True), @@ -102,29 +104,30 @@ ALBUM_FIELDS = [ ('id', 'integer primary key', False), ('artpath', 'blob', False), - ('albumartist', 'text', True), - ('albumartist_sort', 'text', True), - ('album', 'text', True), - ('genre', 'text', True), - ('year', 'int', True), - ('month', 'int', True), - ('day', 'int', True), - ('tracktotal', 'int', True), - ('disctotal', 'int', True), - ('comp', 'bool', True), - ('mb_albumid', 'text', True), - ('mb_albumartistid', 'text', True), - ('albumtype', 'text', True), - ('label', 'text', True), - ('mb_releasegroupid', 'text', True), - ('asin', 'text', True), - ('catalognum', 'text', True), - ('script', 'text', True), - ('language', 'text', True), - ('country', 'text', True), - ('albumstatus', 'text', True), - ('media', 'text', True), - ('albumdisambig', 'text', True), + ('albumartist', 'text', True), + ('albumartist_sort', 'text', True), + ('albumartist_credit', 'text', True, True), + ('album', 'text', True), + ('genre', 'text', True), + ('year', 'int', True), + ('month', 'int', True), + ('day', 'int', True), + ('tracktotal', 'int', True), + ('disctotal', 'int', True), + ('comp', 'bool', True), + ('mb_albumid', 'text', True), + ('mb_albumartistid', 'text', True), + ('albumtype', 'text', True), + ('label', 'text', True), + ('mb_releasegroupid', 'text', True), + ('asin', 'text', True), + ('catalognum', 'text', True), + ('script', 'text', True), + ('language', 'text', True), + ('country', 'text', True), + ('albumstatus', 'text', True), + ('media', 'text', True), + ('albumdisambig', 'text', True), ] ALBUM_KEYS = [f[0] for f in ALBUM_FIELDS] ALBUM_KEYS_ITEM = [f[0] for f in ALBUM_FIELDS if f[2]] diff --git a/docs/changelog.rst b/docs/changelog.rst index 1ed9ea2b4..c487818a8 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -15,6 +15,9 @@ Changelog instead of a messy traceback. They still interrupt beets, but they should now be easier for users to understand. Tracebacks are still available in verbose mode. +* New metadata fields for `artist credits`_: ``artist_credit`` and + ``albumartist_credit`` can now contain release- and recording-specific + variations of the artist's name. See :ref:`itemfields`. * New plugin event: ``import_task_choice`` is called after an import task has an action assigned. * New plugin event: ``library_opened`` is called when beets starts up and @@ -30,6 +33,8 @@ Changelog * :doc:`/plugins/chroma`: Fix occasional crash at end of fingerprint submission and give more context to "failed fingerprint generation" errors. +.. _artist credits: http://wiki.musicbrainz.org/Artist_Credit + 1.0b14 (May 12, 2012) --------------------- diff --git a/docs/reference/pathformat.rst b/docs/reference/pathformat.rst index 23beaa859..5c946e9ba 100644 --- a/docs/reference/pathformat.rst +++ b/docs/reference/pathformat.rst @@ -158,10 +158,15 @@ Ordinary metadata: * title * artist -* artist_sort +* artist_sort: The "sort name" of the track artist (e.g., "Beatles, The" or + "White, Jack"). +* artist_credit: The track-specific `artist credit`_ name, which may be a + variation of the artist's "canonical" name. * album -* albumartist +* albumartist: The artist for the entire album, which may be different from the + artists for the individual tracks. * albumartist_sort +* albumartist_credit * genre * composer * grouping @@ -175,9 +180,9 @@ Ordinary metadata: * lyrics * comments * bpm -* comp -* albumtype (the MusicBrainz album type; the MusicBrainz wiki has a `list of - type names`_) +* comp: Compilation flag. +* albumtype: The MusicBrainz album type; the MusicBrainz wiki has a `list of + type names`_. * label * asin * catalognum @@ -190,6 +195,7 @@ Ordinary metadata: * disctitle * encoder +.. _artist credit: http://wiki.musicbrainz.org/Artist_Credit .. _list of type names: http://wiki.musicbrainz.org/XMLWebService#Release_Type_and_Status Audio information: diff --git a/test/rsrc/test.blb b/test/rsrc/test.blb index 5181128bc92d54a2c79a037ba15ed8e507e187c9..3fe41c8ae885de67124b0b08de219233766b50da 100644 GIT binary patch delta 162 zcmZp$Xt0Fr5+$<*<7*0;+;@QvDX2QrWE-ud49vyyg>DgOuh_EzMBO(oSC?q4Vc))B_$c#tT)>Utzcx-+{`G##