Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create arranger_sort, lyricist_sort, performer and performer_sort tags #2563

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ed54f4a
Add arranger_sort and lyricist_sort to test_metadata.py
dosoe May 16, 2017
6d81b8a
Add lyricist_sort and arranger_sort to the library
dosoe May 16, 2017
a1d840a
Add lyricist_sort and arranger_sort tags
dosoe May 16, 2017
f28c9f7
Fetch arranger_sort and lyricist_sort tags similarly to composer_sort
dosoe May 16, 2017
14ae949
Add arranger_sort and lyricist_sort to apply_*_metadata
dosoe May 16, 2017
0295749
Syntax error
dosoe May 16, 2017
c589d50
The tags 'arranger_sort' and 'lyricist_sort' are not in the tag mapping
dosoe May 16, 2017
8f5df30
Since there is no tag mapping, they can't be read from the files
dosoe May 16, 2017
ddb8f1a
Add lyricist_sort and arranger_sort tags in TrackInfo function
dosoe May 19, 2017
bd0380f
Merge branch 'master' of https://github.com/beetbox/beets
dosoe May 19, 2017
4ba9cd4
Add arranger_sort and lyricist_sort to tag lists in test files
dosoe May 25, 2017
092151b
Merge branch 'master' of https://github.com/beetbox/beets
dosoe Jun 21, 2017
2a93b06
Removed new tags from test_mediafile.py
dosoe Jun 21, 2017
47a7ffc
Merge branch 'master' of https://github.com/beetbox/beets
dosoe Jun 22, 2017
68c275a
changelog entry
dosoe Jun 22, 2017
c957689
Add performer tag similar to arranger_sort.
dosoe Jun 27, 2017
1b42f5b
Add relation direction for performers
dosoe Jun 27, 2017
970aefb
"type" already has a sense in python syntax
dosoe Jun 27, 2017
e4ca5c0
changelog
dosoe Jun 27, 2017
f087298
testing
dosoe Jun 27, 2017
871b1c1
Merge branch 'master' of https://github.com/beetbox/beets
dosoe Aug 2, 2017
34c9bbe
Synching with the main branch
dosoe Mar 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions beets/autotag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,20 @@ def apply_item_metadata(item, track_info):

if track_info.lyricist is not None:
item.lyricist = track_info.lyricist
if track_info.lyricist_sort is not None:
item.lyricist_sort = track_info.lyricist_sort
if track_info.composer is not None:
item.composer = track_info.composer
if track_info.composer_sort is not None:
item.composer_sort = track_info.composer_sort
if track_info.arranger is not None:
item.arranger = track_info.arranger
if track_info.arranger_sort is not None:
item.arranger_sort = track_info.arranger_sort
if track_info.performer is not None:
item.performer = track_info.performer
if track_info.performer_sort is not None:
item.performer_sort = track_info.performer_sort

# At the moment, the other metadata is left intact (including album
# and track number). Perhaps these should be emptied?
Expand Down Expand Up @@ -155,11 +163,19 @@ def apply_metadata(album_info, mapping):

if track_info.lyricist is not None:
item.lyricist = track_info.lyricist
if track_info.lyricist_sort is not None:
item.lyricist_sort = track_info.lyricist_sort
if track_info.composer is not None:
item.composer = track_info.composer
if track_info.composer_sort is not None:
item.composer_sort = track_info.composer_sort
if track_info.arranger is not None:
item.arranger = track_info.arranger
if track_info.arranger_sort is not None:
item.arranger_sort = track_info.arranger_sort
if track_info.performer is not None:
item.performer = track_info.performer
if track_info.performer_sort is not None:
item.performer_sort = track_info.performer_sort

item.track_alt = track_info.track_alt
10 changes: 8 additions & 2 deletions beets/autotag/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ 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,
media=None, lyricist=None, composer=None, composer_sort=None,
arranger=None, track_alt=None):
media=None, lyricist=None, lyricist_sort=None,
composer=None, composer_sort=None, arranger=None,
arranger_sort=None, track_alt=None, performer=None,
performer_sort=None):
self.title = title
self.track_id = track_id
self.artist = artist
Expand All @@ -174,9 +176,13 @@ def __init__(self, title, track_id, artist=None, artist_id=None,
self.data_source = data_source
self.data_url = data_url
self.lyricist = lyricist
self.lyricist_sort = lyricist_sort
self.composer = composer
self.composer_sort = composer_sort
self.arranger = arranger
self.arranger_sort = arranger_sort
self.performer = performer
self.performer_sort = performer_sort
self.track_alt = track_alt

# As above, work around a bug in python-musicbrainz-ngs.
Expand Down
41 changes: 39 additions & 2 deletions beets/autotag/mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def track_info(recording, index=None, medium=None, medium_index=None,
info.length = int(recording['length']) / (1000.0)

lyricist = []
lyricist_sort = []
composer = []
composer_sort = []
for work_relation in recording.get('work-relation-list', ()):
Expand All @@ -219,24 +220,60 @@ def track_info(recording, index=None, medium=None, medium_index=None,
type = artist_relation['type']
if type == 'lyricist':
lyricist.append(artist_relation['artist']['name'])
lyricist_sort.append(
artist_relation['artist']['sort-name'])
elif type == 'composer':
composer.append(artist_relation['artist']['name'])
composer_sort.append(
artist_relation['artist']['sort-name'])
if lyricist:
info.lyricist = u', '.join(lyricist)
info.lyricist_sort = u', '.join(lyricist_sort)
if composer:
info.composer = u', '.join(composer)
info.composer_sort = u', '.join(composer_sort)

arranger = []
arranger_sort = []
performer = []
performer_sort = []
performer_tmp = {}
performer_types = ['performer', 'instrument', 'vocal',
'conductor', 'performing orchestra',
'chorus master', 'concertmaster'
]
for artist_relation in recording.get('artist-relation-list', ()):
if 'type' in artist_relation:
type = artist_relation['type']
if type == 'arranger':
rel_type = artist_relation['type']
if rel_type == 'arranger':
arranger.append(artist_relation['artist']['name'])
arranger_sort.append(
artist_relation['artist']['sort-name'])
if rel_type in performer_types and \
artist_relation.get('direction') == 'backward':
artist_tmp = artist_relation['artist']['name']
performer_tmp[artist_tmp] = []
if 'attribute-list' in artist_relation:
for attribute in artist_relation['attribute-list']:
performer_tmp[artist_tmp].append(attribute)
else:
performer_tmp[artist_tmp].append(artist_relation['type'])
performer_tmp[artist_relation['artist']['sort-name']] =\
performer_tmp[artist_tmp]
performer.append(artist_tmp +
'(' + u', '.join(performer_tmp[artist_tmp]) +
')')
performer_sort.append(artist_relation['artist']['sort-name'] +
'(' +
u', '.join(performer_tmp[artist_tmp]) +
')')
if arranger:
info.arranger = u', '.join(arranger)
info.arranger_sort = u', '.join(arranger_sort)

if performer:
info.performer = u', '.join(performer)
info.performer_sort = u', '.join(performer_sort)

info.decode()
return info
Expand Down
4 changes: 4 additions & 0 deletions beets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,13 @@ class Item(LibModel):
'albumartist_credit': types.STRING,
'genre': types.STRING,
'lyricist': types.STRING,
'lyricist_sort': types.STRING,
'composer': types.STRING,
'composer_sort': types.STRING,
'arranger': types.STRING,
'arranger_sort': types.STRING,
'performer': types.STRING,
'performer_sort': types.STRING,
'grouping': types.STRING,
'year': types.PaddedInt(4),
'month': types.PaddedInt(2),
Expand Down
8 changes: 3 additions & 5 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,9 @@ There are some changes for developers:
missing values into type-specific null-like values. This should help in
cases where a string field is unexpectedly `None` sometimes instead of just
showing up as an empty string. :bug:`2605`
* Refactored the move functions the `beets.library` module and the
`manipulate_files` function in `beets.importer` to use a single parameter
describing the file operation instead of multiple Boolean flags.
There is a new numerated type describing how to move, copy, or link files.
:bug:`2682`

* Added new tags arranger_sort, lyricist_sort, performer and performer_sort.
Thanks to :user:`dosoe`. :bug:`2563`


1.4.5 (June 20, 2017)
Expand Down
5 changes: 5 additions & 0 deletions test/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ def item(lib=None):
album=u'the album',
genre=u'the genre',
lyricist=u'the lyricist',
lyricist_sort=u'the lyricist sort name',
composer=u'the composer',
composer_sort=u'the composer sort name',
arranger=u'the arranger',
arranger_sort=u'the arranger sort name',
performer=u'the performer and his role',
performer_sort=u'the performer sort name and his role',
grouping=u'the grouping',
year=1,
month=2,
Expand Down