From d325bceb1d2d3d8d863839ac3258faa609401cec Mon Sep 17 00:00:00 2001 From: Nicolas Guillaumin Date: Sun, 31 Dec 2017 10:46:48 -0800 Subject: [PATCH] Added a setting to control if video tracks are ignored Users may want to keep tracking video tracks, for example if they rip the audio part of the video tracks. Added a setting to allow this. --- beets/autotag/mb.py | 3 ++- beets/config_default.yaml | 1 + docs/reference/config.rst | 11 +++++++++++ test/test_mb.py | 15 ++++++++++++++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 6cf2818fd..e32f73329 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -294,7 +294,8 @@ def album_info(release): continue if ('video' in track['recording'] and - track['recording']['video'] == 'true'): + track['recording']['video'] == 'true' and + config['match']['ignore_video_tracks'].get(bool) is True): continue # Basic information from the recording. diff --git a/beets/config_default.yaml b/beets/config_default.yaml index 942459738..01c1e0f65 100644 --- a/beets/config_default.yaml +++ b/beets/config_default.yaml @@ -126,5 +126,6 @@ match: original_year: no ignored: [] required: [] + ignore_video_tracks: yes track_length_grace: 10 track_length_max: 30 diff --git a/docs/reference/config.rst b/docs/reference/config.rst index 4015a4fc2..84f41a385 100644 --- a/docs/reference/config.rst +++ b/docs/reference/config.rst @@ -774,6 +774,17 @@ want to enforce to the ``required`` setting:: No tags are required by default. +.. _ignore_video_tracks: + +ignore_video_tracks +~~~~~~~~~~~~~~~~~~~ + +By default, video tracks within a release will be ignored. If you want them to +be included (for example if you would like to track the audio-only versions of +the video tracks), set it to ``no``. + +Default: ``yes``. + .. _path-format-config: Path Format Configuration diff --git a/test/test_mb.py b/test/test_mb.py index 4683793f4..35f7c3aa2 100644 --- a/test/test_mb.py +++ b/test/test_mb.py @@ -358,7 +358,7 @@ class MBAlbumInfoTest(_common.TestCase): self.assertEqual(d.tracks[0].title, 'TITLE ONE') self.assertEqual(d.tracks[1].title, 'TITLE TWO') - def test_skip_video_track(self): + 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, False, True), @@ -369,6 +369,19 @@ class MBAlbumInfoTest(_common.TestCase): self.assertEqual(d.tracks[0].title, 'TITLE ONE') self.assertEqual(d.tracks[1].title, 'TITLE TWO') + def test_no_skip_video_tracks_if_configured(self): + config['match']['ignore_video_tracks'] = False + tracks = [self._make_track('TITLE ONE', 'ID ONE', 100.0 * 1000.0), + self._make_track('TITLE VIDEO', 'ID VIDEO', 100.0 * 1000.0, + False, True), + self._make_track('TITLE TWO', 'ID TWO', 200.0 * 1000.0)] + release = self._make_release(tracks=tracks) + d = mb.album_info(release) + self.assertEqual(len(d.tracks), 3) + self.assertEqual(d.tracks[0].title, 'TITLE ONE') + self.assertEqual(d.tracks[1].title, 'TITLE VIDEO') + self.assertEqual(d.tracks[2].title, 'TITLE TWO') + class ParseIDTest(_common.TestCase): def test_parse_id_correct(self):