Repository: beetbox/beets

Issue:
Don't try to match non-audio media fetched from MusicBrainz
Matching a folder containing all audio files of a MB release made of CD+DVD for instance fails since beets does take into account also the video files.
For instance (1 CD+ 1DVD):
https://musicbrainz.org/release/2775743e-2d9c-4b7f-9baa-1d24dc44c769
https://musicbrainz.org/release/f457c3e1-0d98-4904-9d9e-a085bc5b232b
I imagine the same happens for enhanced CDs with some additional video track.
In general I think the right thing to do is that all media files that are marked as video in MB should not be considered for matching. After all beets currently only deals with audio files.


Discussion:
Sounds like #1210 and might be related to #1638
Indeed! Let’s track this in #1210.
I think that's actually a slightly different issue that may need separate consideration and re-opening.

#1210 is about having a single (or multiple) non-music tracks *inside a given medium*, mixed with audio tracks. See track 21 on [this](https://musicbrainz.org/release/49da37ee-065a-4d7f-a204-9dda8047aad4) - [xml](http://musicbrainz.org/ws/2/release/49da37ee-065a-4d7f-a204-9dda8047aad4?inc=artists+artist-credits+recordings+aliases)

This issue is about skipping a complete *medium*, for release that have CD+DVD for example. See [this](https://musicbrainz.org/release/1082195b-9b14-466f-a443-7cf830f64316) - [xml](http://musicbrainz.org/ws/2/release/1082195b-9b14-466f-a443-7cf830f64316?inc=artists+artist-credits+recordings+aliases)

In the later case, the medium to skip is identified by its `format` of type `DVD`:

```xml
<medium-list count="2">
  <medium>
    <position>1</position>
    <format id="9712d52a-4509-3d4b-a1a2-67c88c643e31">CD</format>
    <track-list count="10" offset="0">...</track-list>
  </medium>
  <medium>
    <position>2</position>
    <format id="2875c583-4580-3a90-b723-ba1b39921e23">DVD</format>
    <track-list offset="0" count="7">...</track-list>
  </medium>
</medium-list>
```
A list of formats is available [here](https://musicbrainz.org/doc/Release/Format)

Currently when trying to import this release, I get:

```
Tagging:
    Playing for Change - Songs Around the World
URL:
    https://musicbrainz.org/release/1082195b-9b14-466f-a443-7cf830f64316
(Similarity: 84.9%) (missing tracks) (2xCD, 2009, US, Hear Music)
CD 1
Missing tracks (7/17 - 41.2%):
 ! Stand by Me (#11)
 ! One Love (#12)
 ! War / No More Trouble (#13)
 ! Don't Worry (#14)
 ! Chanda Mama (#15)
 ! The Playing for Change Foundation (#16)
 ! Peace Through Music (#17)
[A]pply, More candidates, Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort?
```
Ah, I see! So they’re certainly related, but not exactly the same problem. Perhaps https://github.com/beetbox/beets/issues/2404 is a closer precedent?
I think that's different too. #2404 is about alternative *audio* media, like a CD and a DVD-Audio, or a CD and a Digital Media. I think this issue is simpler, it's just about ignoring media that don't contain audio (such as DVD, or CD-Rom (data) disks).
Got it; thanks for helping to clarify. I'll reopen this and change the title.

Resolving patch:
diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py
--- a/beets/autotag/mb.py
+++ b/beets/autotag/mb.py
@@ -36,6 +36,9 @@
 else:
     BASE_URL = 'http://musicbrainz.org/'
 
+NON_AUDIO_FORMATS = ['Data CD', 'DVD', 'DVD-Video', 'Blu-ray', 'HD-DVD', 'VCD',
+                     'SVCD', 'UMD', 'VHS']
+
 musicbrainzngs.set_useragent('beets', beets.__version__,
                              'http://beets.io/')
 
@@ -275,6 +278,9 @@ def album_info(release):
         disctitle = medium.get('title')
         format = medium.get('format')
 
+        if format in NON_AUDIO_FORMATS:
+            continue
+
         all_tracks = medium['track-list']
         if 'pregap' in medium:
             all_tracks.insert(0, medium['pregap'])


Test patch:
diff --git a/test/test_mb.py b/test/test_mb.py
--- a/test/test_mb.py
+++ b/test/test_mb.py
@@ -27,7 +27,7 @@
 
 class MBAlbumInfoTest(_common.TestCase):
     def _make_release(self, date_str='2009', tracks=None, track_length=None,
-                      track_artist=False):
+                      track_artist=False, medium_format='FORMAT'):
         release = {
             'title': 'ALBUM TITLE',
             'id': 'ALBUM ID',
@@ -90,7 +90,7 @@ def _make_release(self, date_str='2009', tracks=None, track_length=None,
             release['medium-list'].append({
                 'position': '1',
                 'track-list': track_list,
-                'format': 'FORMAT',
+                'format': medium_format,
                 'title': 'MEDIUM TITLE',
             })
         return release
@@ -324,6 +324,27 @@ def test_data_source(self):
         d = mb.album_info(release)
         self.assertEqual(d.data_source, 'MusicBrainz')
 
+    def test_skip_non_audio_dvd(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")
+        d = mb.album_info(release)
+        self.assertEqual(len(d.tracks), 0)
+
+    def test_skip_non_audio_dvd_video(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-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")
+        d = mb.album_info(release)
+        self.assertEqual(len(d.tracks), 2)
+
 
 class ParseIDTest(_common.TestCase):
     def test_parse_id_correct(self):