From 5896522df5d56964edae0b4e4f57f292fed9f264 Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Sat, 28 Jul 2018 12:51:44 +0200 Subject: [PATCH] Update help and base script to manage thumbnail --- nfo_example.txt | 1 + prismedia_upload.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/nfo_example.txt b/nfo_example.txt index 065601d..dc538df 100644 --- a/nfo_example.txt +++ b/nfo_example.txt @@ -14,6 +14,7 @@ category = Films cca = True privacy = private disable-comments = True +thumbnail = /path/to/your/thumbnail.jpg # Set the absolute path to your thumbnail nsfw = True platform = youtube, peertube language = French diff --git a/prismedia_upload.py b/prismedia_upload.py index 7261cbf..508e5ef 100755 --- a/prismedia_upload.py +++ b/prismedia_upload.py @@ -34,6 +34,9 @@ Options: DATE should be on the form YYYY-MM-DDThh:mm:ss eg: 2018-03-12T19:00:00 DATE should be in the future For Peertube, requires the "atd" and "curl utilities installed on the system + --thumbnail=STRING Path to a file to use as a thumbnail for the video. + Supported types are jpg and jpeg. + By default, prismedia search for an image based on video name followed by .jpg or .jpeg -h --help Show this help. --version Show version. @@ -151,6 +154,12 @@ def validatePublish(publish): return False return True +def validateThumbnail(thumbnail): + supported_types = ['image/jpg', 'image/jpeg'] + if magic.from_file(thumbnail, mime=True) in supported_types: + return thumbnail + else: + return False if __name__ == '__main__': @@ -199,12 +208,18 @@ if __name__ == '__main__': Optional('--cca'): bool, Optional('--disable-comments'): bool, Optional('--nsfw'): bool, + Optional('--thumbnail'): Or(None, And( + str, validateThumbnail, error='thumbnail is not supported, please use jpg/jpeg'), + ), '--help': bool, '--version': bool }) options = utils.parseNFO(options) + if not options.get('--thumbnail'): + options = utils.searchThumbnail(options) + try: options = schema.validate(options) except SchemaError as e: