beetbox / pyacoustid

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

Fix #38 : cast duration to an integer #41

Closed Notmarrco closed 6 years ago

Notmarrco commented 6 years ago

Fix #38

we could also use math.floor or round depending on what's the best for acoustid ... Tell me if one of them is better.

The float call is made to handle the case when duration is a string or else.

sampsyo commented 6 years ago

Thanks!!

I’m not sure, though, that we want to be in the business of supporting strings. It seems a little unpythonic to allow any type that can be converted to a float with int(float(...)). Can we just check whether isinstance(..., (int, float)) or similar and just raise a TypeError otherwise?

Notmarrco commented 6 years ago

Yes you're right.

Or I could just do like in line 223 https://github.com/beetbox/pyacoustid/blob/master/acoustid.py#L223 and cast to int().

Not as polished as your suggestion, but at least it's consistent with the codebase.

sampsyo commented 6 years ago

Sure; just having an int(...) wrapping that will work great.

sampsyo commented 6 years ago

Awesome; thank you! :sparkles: