zooniverse/panoptes-python-client

Wrong MIME type for mp3 subjects

Closed this issue · 4 comments

Related to zooniverse/Panotpes#2458, @trouille reports

When I try with the Panoptes Python Client and the script at this link, I get the error:
panoptes_client.panoptes.PanoptesAPIException: Validation failed: Locations is invalid

Rails does not recognize audio/mp3 as a valid MIME type. For mp3s, the MIME type needs to be audio/mpeg. magic is likely detecting the wrong MIME type for these files.

magic appears to be detecting mp3s as audio/x-wav

I'm not able to reproduce this here.

>>> f = open('/Users/adam/Desktop/file.mp3', 'rb')
>>> magic.from_buffer(f.read(), mime=True)
'audio/mpeg'
>>> f.close()
>>> from panoptes_client import Panoptes, Project, Subject
>>> Panoptes.connect([...])
<panoptes_client.panoptes.Panoptes object at 0x7f4187443208>
>>> p = Project(7)
>>> s = Subject()
>>> s.links.project=p
>>> s.add_location('/Users/adam/Desktop/file.mp3')
>>> s.save()
>>>

From memory, the issue was the specific files that were being uploaded. The extension was .mp3, but they were actually WAV files.

Ah ok, in that case I'll close this.