Commit bb5d6110 authored by SVN-Git Migration's avatar SVN-Git Migration

Imported Upstream version 0.7

parent c4532e4d
Metadata-Version: 1.0
Name: pyacoustid
Version: 0.6
Version: 0.7
Summary: bindings for Chromaprint acoustic fingerprinting and the Acoustid API
Home-page: https://github.com/sampsyo/pyacoustid
Author: Adrian Sampson
......@@ -108,6 +108,11 @@ Description: Chromaprint and Acoustid for Python
Version History
---------------
0.7
Properly encode Unicode parameters (resolves a ``UnicodeEncodeError``
in fingerprint submission).
Parse all recordings for each Acoustid lookup result.
0.6
Add a new function, ``fingerprint_file``, that automatically selects a
backend for fingerprinting a single file.
......
......@@ -100,6 +100,11 @@ used when the Chromaprint library or fpcalc command-line tool cannot be found.
Version History
---------------
0.7
Properly encode Unicode parameters (resolves a ``UnicodeEncodeError``
in fingerprint submission).
Parse all recordings for each Acoustid lookup result.
0.6
Add a new function, ``fingerprint_file``, that automatically selects a
backend for fingerprinting a single file.
......
......@@ -155,7 +155,18 @@ def _api_request(url, params):
which are encoded as compressed form data, and returns a parsed JSON
response. May raise a WebServiceError if the request fails.
"""
body = _compress(urllib.urlencode(params))
# Encode any Unicode values in parameters. (urllib.urlencode in
# Python 2.x operates on bytestrings, so a Unicode error is raised
# if non-ASCII characters are passed in a Unicode string.)
byte_params = {}
for key, value in params.iteritems():
if isinstance(key, unicode):
key = key.encode('utf8')
if isinstance(value, unicode):
value = value.encode('utf8')
byte_params[key] = value
body = _compress(urllib.urlencode(byte_params))
req = urllib2.Request(url, body, {
'Content-Encoding': 'gzip',
'Accept-Encoding': 'gzip',
......@@ -221,19 +232,19 @@ def parse_lookup_result(data):
for result in data['results']:
score = result['score']
if not result.get('recordings'):
if 'recordings' not in result:
# No recording attached. This result is not very useful.
continue
recording = result['recordings'][0]
# Get the artist if available.
if recording.get('artists'):
artist = recording['artists'][0]
artist_name = artist['name']
else:
artist_name = None
for recording in result['recordings']:
# Get the artist if available.
if recording.get('artists'):
names = [artist['name'] for artist in recording['artists']]
artist_name = '; '.join(names)
else:
artist_name = None
yield score, recording['id'], recording.get('title'), artist_name
yield score, recording['id'], recording.get('title'), artist_name
def _fingerprint_file_audioread(path):
"""Fingerprint a file by using audioread and chromaprint."""
......
Metadata-Version: 1.0
Name: pyacoustid
Version: 0.6
Version: 0.7
Summary: bindings for Chromaprint acoustic fingerprinting and the Acoustid API
Home-page: https://github.com/sampsyo/pyacoustid
Author: Adrian Sampson
......@@ -108,6 +108,11 @@ Description: Chromaprint and Acoustid for Python
Version History
---------------
0.7
Properly encode Unicode parameters (resolves a ``UnicodeEncodeError``
in fingerprint submission).
Parse all recordings for each Acoustid lookup result.
0.6
Add a new function, ``fingerprint_file``, that automatically selects a
backend for fingerprinting a single file.
......
......@@ -25,7 +25,7 @@ def _read(fn):
return data
setup(name='pyacoustid',
version='0.6',
version='0.7',
description=
'bindings for Chromaprint acoustic fingerprinting and the '
'Acoustid API',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment