Skip to content

Commit

Permalink
Merge pull request #94 from dosas/feature/issue-50
Browse files Browse the repository at this point in the history
Add brotli support
  • Loading branch information
h2non authored Dec 29, 2020
2 parents cff02bf + 511b1b6 commit b61655e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Audio
Archive
^^^^^^^

- **br** - ``application/x-brotli``
- **rpm** - ``application/x-rpm``
- **dcm** - ``application/dicom``
- **epub** - ``application/epub+zip``
Expand Down
1 change: 1 addition & 0 deletions filetype/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

# Supported archive container types
ARCHIVE = (
archive.Br(),
archive.Rpm(),
archive.Dcm(),
archive.Epub(),
Expand Down
17 changes: 17 additions & 0 deletions filetype/types/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,22 @@ def match(self, buf):
buf[3] == 0x50)


class Br(Type):
"""Implements the Br image type matcher."""

MIME = 'application/x-brotli'
EXTENSION = 'br'

def __init__(self):
super(Br, self).__init__(
mime=Br.MIME,
extension=Br.EXTENSION
)

def match(self, buf):
return buf[:4] == bytearray([0xce, 0xb2, 0xcf, 0x81])


class Dcm(Type):
"""Implements the Dcm image type matcher."""

Expand Down Expand Up @@ -545,3 +561,4 @@ def __init__(self):

def match(self, buf):
return buf[:4] == bytearray([0xed, 0xab, 0xee, 0xdb])

0 comments on commit b61655e

Please sign in to comment.