From 802d70b8d577d23c8fd8838a502e9f283ff97a8c Mon Sep 17 00:00:00 2001 From: Zykino Date: Sun, 19 Apr 2020 15:26:16 +0200 Subject: [PATCH] Empower user to force using the file they selected At least on Windows I got multiples times a detected type of `inode/blockdevice`. In reality files where good mp4 files accepted by peertube and youtube. --- prismedia/upload.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/prismedia/upload.py b/prismedia/upload.py index 0a1ba9c..75688af 100755 --- a/prismedia/upload.py +++ b/prismedia/upload.py @@ -115,10 +115,16 @@ VALID_LANGUAGES = ('arabic', 'english', 'french', def validateVideo(path): supported_types = ['video/mp4'] - if magic.from_file(path, mime=True) in supported_types: - return path - else: - return False + detected_type = magic.from_file(path, mime=True) + if detected_type not in supported_types: + print("File", path, "detected type is", detected_type, "which is not one of", supported_types) + + force_file = ['y', 'yes'] + is_forcing = input("Are you sure you selected the correct file? (y/N)") + if is_forcing.lower() not in force_file: + return False + + return path def validateCategory(category):