mirror of
https://github.com/fergalmoran/picard.git
synced 2026-02-23 08:06:46 +00:00
PICARD-105: Allow loading AcoustId recording as NAT
For NAT recordings AcoustId returns incomplete results and we have only the recording ID. Allow Picard to load such results as NAT.
This commit is contained in:
committed by
Laurent Monin
parent
0791312e5c
commit
8586bf95da
@@ -67,16 +67,22 @@ def _make_artist_credit_node(artists):
|
||||
|
||||
|
||||
def parse_recording(recording):
|
||||
if 'title' not in recording: # we have no metadata for this recording
|
||||
if 'id' not in recording: # we have no metadata for this recording
|
||||
return
|
||||
|
||||
recording_mb = {
|
||||
'id': recording['id'],
|
||||
'title': recording['title'],
|
||||
'artist-credit': _make_artist_credit_node(recording['artists']),
|
||||
'releases': _make_releases_node(recording)
|
||||
'id': recording['id']
|
||||
}
|
||||
|
||||
if 'title' in recording:
|
||||
recording_mb['title'] = recording['title']
|
||||
|
||||
if 'artists' in recording:
|
||||
recording_mb['artist-credit'] = _make_artist_credit_node(recording['artists'])
|
||||
|
||||
if 'releasegroups' in recording:
|
||||
recording_mb['releases'] = _make_releases_node(recording)
|
||||
|
||||
if 'duration' in recording:
|
||||
try:
|
||||
recording_mb['length'] = int(recording['duration']) * 1000
|
||||
|
||||
@@ -634,7 +634,8 @@ class File(QtCore.QObject, Item):
|
||||
self.tagger.get_release_group_by_id(rg['id']).loaded_albums.add(release['id'])
|
||||
self.tagger.move_file_to_track(self, release['id'], track['id'])
|
||||
else:
|
||||
self.tagger.move_file_to_nat(self, track['id'], node=track)
|
||||
node = track if 'title' in track else None
|
||||
self.tagger.move_file_to_nat(self, track['id'], node=node)
|
||||
|
||||
def lookup_metadata(self):
|
||||
"""Try to identify the file using the existing metadata."""
|
||||
|
||||
@@ -222,12 +222,13 @@ class Metadata(dict):
|
||||
|
||||
if 'title' in self:
|
||||
a = self['title']
|
||||
b = track['title']
|
||||
b = track.get('title', '')
|
||||
parts.append((similarity2(a, b), weights["title"]))
|
||||
|
||||
if 'artist' in self:
|
||||
a = self['artist']
|
||||
b = artist_credit_from_node(track['artist-credit'])[0]
|
||||
artist_credits = track.get('artist-credit', [])
|
||||
b = artist_credit_from_node(artist_credits)[0]
|
||||
parts.append((similarity2(a, b), weights["artist"]))
|
||||
|
||||
a = self.length
|
||||
|
||||
Reference in New Issue
Block a user