Skip to content

Commit

Permalink
Merge pull request #2228 from diego-plan9/discogs-disc0
Browse files Browse the repository at this point in the history
discogs: set `track.medium` correctly for single medium albums
  • Loading branch information
diego-plan9 authored Oct 19, 2016
2 parents 89c4091 + 2604bc8 commit 6402e05
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions beetsplug/discogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ def get_tracks(self, tracklist):
index_count = 0
side_count = 0
index_count += 1
medium_count = 1 if medium_count == 0 else medium_count
track.medium, track.medium_index = medium_count, index_count

# Get `disctitle` from Discogs index tracks. Assume that an index track
Expand Down
3 changes: 2 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ And there are a few bug fixes too:
the items. :bug:`1938`
* :doc:`/plugins/discogs`: Subtracks are now detected and combined into a
single track, two-sided mediums are treated as single discs, and tracks
have ``media`` and ``medium_total`` set correctly. :bug:`2222`
have ``media``, ``medium_total`` and ``medium`` set correctly. :bug:`2222`
:bug:`2228`.

The last release, 1.3.19, also erroneously reported its version as "1.3.18"
when you typed ``beet version``. This has been corrected.
Expand Down
38 changes: 38 additions & 0 deletions test/test_discogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,44 @@ def test_parse_media_for_tracks(self):
self.assertEqual(t[0].media, d.media)
self.assertEqual(t[1].media, d.media)

def test_parse_medium_numbers_single_medium(self):
release = self._make_release_from_positions(['1', '2'])
d = DiscogsPlugin().get_album_info(release)
t = d.tracks

self.assertEqual(d.mediums, 1)
self.assertEqual(t[0].medium, 1)
self.assertEqual(t[0].medium_total, 1)
self.assertEqual(t[1].medium, 1)
self.assertEqual(t[0].medium_total, 1)

def test_parse_medium_numbers_two_mediums(self):
release = self._make_release_from_positions(['1-1', '2-1'])
d = DiscogsPlugin().get_album_info(release)
t = d.tracks

self.assertEqual(d.mediums, 2)
self.assertEqual(t[0].medium, 1)
self.assertEqual(t[0].medium_total, 2)
self.assertEqual(t[1].medium, 2)
self.assertEqual(t[1].medium_total, 2)

def test_parse_medium_numbers_two_mediums_two_sided(self):
release = self._make_release_from_positions(['A1', 'B1', 'C1'])
d = DiscogsPlugin().get_album_info(release)
t = d.tracks

self.assertEqual(d.mediums, 2)
self.assertEqual(t[0].medium, 1)
self.assertEqual(t[0].medium_total, 2)
self.assertEqual(t[0].medium_index, 1)
self.assertEqual(t[1].medium, 1)
self.assertEqual(t[1].medium_total, 2)
self.assertEqual(t[1].medium_index, 2)
self.assertEqual(t[2].medium, 2)
self.assertEqual(t[2].medium_total, 2)
self.assertEqual(t[2].medium_index, 1)

def test_parse_track_indices(self):
release = self._make_release_from_positions(['1', '2'])
d = DiscogsPlugin().get_album_info(release)
Expand Down

0 comments on commit 6402e05

Please sign in to comment.