From 210b9d316f9bd73985748f0b979d1dce9b30aa64 Mon Sep 17 00:00:00 2001 From: Filipe Fortes Date: Sun, 2 Sep 2018 10:09:10 -0400 Subject: [PATCH 1/2] Allow ignoring of audio data tracks on import --- beets/autotag/mb.py | 3 ++- beets/config_default.yaml | 1 + docs/changelog.rst | 2 ++ docs/reference/config.rst | 9 +++++++++ test/test_mb.py | 12 ++++++++++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 2b28a5cc4..50d28a538 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -281,7 +281,8 @@ def album_info(release): continue all_tracks = medium['track-list'] - if 'data-track-list' in medium: + if ('data-track-list' in medium + and not config['match']['ignore_data_tracks']): all_tracks += medium['data-track-list'] track_count = len(all_tracks) diff --git a/beets/config_default.yaml b/beets/config_default.yaml index 273f94235..adbe5d616 100644 --- a/beets/config_default.yaml +++ b/beets/config_default.yaml @@ -129,6 +129,7 @@ match: ignored: [] required: [] ignored_media: [] + ignore_data_tracks: no ignore_video_tracks: yes track_length_grace: 10 track_length_max: 30 diff --git a/docs/changelog.rst b/docs/changelog.rst index 04d3619e8..997fd6f3d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -40,6 +40,8 @@ New features: Fixes: +* A new importer option, :ref:`ignore_data_tracks`, lets you skip audio tracks + contained in data files :bug:`xxxx` * Restore iTunes Store album art source, and remove the dependency on python-itunes_, which had gone unmaintained and was not py3 compatible. Thanks to :user:`ocelma` for creating python-itunes_ in the first place. diff --git a/docs/reference/config.rst b/docs/reference/config.rst index 94dab4345..de4c58a15 100644 --- a/docs/reference/config.rst +++ b/docs/reference/config.rst @@ -811,6 +811,15 @@ No formats are ignored by default. .. _ignore_video_tracks: +ignore_data_tracks +~~~~~~~~~~~~~~~~~~~ + +By default, audio files contained in data tracks within a release are included +in the album's tracklist. If you do not want them to be included, set it to +``yes``. + +Default: ``no``. + ignore_video_tracks ~~~~~~~~~~~~~~~~~~~ diff --git a/test/test_mb.py b/test/test_mb.py index b61ebe59a..a6d31ef7b 100644 --- a/test/test_mb.py +++ b/test/test_mb.py @@ -383,6 +383,18 @@ class MBAlbumInfoTest(_common.TestCase): self.assertEqual(d.tracks[1].title, 'TITLE TWO') self.assertEqual(d.tracks[2].title, 'TITLE AUDIO DATA') + def test_skip_audio_data_tracks_if_configured(self): + config['match']['ignore_data_tracks'] = True + tracks = [self._make_track('TITLE ONE', 'ID ONE', 100.0 * 1000.0), + self._make_track('TITLE TWO', 'ID TWO', 200.0 * 1000.0)] + data_tracks = [self._make_track('TITLE AUDIO DATA', 'ID DATA TRACK', + 100.0 * 1000.0)] + release = self._make_release(tracks=tracks, data_tracks=data_tracks) + d = mb.album_info(release) + self.assertEqual(len(d.tracks), 2) + self.assertEqual(d.tracks[0].title, 'TITLE ONE') + self.assertEqual(d.tracks[1].title, 'TITLE TWO') + def test_skip_video_tracks_by_default(self): tracks = [self._make_track('TITLE ONE', 'ID ONE', 100.0 * 1000.0), self._make_track('TITLE VIDEO', 'ID VIDEO', 100.0 * 1000.0, From 5e518c7d9e1e216a35409967cdd6c1797f77b68e Mon Sep 17 00:00:00 2001 From: Filipe Fortes Date: Sun, 2 Sep 2018 10:53:00 -0400 Subject: [PATCH 2/2] Set bug number --- docs/changelog.rst | 2 +- docs/reference/config.rst | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 997fd6f3d..44b56f014 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -41,7 +41,7 @@ New features: Fixes: * A new importer option, :ref:`ignore_data_tracks`, lets you skip audio tracks - contained in data files :bug:`xxxx` + contained in data files :bug:`3021` * Restore iTunes Store album art source, and remove the dependency on python-itunes_, which had gone unmaintained and was not py3 compatible. Thanks to :user:`ocelma` for creating python-itunes_ in the first place. diff --git a/docs/reference/config.rst b/docs/reference/config.rst index de4c58a15..e7703f3a8 100644 --- a/docs/reference/config.rst +++ b/docs/reference/config.rst @@ -809,7 +809,7 @@ of audio, for example:: No formats are ignored by default. -.. _ignore_video_tracks: +.. _ignore_data_tracks: ignore_data_tracks ~~~~~~~~~~~~~~~~~~~ @@ -820,6 +820,8 @@ in the album's tracklist. If you do not want them to be included, set it to Default: ``no``. +.. _ignore_video_tracks: + ignore_video_tracks ~~~~~~~~~~~~~~~~~~~