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',
'country',
'albumstatus',
'media',
'albumdisambig'):
value = getattr(album_info, field)
if value is not None:
item[field] = value
if track_info.disctitle is not None:
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``
- ``length``: float: duration of the track in seconds
- ``index``: position on the entire release
- ``media``: delivery mechanism (Vinyl, etc.)
- ``medium``: the disc number this track appears on in the album
- ``medium_index``: the track's position on the 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,
length=None, index=None, medium=None, medium_index=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.track_id = track_id
self.artist = artist
self.artist_id = artist_id
self.length = length
self.index = index
self.media = media
self.medium = medium
self.medium_index = medium_index
self.medium_total = medium_total
@ -163,7 +166,7 @@ class TrackInfo(object):
to Unicode.
"""
for fld in ['title', 'artist', 'medium', 'artist_sort', 'disctitle',
'artist_credit']:
'artist_credit', 'media']:
value = getattr(self, fld)
if isinstance(value, str):
setattr(self, fld, value.decode(codec, 'ignore'))

View file

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

View file

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

View file

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

View file

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