Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pregap tracks #1493

Merged
merged 1 commit into from
Jun 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion beets/autotag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ def apply_metadata(album_info, mapping):
item.title = track_info.title

if config['per_disc_numbering']:
item.track = track_info.medium_index or track_info.index
# We want to let the track number be zero, but if the medium index
# is not provided we need to fall back to the overall index.
item.track = track_info.medium_index
if item.track is None:
item.track = track_info.index
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a little tricky, an inline condition, like this:

item.track = track_info.medium_index if track_info.medium_index is not None else track_info.index

or a comment to the effect of "we want to let the track number be zero, but if the medium index is not provided we need to fall back to the overall index" would be helpful here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not inline the conditional because of its size; I'll add that comment there instead.

item.tracktotal = track_info.medium_total or len(album_info.tracks)
else:
item.track = track_info.index
Expand Down
7 changes: 6 additions & 1 deletion beets/autotag/mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,12 @@ def album_info(release):
for medium in release['medium-list']:
disctitle = medium.get('title')
format = medium.get('format')
for track in medium['track-list']:

all_tracks = medium['track-list']
if 'pregap' in medium:
all_tracks.insert(0, medium['pregap'])

for track in all_tracks:
# Basic information from the recording.
index += 1
ti = track_info(
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ New features:
and `min_width` options if no local imaging backend is available. :bug:`1460`
* The `move` command has a new `-p/--pretend` option, making the command show
how the items will be moved, without modifying the files on disk.

* The importer now supports matching of pregap tracks in releases.

Fixes:

Expand Down
5 changes: 4 additions & 1 deletion docs/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ A boolean controlling the track numbering style on multi-disc releases. By
default (``per_disc_numbering: no``), tracks are numbered per-release, so the
first track on the second disc has track number N+1 where N is the number of
tracks on the first disc. If this ``per_disc_numbering`` is enabled, then the
first track on each disc always has track number 1.
first track on each disc always has track number 1. This is true even when the
disc has pregap tracks, typically numbered 0 - in that case, the pregap track
of the first disc has track number 1 and every other track has its original
track number plus one.

If you enable ``per_disc_numbering``, you will likely want to change your
:ref:`path-format-config` also to include ``$disc`` before ``$track`` to make
Expand Down