From 2f7629ef1e7db2d04a7172d00eb6a74a44d2bdf5 Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Sat, 10 Apr 2021 11:34:36 +0200 Subject: [PATCH] Remove format checks for videos and thumbnail as Youtube and Peertube have no limitation anymore --- prismedia/upload.py | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/prismedia/upload.py b/prismedia/upload.py index a020eea..c7dc4c3 100755 --- a/prismedia/upload.py +++ b/prismedia/upload.py @@ -125,14 +125,6 @@ except ImportError: ' is installed: \n' 'see https://github.com/halst/schema\n') exit(1) -try: - # noinspection PyUnresolvedReferences - import magic -except ImportError: - logger.critical('This program requires that the `python-magic` library' - ' is installed, NOT the Python bindings to libmagic API \n' - 'see https://github.com/ahupp/python-magic\n') - exit(1) VERSION = "prismedia v0.11.0" @@ -152,20 +144,6 @@ VALID_LANGUAGES = ('arabic', 'english', 'french', VALID_PROGRESS = ('percentage', 'bigfile', 'accurate') -def validateVideo(path): - supported_types = ['video/mp4'] - 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): if category.lower() in VALID_CATEGORIES: return True @@ -219,15 +197,6 @@ def validateOriginalDate(originalDate): return True -def validateThumbnail(thumbnail): - supported_types = ['image/jpg', 'image/jpeg'] - if os.path.exists(thumbnail) and \ - magic.from_file(thumbnail, mime=True) in supported_types: - return thumbnail - else: - return False - - def validateLogLevel(loglevel): numeric_level = getattr(logging, loglevel, None) if not isinstance(numeric_level, int): @@ -316,7 +285,7 @@ def main(): }) schema = Schema({ - '--file': And(str, os.path.exists, validateVideo, error='file is not supported, please use mp4'), + '--file': And(str, os.path.exists, error='file does not exists, please check path'), # Strict option checks - at the moment Schema needs to check Hook and Optional separately # Hook('--name', handler=_optionnalOrStrict): object, Hook('--description', handler=_optionnalOrStrict): object, @@ -387,7 +356,7 @@ def main(): Optional('--disable-comments'): bool, Optional('--nsfw'): bool, Optional('--thumbnail'): Or(None, And( - str, validateThumbnail, error='thumbnail is not supported, please use jpg/jpeg'), + str, os.path.exists, error='Thumbnail does not exists, please check the path.'), ), Optional('--channel'): Or(None, str), Optional('--channelCreate'): bool,