Browse Source

add possibility to choose license cca for Youtube

develop
LecygneNoir 6 years ago
parent
commit
c8efa820ff
5 changed files with 17 additions and 4 deletions
  1. +2
    -1
      README.md
  2. +1
    -1
      lib/pt_upload.py
  3. +3
    -0
      lib/utils.py
  4. +8
    -1
      lib/yt_upload.py
  5. +3
    -1
      prismedia_upload.py

+ 2
- 1
README.md View File

@ -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

+ 1
- 1
lib/pt_upload.py View File

@ -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)),

+ 3
- 0
lib/utils.py View File

@ -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()]

+ 8
- 1
lib/yt_upload.py View File

@ -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.

+ 3
- 1
prismedia_upload.py View File

@ -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
})

Loading…
Cancel
Save