From 93c8f834f03e10b414f9faacc86d5cceece38314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rui=20Gonc=CC=A7alves?= Date: Tue, 2 Jun 2015 21:07:57 +0100 Subject: [PATCH] Add support for pregap tracks --- beets/autotag/__init__.py | 6 +++++- beets/autotag/mb.py | 7 ++++++- docs/changelog.rst | 2 +- docs/reference/config.rst | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/beets/autotag/__init__.py b/beets/autotag/__init__.py index 2f632f1ee..6ccd59d09 100644 --- a/beets/autotag/__init__.py +++ b/beets/autotag/__init__.py @@ -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 item.tracktotal = track_info.medium_total or len(album_info.tracks) else: item.track = track_info.index diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index b9402f3dc..8589a62aa 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -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( diff --git a/docs/changelog.rst b/docs/changelog.rst index 0ec2e53fb..296fd10a1 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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: diff --git a/docs/reference/config.rst b/docs/reference/config.rst index f9e577d4a..7f9443179 100644 --- a/docs/reference/config.rst +++ b/docs/reference/config.rst @@ -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