https://github.com/corona10/mimesniff
Pure python mimesniff implementation of https://mimesniff.spec.whatwg.org
https://github.com/corona10/mimesniff
magic mime mimesniff mimetype python python3
Last synced: about 2 months ago
JSON representation
Pure python mimesniff implementation of https://mimesniff.spec.whatwg.org
- Host: GitHub
- URL: https://github.com/corona10/mimesniff
- Owner: corona10
- License: apache-2.0
- Created: 2019-06-15T15:17:23.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-24T16:21:56.000Z (almost 5 years ago)
- Last Synced: 2025-07-17T15:09:14.763Z (3 months ago)
- Topics: magic, mime, mimesniff, mimetype, python, python3
- Language: Python
- Size: 2.18 MB
- Stars: 14
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
mimesniff
=========
.. image:: https://travis-ci.org/corona10/mimesniff.svg?branch=master
:target: https://travis-ci.org/corona10/mimesniff.. image:: https://img.shields.io/pypi/v/mimesniff.svg?style=flat
:target: https://pypi.python.org/pypi/mimesniffPure python mimesniff implementation of
`https://mimesniff.spec.whatwg.org`_API interface is similar with `API of python standard library`_
Install
-------.. code:: bash
pip install mimesniff
Usage
-----.. code:: python
import mimesniff
res = mimesniff.what('sample.mp3')
print(res)
# audio/mpeg
with open('sample.mp3', 'rb') as fin:
res = mimesniff.what(fin)
print(res)
# audio/mpegwith open('sample.mp3', 'rb') as fin:
header = fin.read(512)
res = mimesniff.what(header)
print(res)
# audio/mpeg.. _`https://mimesniff.spec.whatwg.org`: https://mimesniff.spec.whatwg.org
.. _API of python standard library: https://docs.python.org/3/library/sndhdr.html