Skip to content

Commit

Permalink
Added a setting to control which formats are ignored
Browse files Browse the repository at this point in the history
This is related to beetbox#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 beetbox#1210.
  • Loading branch information
nguillaumin committed Jan 2, 2018
1 parent 563b0f4 commit 22c4f9c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.
5 changes: 1 addition & 4 deletions beets/autotag/mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
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__,
Expand Down Expand Up @@ -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']
Expand Down
1 change: 1 addition & 0 deletions beets/config_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 7 additions & 3 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`


Expand Down
13 changes: 13 additions & 0 deletions docs/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 7 additions & 11 deletions test/test_mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,24 +326,20 @@ def test_data_source(self):
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)

Expand Down

0 comments on commit 22c4f9c

Please sign in to comment.