Equality is not anymore based on file attribute only.
Now it compares artist/title between tracks
* Add option to prevent single & repeat mode to disable queuing (Closes #19)
* Honor MPC password/host format on command line option 'host'
* Fixed fuzzy search for short artist names
+ * Changed tracks equality test
+ Equality is not anymore based on file attribute only.
+ Now it compares artist/title between tracks
-- kaliko jack <kaliko@azylum.org> UNRELEASED
:param int time: duration in second, defaults to 0
:param int pos: position in queue, defaults to -1
:param str title|artist|album: defaults to ""
- :param str musicbrainz_artistid|musicbrainz_albumartistid: MusicBrainz IDs, defaults to ``None``
+ :param str musicbrainz_artistid: MusicBrainz IDs, defaults to ``None``
+ :param str musicbrainz_albumartistid: MusicBrainz IDs, defaults to ``None``
"""
def __init__(self, file=None, time=0, pos=-1, **kwargs):
return Track(time=self.time - other.time)
def __hash__(self):
+ if self.musicbrainz_artistid and self.title:
+ return hash(self.musicbrainz_artistid + self.title)
+ if self.artist and self.title:
+ return hash(self.artist + self.title)
if self.file:
return hash(self.file)
else:
trk = Track(artist='track_artist')
self.assertEqual(trk.Artist.name, 'track_artist')
+class TestTrackObjectEquality(unittest.TestCase):
+
+ def test_identity(self):
+ trk0 = Track(file='/foo/bar',
+ musicbrainz_artistid='d8e7e3e2-49ab-4f7c-b148-fc946d521f99',
+ title='Crazy')
+ trk1 = Track(file='/foo/bar/baz',
+ musicbrainz_artistid='d8e7e3e2-49ab-4f7c-b148-fc946d521f99',
+ title='Crazy')
+ self.assertTrue(trk1 == trk0, 'different files same artist/title should be equal')
+ trk0 = Track(file='/foo/bar',
+ musicbrainz_artistid='d8e7e3e2-49ab-4f7c-b148-fc946d521f88',
+ title='Crazy')
+ trk1 = Track(file='/foo/bar/baz',
+ musicbrainz_artistid='d8e7e3e2-49ab-4f7c-b148-fc946d521f99',
+ title='Crazy')
+ self.assertTrue(trk1 != trk0, 'different files same title different artist should not be equal')
+
# vim: ai ts=4 sw=4 sts=4 expandtab