diff --git a/beets/autotag/__init__.py b/beets/autotag/__init__.py index fab0fbbae..2f632f1ee 100644 --- a/beets/autotag/__init__.py +++ b/beets/autotag/__init__.py @@ -42,6 +42,8 @@ def apply_item_metadata(item, track_info): item.mb_trackid = track_info.track_id if track_info.artist_id: item.mb_artistid = track_info.artist_id + if track_info.data_source: + item.data_source = track_info.data_source # At the moment, the other metadata is left intact (including album # and track number). Perhaps these should be emptied? @@ -125,7 +127,8 @@ def apply_metadata(album_info, mapping): 'language', 'country', 'albumstatus', - 'albumdisambig'): + 'albumdisambig', + 'data_source',): value = getattr(album_info, field) if value is not None: item[field] = value diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index 12d11a0b3..3a4f96548 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -137,6 +137,8 @@ class TrackInfo(object): - ``artist_sort``: name of the track artist for sorting - ``disctitle``: name of the individual medium (subtitle) - ``artist_credit``: Recording-specific artist name + - ``data_source``: The original data source (MusicBrainz, Discogs, etc.) + - ``data_url``: The data source release URL. Only ``title`` and ``track_id`` are required. The rest of the fields may be None. The indices ``index``, ``medium``, and ``medium_index`` diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index c25599751..b9402f3dc 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -161,6 +161,7 @@ def track_info(recording, index=None, medium=None, medium_index=None, medium=medium, medium_index=medium_index, medium_total=medium_total, + data_source='MusicBrainz', data_url=track_url(recording['id']), ) diff --git a/beets/library.py b/beets/library.py index a57ed1642..fed42da5f 100644 --- a/beets/library.py +++ b/beets/library.py @@ -388,6 +388,8 @@ class Item(LibModel): 'channels': types.INTEGER, 'mtime': DateType(), 'added': DateType(), + + 'data_source': types.STRING, } _search_fields = ('artist', 'title', 'comments', @@ -790,6 +792,8 @@ class Album(LibModel): 'original_year': types.PaddedInt(4), 'original_month': types.PaddedInt(2), 'original_day': types.PaddedInt(2), + + 'data_source': types.STRING, } _search_fields = ('album', 'albumartist', 'genre') @@ -832,6 +836,7 @@ class Album(LibModel): 'original_year', 'original_month', 'original_day', + 'data_source', ] """List of keys that are set on an album's items. """