mirror of
https://github.com/beetbox/beets.git
synced 2026-02-11 09:54:31 +01:00
add data_source, data_url to TrackInfo objects
The Beatport plugin now uses this to provide singleton matches (and their appropriate penalty).
This commit is contained in:
parent
4555d69803
commit
0262803a40
2 changed files with 12 additions and 5 deletions
|
|
@ -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'):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue