From 840f4d2010521a3752f0c477a2b984476f704c12 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Thu, 11 Jul 2024 20:10:15 +0200 Subject: [PATCH] Update to make upload of m4a and m4b files work (#3102) --- cps/__init__.py | 4 ++-- cps/file_helper.py | 7 +++---- optional-requirements.txt | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cps/__init__.py b/cps/__init__.py index fead0d2f..642f6a6e 100755 --- a/cps/__init__.py +++ b/cps/__init__.py @@ -70,8 +70,8 @@ mimetypes.add_type('image/vnd.djv', '.djv') 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') diff --git a/cps/file_helper.py b/cps/file_helper.py index 095b5ee0..d6182311 100644 --- a/cps/file_helper.py +++ b/cps/file_helper.py @@ -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) @@ -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 diff --git a/optional-requirements.txt b/optional-requirements.txt index 77f41e1e..3f6b6e37 100644 --- a/optional-requirements.txt +++ b/optional-requirements.txt @@ -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'