1. Felix Krull
  2. rgain

Commits

Bart Nagel  committed 8fed15c

Use Musicbrainz album ID if available

  • Participants
  • Parent commits a2a8d9d
  • Branches mbid

Comments (0)

Files changed (2)

File README

View file
  • Ignore whitespace
 run.
 Prior to analyzing any audio data, ``collectiongain`` gathers all audio files in
 the directory and determines a so-called album ID for each from the file's tags:
- - If the file contains an 'album' tag, it is joined with either
+ - If the file contains a Musicbrainz album ID, that is used.
+ - Otherwise, if the file contains an 'album' tag, it is joined with either
     * an 'albumartist' tag, if that exists,
     * or the 'artist' tag
     * or nothing if neither tag exists.
    The resulting artist-album combination is the album ID for that file.
- - If the file doesn't contain an 'album' tag, it is presumed to be a single
-   track without album; it will only get track gain, no album gain.
+ - If the file doesn't contain a Musicbrainz album ID or an 'album' tag, it is
+   presumed to be a single track without album; it will only get track gain, no
+   album gain.
 Since this step takes a relatively long time, the album IDs are cached between
 several runs of ``collectiongain``. If a file was modified or a new file was
 added, the album ID will be (re-)calculated for that file only.
 With the exception of the manpages, all files are
 Copyright (c) 2009, 2010 Felix Krull <f_krull@gmx.de>
 The manpages were originally written for the Debian project and are
-Copyright (c) 2011 Simon Chopin <chopin.simon@gmail.com>
+Copyright (c) 2011 Simon Chopin <chopin.simon@gmail.com>

File rgain/script/collectiongain.py

View file
  • Ignore whitespace
     except Exception, exc:
         raise Error(u"%s: error - %s" % (filepath, exc))
 
+    album_id = None
+    if ext == ".mp3":
+        for frame in tags.itervalues():
+            if isinstance(frame, TXXX) and frame.desc == "MusicBrainz Album Id":
+                album_id = frame.text[0]
+                break
+    else:
+        try:
+            album_id = tags.get("musicbrainz_albumid")[0]
+        except TypeError:
+            pass
+
+    if album_id is not None:
+        return album_id
+
     if ext == ".mp3":
         if "TALB" in tags:
             album = tags["TALB"].text[0]