Added artist sort name

- MP3 tag saved
- Available template field as $artist_sort_name
This commit is contained in:
Paul Provost 2012-03-10 18:51:48 -05:00
parent 3ffbe171e5
commit 68952209d5
5 changed files with 25 additions and 3 deletions

View file

@ -125,6 +125,10 @@ def apply_metadata(items, album_info):
item.artist = track_info.artist
else:
item.artist = album_info.artist
if track_info.artist_sort_name:
item.artist_sort_name = track_info.artist_sort_name
elif album_info.artist_sort_name:
item.artist_sort_name = album_info.artist_sort_name
item.albumartist = album_info.artist
item.album = album_info.album
item.tracktotal = len(items)

View file

@ -36,13 +36,14 @@ class AlbumInfo(object):
- ``day``: release day
- ``label``: music label responsible for the release
- ``mediums``: the number of discs in this release
- ``artist_sort_name``: name of the release's artists for sorting
The fields up through ``tracks`` are required. The others are
optional and may be None.
"""
def __init__(self, album, album_id, artist, artist_id, tracks, asin=None,
albumtype=None, va=False, year=None, month=None, day=None,
label=None, mediums=None):
label=None, mediums=None, artist_sort_name=None):
self.album = album
self.album_id = album_id
self.artist = artist
@ -56,6 +57,8 @@ class AlbumInfo(object):
self.day = day
self.label = label
self.mediums = mediums
if artist_sort_name != '':
self.artist_sort_name = artist_sort_name
class TrackInfo(object):
"""Describes a canonical track present on a release. Appears as part
@ -68,12 +71,14 @@ class TrackInfo(object):
- ``length``: float: duration of the track in seconds
- ``medium``: the disc number this track appears on in the album
- ``medium_index``: the track's position on the disc
- ``artist_sort_name``: name of the release's artists for sorting
Only ``title`` and ``track_id`` are required. The rest of the fields
may be None.
"""
def __init__(self, title, track_id, artist=None, artist_id=None,
length=None, medium=None, medium_index=None):
length=None, medium=None, medium_index=None,
artist_sort_name=None):
self.title = title
self.track_id = track_id
self.artist = artist
@ -81,7 +86,8 @@ class TrackInfo(object):
self.length = length
self.medium = medium
self.medium_index = medium_index
if artist_sort_name != '':
self.artist_sort_name = artist_sort_name
# Aggregation of sources.

View file

@ -85,12 +85,17 @@ def album_info(release):
"""
# Get artist name using join phrases.
artist_parts = []
artist_sort_parts = []
for el in release['artist-credit']:
if isinstance(el, basestring):
artist_parts.append(el)
else:
artist_parts.append(el['artist']['name'])
artist_sort_parts.append(el['artist']['sort-name'])
artist_name = ''.join(artist_parts)
artist_sort_name = ', '.join(artist_sort_parts)
if artist_sort_name == artist_name:
artist_sort_name = ''
# Basic info.
track_infos = []
@ -111,6 +116,7 @@ def album_info(release):
release['artist-credit'][0]['artist']['id'],
track_infos,
mediums=len(release['medium-list']),
artist_sort_name = artist_sort_name,
)
info.va = info.artist_id == VARIOUS_ARTISTS_ID
if 'asin' in release:

View file

@ -42,6 +42,7 @@ ITEM_FIELDS = [
('title', 'text', True, True),
('artist', 'text', True, True),
('artist_sort_name', 'text', True, True),
('album', 'text', True, True),
('albumartist', 'text', True, True),
('genre', 'text', True, True),

View file

@ -738,6 +738,11 @@ class MediaFile(object):
mp4 = StorageStyle("\xa9ART"),
etc = StorageStyle('artist'),
)
artist_sort_name = MediaField(
mp3 = StorageStyle('TSOP'),
mp4 = StorageStyle("soar"),
etc = StorageStyle('ARTISTSORT'),
)
album = MediaField(
mp3 = StorageStyle('TALB'),
mp4 = StorageStyle("\xa9alb"),