beetbox / pyacoustid

Python bindings for Chromaprint acoustic fingerprinting and the Acoustid Web service
MIT License
325 stars 66 forks source link

error when submitting - missing parameter duration.0 #38

Closed Notmarrco closed 7 years ago

Notmarrco commented 7 years ago

Hi,

I'm trying to submit a fingerprint, but I got an Exception.

When I submit directly via the web API in my browser, the submit is successful.

Here is my code :

>>> (d, f) = acoustid.fingerprint_file('song.mp3')
>>> data = {'duration': d, 'fingerprint': f, 'mbid': 'f77afe3f-d335-409c-bc5f-a5271fee23c8'}
>>> client = 'xxxxxx'
>>> user = 'xxxxxx'
>>> acoustid.submit(client, user, data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/notmarrco/.local/lib/python3.5/site-packages/acoustid.py", line 379, in submit
    raise WebServiceError("error {0}: {1}".format(code, message))
acoustid.WebServiceError: error 2: missing required parameter "duration.0"

I provide "duration" so I don't understand the "missing required parameter" exception.

Thanks

Notmarrco commented 7 years ago

found it : I had to take the math.floor(d) for duration.

sampsyo commented 7 years ago

Glad you worked it out! Perhaps we should add a check that the duration is passed in as an int… a PR to that effect would be very welcome.