mirror of
https://github.com/beetbox/beets.git
synced 2026-02-09 08:52:30 +01:00
Improved parsing of Discogs' position field.
Some albums have a single disc with positions like I, II, III, IV, etc. Previously beets thought each track on these albums was a new medium. Now we assume that if there is no explicit medium index and the ordinal of an alpha medium does not appear to be sequential (e.g. A, B, C) that the medium is actually the medium index.
This commit is contained in:
parent
4c06c96630
commit
835a3c2a73
1 changed files with 12 additions and 2 deletions
|
|
@ -137,7 +137,15 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
medium = None
|
||||
medium_count, index_count = 0, 0
|
||||
for track in tracks:
|
||||
if medium != track.medium:
|
||||
# Handle special case where a different medium does not indicate a
|
||||
# new disc, when there is no medium_index and the ordinal of medium
|
||||
# is not sequential. For example, I, II, III, IV, V. Assume these
|
||||
# are the track index, not the medium.
|
||||
medium_is_index = track.medium and not track.medium_index and (
|
||||
len(track.medium) != 1 or
|
||||
ord(track.medium) - 64 != medium_count + 1)
|
||||
|
||||
if not medium_is_index and medium != track.medium:
|
||||
# Increment medium_count and reset index_count when medium
|
||||
# changes.
|
||||
medium = track.medium
|
||||
|
|
@ -173,7 +181,9 @@ class DiscogsPlugin(BeetsPlugin):
|
|||
def get_track_index(self, position):
|
||||
"""Returns the medium and medium index for a discogs track position.
|
||||
"""
|
||||
match = re.match(r'^(.*?)(\d*)$', position, re.I)
|
||||
# medium_index is a number at the end of position. medium is everything
|
||||
# else. E.g. (A)(1), (Side A, Track )(1), (A)(), ()(1), etc.
|
||||
match = re.match(r'^(.*?)(\d*)$', position.upper())
|
||||
if match:
|
||||
medium, index = match.groups()
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue