Skip to content

Commit

Permalink
Update to make upload of m4a and m4b files work (#3102)
Browse files Browse the repository at this point in the history
  • Loading branch information
OzzieIsaacs committed Jul 11, 2024
1 parent 3cda0a0 commit 840f4d2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
mimetypes.add_type('image/vnd.djv', '.djvu')
mimetypes.add_type('application/mpeg', '.mpeg')
mimetypes.add_type('audio/mpeg', '.mp3')
mimetypes.add_type('application/mp4', '.m4a')
mimetypes.add_type('application/mp4', '.m4b')
mimetypes.add_type('audio/x-m4a', '.m4a')
mimetypes.add_type('audio/x-m4a', '.m4b')
mimetypes.add_type('audio/ogg', '.ogg')
mimetypes.add_type('application/ogg', '.oga')
mimetypes.add_type('text/css', '.css')
Expand Down
7 changes: 3 additions & 4 deletions cps/file_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def del_temp_dir():

def validate_mime_type(file_buffer, allowed_extensions):
mime = magic.Magic(mime=True)
allowed_mimetypes =list()
allowed_mimetypes = list()
for x in allowed_extensions:
try:
allowed_mimetypes.append(mimetypes.types_map["." + x])
except KeyError as e:
except KeyError:
log.error("Unkown mimetype for Extension: {}".format(x))
tmp_mime_type = mime.from_buffer(file_buffer.read())
file_buffer.seek(0)
Expand All @@ -66,6 +66,5 @@ def validate_mime_type(file_buffer, allowed_extensions):
return True
except:
file_buffer.seek(0)
pass

log.error("Mimetype '{}' not found in allowed types".format(tmp_mime_type))
return False
2 changes: 1 addition & 1 deletion optional-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ natsort>=2.2.0,<8.5.0
comicapi>=2.2.0,<3.3.0

# Kobo integration
jsonschema>=3.2.0,<4.23.0
jsonschema>=3.2.0,<4.24.0

# Hide console Window on Windows
pywin32>=220,<310 ; sys_platform == 'win32'

0 comments on commit 840f4d2

Please sign in to comment.