Would it make sense to use the free DROID signature files to detect the mime type? They are completely free and actually maintained: https://www.nationalarchives.gov.uk/aboutapps/pronom/droid-signature-files.htm