From c8efa820ff74133c320de7b9d1fa5e6c15d69b94 Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Fri, 9 Mar 2018 16:15:53 +0100 Subject: [PATCH] add possibility to choose license cca for Youtube --- README.md | 3 ++- lib/pt_upload.py | 2 +- lib/utils.py | 3 +++ lib/yt_upload.py | 9 ++++++++- prismedia_upload.py | 4 +++- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3b864aa..ed83772 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ Options: -d, --description=STRING Description of the video. -t, --tags=STRING Tags for the video. comma separated -c, --category=STRING Category for the videos, see below. Default to films + --cca License should be CreativeCommon Attribution (affects Youtube upload only) -h --help Show this help. --version Show version. @@ -54,7 +55,7 @@ Categories: - [x] description - [x] tags - [x] categories - - [ ] licence + - [x] license: cca or not, affect only Youtube as Peertube uses Attribution by design - [ ] thumbnail/preview - [ ] Use a config file (NFO) file to retrieve videos arguments - [ ] Record and forget: put the video in a directory, and the script uploads it for you diff --git a/lib/pt_upload.py b/lib/pt_upload.py index 48fe896..220b7ad 100644 --- a/lib/pt_upload.py +++ b/lib/pt_upload.py @@ -56,7 +56,7 @@ def upload_video(oauth, config, options): fields = [ ("name", options.get('--name') or splitext(basename(path))[0]), # look at the list numbers at /videos/licences - ("licence", str(options.get('--licence') or 1)), + ("licence", "1"), ("description", options.get('--description') or "default description"), # look at the list numbers at /videos/privacies ("privacy", str(options.get('--privacy') or 3)), diff --git a/lib/utils.py b/lib/utils.py index f2e2041..56548c5 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -2,6 +2,7 @@ # coding: utf-8 +### FOR CATEGORIE ### YOUTUBE_CATEGORY = { "music":10, "films":1, @@ -42,6 +43,8 @@ PEERTUBE_CATEGORY = { "animals":16 } +###################### + def getCategory(category, type): if type == "youtube": return YOUTUBE_CATEGORY[category.lower()] diff --git a/lib/yt_upload.py b/lib/yt_upload.py index 31ce3d2..62610b0 100644 --- a/lib/yt_upload.py +++ b/lib/yt_upload.py @@ -81,6 +81,10 @@ def initialize_upload(youtube, options): if options.get('--category'): category = utils.getCategory(options.get('--category'), 'youtube') + license = None + if options.get('--cca'): + license = "creativeCommon" + body = { "snippet": { "title": options.get('--name') or splitext(basename(path))[0], @@ -89,7 +93,10 @@ def initialize_upload(youtube, options): #if no category, set default to 1 (Films) "categoryId": str(category or 1), }, - "status": {"privacyStatus": str(options.get('--privacy') or "private")} + "status": { + "privacyStatus": str(options.get('--privacy') or "private"), + "license": str(license or "youtube") + } } # Call the API's videos.insert method to create and upload the video. diff --git a/prismedia_upload.py b/prismedia_upload.py index 0fdedda..388795f 100755 --- a/prismedia_upload.py +++ b/prismedia_upload.py @@ -13,7 +13,8 @@ Options: --name=NAME Name of the video to upload. default to video file name -d, --description=STRING Description of the video. -t, --tags=STRING Tags for the video. comma separated - -c, --category=STRING Category for the videos, see below. Default to films + -c, --category=STRING Category for the videos, see below. Default to films + --cca License should be CreativeCommon Attribution (affects Youtube upload only) -h --help Show this help. --version Show version. @@ -85,6 +86,7 @@ if __name__ == '__main__': Optional('--description'): Or(None, And(str, lambda x: not x.isdigit(), error="The video name should be a string")), Optional('--tags'): Or(None, And(str, lambda x: not x.isdigit(), error="Tags should be a string")), Optional('--category'): Or(None, And(str, validateCategory, error="Category not recognized, please see --help")), + Optional('--cca'): bool, '--help': bool, '--version': bool })