Skip to content

Commit

Permalink
acousticbrainz: handle query args depending on request action
Browse files Browse the repository at this point in the history
  • Loading branch information
phw committed Jul 2, 2021
1 parent 1dee55a commit 44680d2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions plugins/acousticbrainz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,20 +310,24 @@ def _batch(self, action, recording_ids, callback, result, response=None, reply=N
callback=partial(self._batch, action, recording_ids, callback, result))

def _do_request(self, action, recording_ids, callback):
queryargs = {
'recording_ids': ';'.join(recording_ids),
'map_classes': 'true'
}
self.album.tagger.webservice.get(
ACOUSTICBRAINZ_HOST,
ACOUSTICBRAINZ_PORT,
'/api/v1/%s' % action,
callback,
priority=True,
parse_response_type='json',
queryargs=queryargs
queryargs=self._get_query_args(action, recording_ids)
)

def _get_query_args(self, action, recording_ids):
queryargs = {
'recording_ids': ';'.join(recording_ids),
}
if action == 'high-level':
queryargs['map_classes'] = 'true'
return queryargs

def _merge_results(self, full, new):
mapping = new.get('mbid_mapping', {})
new = {mapping.get(k, k): v for (k, v) in new.items() if k != 'mbid_mapping'}
Expand Down

0 comments on commit 44680d2

Please sign in to comment.