diff --git a/NEWS b/NEWS index 1a166a1b0..119ff4a2c 100644 --- a/NEWS +++ b/NEWS @@ -46,6 +46,8 @@ * Fixed an occasional bug where Mutagen would complain that a tag was already present. * Fixed a bug with reading invalid integers from ID3 tags. +* The tagger should now be a little more reluctant to reorder tracks + that already have indices. 1.0b3 ----- diff --git a/beets/autotag/__init__.py b/beets/autotag/__init__.py index 19b7fb3ff..0a5111b96 100644 --- a/beets/autotag/__init__.py +++ b/beets/autotag/__init__.py @@ -41,10 +41,10 @@ TRACK_WEIGHT = 1.0 # the overall TRACK_WEIGHT does that). TRACK_TITLE_WEIGHT = 3.0 # Added when the indices of tracks don't match. -TRACK_INDEX_WEIGHT = 0.0 +TRACK_INDEX_WEIGHT = 1.0 # Track length weights: no penalty before GRACE, maximum (WEIGHT) # penalty at GRACE+MAX discrepancy. -TRACK_LENGTH_GRACE = 15 +TRACK_LENGTH_GRACE = 10 TRACK_LENGTH_MAX = 30 TRACK_LENGTH_WEIGHT = 2.0 # MusicBrainz track ID matches. diff --git a/test/test_autotag.py b/test/test_autotag.py index 856f22b1b..4f3479837 100644 --- a/test/test_autotag.py +++ b/test/test_autotag.py @@ -120,6 +120,54 @@ class OrderingTest(unittest.TestCase): ordered = autotag.order_items(items, trackinfo) self.assertEqual(ordered, None) + def test_order_corrects_when_track_names_are_entirely_wrong(self): + # A real-world test case contributed by a user. + def item(i, length): + return Item({ + 'artist': 'ben harper', + 'album': 'burn to shine', + 'title': 'ben harper - Burn to Shine ' + str(i), + 'track': i, + 'length': length, + 'mb_trackid': '', 'mb_albumid': '', 'mb_artistid': '', + }) + items = [] + items.append(item(1, 241.37243007106997)) + items.append(item(2, 342.27781704375036)) + items.append(item(3, 245.95070222338137)) + items.append(item(4, 472.87662515485437)) + items.append(item(5, 279.1759535763187)) + items.append(item(6, 270.33333768012)) + items.append(item(7, 247.83435613222923)) + items.append(item(8, 216.54504531525072)) + items.append(item(9, 225.72775379800484)) + items.append(item(10, 317.7643606963552)) + items.append(item(11, 243.57001238834192)) + items.append(item(12, 186.45916150485752)) + + def info(title, length): + return { + 'title': title, + 'length': length, + } + trackinfo = [] + trackinfo.append(info('Alone', 238.893)) + trackinfo.append(info('The Woman in You', 341.44)) + trackinfo.append(info('Less', 245.59999999999999)) + trackinfo.append(info('Two Hands of a Prayer', 470.49299999999999)) + trackinfo.append(info('Please Bleed', 277.86599999999999)) + trackinfo.append(info('Suzie Blue', 269.30599999999998)) + trackinfo.append(info('Steal My Kisses', 245.36000000000001)) + trackinfo.append(info('Burn to Shine', 214.90600000000001)) + trackinfo.append(info('Show Me a Little Shame', 224.09299999999999)) + trackinfo.append(info('Forgiven', 317.19999999999999)) + trackinfo.append(info('Beloved One', 243.733)) + trackinfo.append(info('In the Lord\'s Arms', 186.13300000000001)) + + ordered = autotag.order_items(items, trackinfo) + for i, item in enumerate(ordered): + self.assertEqual(i+1, item.track) + class ApplyTest(unittest.TestCase): def setUp(self): self.items = []