Make 'media' an item level field.

Releases can consist of discs of various media types, most typically
CD/DVD combo releases. Having the media value an album level field
forces all discs to be of the same type. Making it an item level
field instead seems to be the proper thing to do here.

Fixes #161
This commit is contained in:
Heinz Wiesinger 2014-10-04 11:01:18 +02:00
parent 6667ca925d
commit ec56f2bbd4
6 changed files with 12 additions and 6 deletions

View file

@ -122,10 +122,12 @@ def apply_metadata(album_info, mapping):
'language', 'language',
'country', 'country',
'albumstatus', 'albumstatus',
'media',
'albumdisambig'): 'albumdisambig'):
value = getattr(album_info, field) value = getattr(album_info, field)
if value is not None: if value is not None:
item[field] = value item[field] = value
if track_info.disctitle is not None: if track_info.disctitle is not None:
item.disctitle = track_info.disctitle item.disctitle = track_info.disctitle
if track_info.media is not None:
item.media = track_info.media

View file

@ -127,6 +127,7 @@ class TrackInfo(object):
- ``artist_id`` - ``artist_id``
- ``length``: float: duration of the track in seconds - ``length``: float: duration of the track in seconds
- ``index``: position on the entire release - ``index``: position on the entire release
- ``media``: delivery mechanism (Vinyl, etc.)
- ``medium``: the disc number this track appears on in the album - ``medium``: the disc number this track appears on in the album
- ``medium_index``: the track's position on the disc - ``medium_index``: the track's position on the disc
- ``medium_total``: the number of tracks on the item's disc - ``medium_total``: the number of tracks on the item's disc
@ -141,13 +142,15 @@ class TrackInfo(object):
def __init__(self, title, track_id, artist=None, artist_id=None, def __init__(self, title, track_id, artist=None, artist_id=None,
length=None, index=None, medium=None, medium_index=None, length=None, index=None, medium=None, medium_index=None,
medium_total=None, artist_sort=None, disctitle=None, medium_total=None, artist_sort=None, disctitle=None,
artist_credit=None, data_source=None, data_url=None): artist_credit=None, data_source=None, data_url=None,
media=None):
self.title = title self.title = title
self.track_id = track_id self.track_id = track_id
self.artist = artist self.artist = artist
self.artist_id = artist_id self.artist_id = artist_id
self.length = length self.length = length
self.index = index self.index = index
self.media = media
self.medium = medium self.medium = medium
self.medium_index = medium_index self.medium_index = medium_index
self.medium_total = medium_total self.medium_total = medium_total
@ -163,7 +166,7 @@ class TrackInfo(object):
to Unicode. to Unicode.
""" """
for fld in ['title', 'artist', 'medium', 'artist_sort', 'disctitle', for fld in ['title', 'artist', 'medium', 'artist_sort', 'disctitle',
'artist_credit']: 'artist_credit', 'media']:
value = getattr(self, fld) value = getattr(self, fld)
if isinstance(value, str): if isinstance(value, str):
setattr(self, fld, value.decode(codec, 'ignore')) setattr(self, fld, value.decode(codec, 'ignore'))

View file

@ -209,6 +209,7 @@ def album_info(release):
index = 0 index = 0
for medium in release['medium-list']: for medium in release['medium-list']:
disctitle = medium.get('title') disctitle = medium.get('title')
format = medium.get('format')
for track in medium['track-list']: for track in medium['track-list']:
# Basic information from the recording. # Basic information from the recording.
index += 1 index += 1
@ -220,6 +221,7 @@ def album_info(release):
len(medium['track-list']), len(medium['track-list']),
) )
ti.disctitle = disctitle ti.disctitle = disctitle
ti.media = format
# Prefer track data, where present, over recording data. # Prefer track data, where present, over recording data.
if track.get('title'): if track.get('title'):

View file

@ -729,7 +729,6 @@ class Album(LibModel):
'language': types.STRING, 'language': types.STRING,
'country': types.STRING, 'country': types.STRING,
'albumstatus': types.STRING, 'albumstatus': types.STRING,
'media': types.STRING,
'albumdisambig': types.STRING, 'albumdisambig': types.STRING,
'rg_album_gain': types.NULL_FLOAT, 'rg_album_gain': types.NULL_FLOAT,
'rg_album_peak': types.NULL_FLOAT, 'rg_album_peak': types.NULL_FLOAT,
@ -769,7 +768,6 @@ class Album(LibModel):
'language', 'language',
'country', 'country',
'albumstatus', 'albumstatus',
'media',
'albumdisambig', 'albumdisambig',
'rg_album_gain', 'rg_album_gain',
'rg_album_peak', 'rg_album_peak',

View file

@ -88,7 +88,7 @@ def _item(track_info, album_info, album_id):
'mb_artistid': t.artist_id, 'mb_artistid': t.artist_id,
'mb_releasegroupid': a.releasegroup_id, 'mb_releasegroupid': a.releasegroup_id,
'mb_trackid': t.track_id, 'mb_trackid': t.track_id,
'media': a.media, 'media': t.media,
'month': a.month, 'month': a.month,
'script': a.script, 'script': a.script,
'title': t.title, 'title': t.title,

View file

@ -37,6 +37,7 @@ Fixes:
temporarily temporarily
* :doc:`/plugins/discogs`: Recover from HTTP errors when communicating with * :doc:`/plugins/discogs`: Recover from HTTP errors when communicating with
the Discogs servers. Thanks to Dustin Rodriguez. the Discogs servers. Thanks to Dustin Rodriguez.
* Fix storing media types for albums consisting of different media.
1.3.8 (September 17, 2014) 1.3.8 (September 17, 2014)