Added a setting to control which formats are ignored

This is related to #2688 where a list of hard-coded non-audio formats to
ignore has been added. Some users may want to rip the audio portion of
video tracks (e.g. DVD-Video) so it would be beneficial to let them
control exactly which formats to ignore.

I added a `ignored_formats` setting for that purpose and moved the
hard-coded list into the config. Test and documentation have been
updated accordingly.

Aside: I also clarified the changelog a bit regarding this change and
the related one for #1210.
This commit is contained in:
Nicolas Guillaumin 2018-01-02 11:03:02 -08:00
parent 563b0f47bd
commit 22c4f9cb97
5 changed files with 29 additions and 18 deletions

View file

@ -36,9 +36,6 @@ if util.SNI_SUPPORTED:
else:
BASE_URL = 'http://musicbrainz.org/'
NON_AUDIO_FORMATS = ['Data CD', 'DVD', 'DVD-Video', 'Blu-ray', 'HD-DVD', 'VCD',
'SVCD', 'UMD', 'VHS']
SKIPPED_TRACKS = ['[data track]']
musicbrainzngs.set_useragent('beets', beets.__version__,
@ -280,7 +277,7 @@ def album_info(release):
disctitle = medium.get('title')
format = medium.get('format')
if format in NON_AUDIO_FORMATS:
if format in config['match']['ignored_formats'].as_str_seq():
continue
all_tracks = medium['track-list']

View file

@ -126,6 +126,7 @@ match:
original_year: no
ignored: []
required: []
ignored_formats: ['Data CD', 'DVD', 'DVD-Video', 'Blu-ray', 'HD-DVD', 'VCD', 'SVCD', 'UMD', 'VHS']
ignore_video_tracks: yes
track_length_grace: 10
track_length_max: 30

View file

@ -8,9 +8,13 @@ Changelog goes here!
Fixes:
* Non-audio media (DVD-Video, etc.) are now skipped by the autotagger. :bug:`2688`
* Non-audio tracks (data tracks, video tracks, etc.) are now skipped by the
autotagger. :bug:`1210`
* Non-audio media (DVD-Video, etc.) are now skipped by default by the
autotagger. A new option ``ignored_formats`` controls which formats to
ignore. :bug:`2688`
* Non-audio tracks (data tracks, video tracks) are now skipped by the
autotagger. Data tracks will always be ignored, but a new option
``ignore_video_tracks`` has been added to control if video tracks should be
ignored or not. :bug:`1210`
* :doc:`/plugins/replaygain`: Fix a corner-case with the ``bs1770gain`` backend where ReplayGain values were assigned to the wrong files. Now ``bs1770gain`` version 0.4.6 or later is required. :bug:`2777`

View file

@ -774,6 +774,19 @@ want to enforce to the ``required`` setting::
No tags are required by default.
.. _ignored_formats:
ignored_formats
~~~~~~~~~~~~~~~
By default a list of release formats considered not containing audio will be
ignored. If you want them to be included (for example if you would like to
consider the audio portion of DVD-Video tracks) you can alter the list
accordingly.
Default: ``['Data CD', 'DVD', 'DVD-Video', 'Blu-ray', 'HD-DVD', 'VCD', 'SVCD',
'UMD', 'VHS']``.
.. _ignore_video_tracks:
ignore_video_tracks

View file

@ -326,24 +326,20 @@ class MBAlbumInfoTest(_common.TestCase):
d = mb.album_info(release)
self.assertEqual(d.data_source, 'MusicBrainz')
def test_skip_non_audio_dvd(self):
def test_ignored_formats(self):
config['match']['ignored_formats'] = ['IGNORED1', 'IGNORED2']
tracks = [self._make_track('TITLE ONE', 'ID ONE', 100.0 * 1000.0),
self._make_track('TITLE TWO', 'ID TWO', 200.0 * 1000.0)]
release = self._make_release(tracks=tracks, medium_format="DVD")
release = self._make_release(tracks=tracks, medium_format="IGNORED1")
d = mb.album_info(release)
self.assertEqual(len(d.tracks), 0)
def test_skip_non_audio_dvd_video(self):
def test_no_ignored_formats(self):
config['match']['ignored_formats'] = ['IGNORED1', 'IGNORED2']
tracks = [self._make_track('TITLE ONE', 'ID ONE', 100.0 * 1000.0),
self._make_track('TITLE TWO', 'ID TWO', 200.0 * 1000.0)]
release = self._make_release(tracks=tracks, medium_format="DVD-Video")
d = mb.album_info(release)
self.assertEqual(len(d.tracks), 0)
def test_no_skip_dvd_audio(self):
tracks = [self._make_track('TITLE ONE', 'ID ONE', 100.0 * 1000.0),
self._make_track('TITLE TWO', 'ID TWO', 200.0 * 1000.0)]
release = self._make_release(tracks=tracks, medium_format="DVD-Audio")
release = self._make_release(tracks=tracks,
medium_format="NON-IGNORED")
d = mb.album_info(release)
self.assertEqual(len(d.tracks), 2)