diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index 5938c2308..32548644d 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -95,7 +95,7 @@ class AlbumInfo(object): self.original_year = original_year self.original_month = original_month self.original_day = original_day - self.data_source = data_source or 'Unknown' + self.data_source = data_source self.data_url = data_url # Work around a bug in python-musicbrainz-ngs that causes some @@ -138,7 +138,8 @@ class TrackInfo(object): """ def __init__(self, title, track_id, artist=None, artist_id=None, length=None, index=None, medium=None, medium_index=None, - artist_sort=None, disctitle=None, artist_credit=None): + artist_sort=None, disctitle=None, artist_credit=None, + data_source=None, data_url=None): self.title = title self.track_id = track_id self.artist = artist @@ -150,6 +151,8 @@ class TrackInfo(object): self.artist_sort = artist_sort self.disctitle = disctitle self.artist_credit = artist_credit + self.data_source = data_source + self.data_url = data_url # As above, work around a bug in python-musicbrainz-ngs. def decode(self, codec='utf8'): diff --git a/beetsplug/beatport.py b/beetsplug/beatport.py index 05e33637c..1712900be 100644 --- a/beetsplug/beatport.py +++ b/beetsplug/beatport.py @@ -171,11 +171,14 @@ class BeatportPlugin(BeetsPlugin): dist.add('source', self.config['source_weight'].as_number()) return dist - def track_distance(self, item, info): + def track_distance(self, item, track_info): """Returns the beatport source weight and the maximum source weight for individual tracks. """ - return Distance() # FIXME: Need source information for tracks. + dist = Distance() + if track_info.data_source == 'Beatport': + dist.add('source', self.config['source_weight'].as_number()) + return dist def candidates(self, items, artist, release, va_likely): """Returns a list of AlbumInfo objects for beatport search results @@ -272,7 +275,8 @@ class BeatportPlugin(BeetsPlugin): return TrackInfo(title=title, track_id=track.beatport_id, artist=artist, artist_id=artist_id, - length=length, index=index) + length=length, index=index, + data_source=u'Beatport', data_url=track.url) def _get_artist(self, artists): """Returns an artist string (all artists) and an artist_id (the main