1 # -*- coding: utf-8 -*-
4 def discogs_artistfind(data
, artist
):
6 for item
in data
.get('results',[]):
8 artistdata
['artist'] = item
['title']
9 # filter inaccurate results
10 match
= difflib
.SequenceMatcher(None, artist
.lower(), item
['title'].lower()).ratio()
11 score
= round(match
, 2)
13 artistdata
['thumb'] = item
['thumb']
14 artistdata
['genre'] = ''
15 artistdata
['born'] = ''
16 artistdata
['dcid'] = item
['id']
17 # discogs does not provide relevance, use our own
18 artistdata
['relevance'] = str(score
)
19 artists
.append(artistdata
)
22 def discogs_artistdetails(data
):
24 artistdata
['artist'] = data
['name']
25 artistdata
['biography'] = data
['profile']
28 for item
in data
['images']:
30 thumbdata
['image'] = item
['uri']
31 thumbdata
['preview'] = item
['uri150']
32 thumbdata
['aspect'] = 'thumb'
33 thumbs
.append(thumbdata
)
34 artistdata
['thumb'] = thumbs
37 def discogs_artistalbums(data
):
39 for item
in data
['releases']:
40 if item
['role'] == 'Main':
42 albumdata
['title'] = item
['title']
43 albumdata
['year'] = str(item
.get('year', ''))
44 albums
.append(albumdata
)