Skip to content

Commit 4713574

Browse files
authored
Merge pull request #108 from hannesbraun/aiff-support
Add AIFF support
2 parents 8575b9f + 67cd731 commit 4713574

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Audio
102102
- **flac** - ``audio/x-flac``
103103
- **wav** - ``audio/x-wav``
104104
- **amr** - ``audio/amr``
105+
- **aiff** - ``audio/x-aiff``
105106

106107
Archive
107108
^^^^^^^

filetype/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
audio.Flac(),
5454
audio.Wav(),
5555
audio.Amr(),
56+
audio.Aiff(),
5657
)
5758

5859
# Supported font types

filetype/types/audio.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,28 @@ def __init__(self):
185185
def match(self, buf):
186186
return (buf[:2] == bytearray([0xff, 0xf1]) or
187187
buf[:2] == bytearray([0xff, 0xf9]))
188+
189+
190+
class Aiff(Type):
191+
"""
192+
Implements the AIFF audio type matcher.
193+
"""
194+
MIME = 'audio/x-aiff'
195+
EXTENSION = 'aiff'
196+
197+
def __init__(self):
198+
super(Aiff, self).__init__(
199+
mime=Aiff.MIME,
200+
extension=Aiff.EXTENSION
201+
)
202+
203+
def match(self, buf):
204+
return (len(buf) > 11 and
205+
buf[0] == 0x46 and
206+
buf[1] == 0x4F and
207+
buf[2] == 0x52 and
208+
buf[3] == 0x4D and
209+
buf[8] == 0x41 and
210+
buf[9] == 0x49 and
211+
buf[10] == 0x46 and
212+
buf[11] == 0x46)

0 commit comments

Comments
 (0)