mirror of
https://git.lecygnenoir.info/LecygneNoir/prismedia.git
synced 2025-10-03 17:39:16 +02:00
add possibility to choose license cca for Youtube
This commit is contained in:
parent
ac91e9b918
commit
c8efa820ff
5 changed files with 17 additions and 4 deletions
|
@ -32,6 +32,7 @@ Options:
|
||||||
-d, --description=STRING Description of the video.
|
-d, --description=STRING Description of the video.
|
||||||
-t, --tags=STRING Tags for the video. comma separated
|
-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.
|
-h --help Show this help.
|
||||||
--version Show version.
|
--version Show version.
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ Categories:
|
||||||
- [x] description
|
- [x] description
|
||||||
- [x] tags
|
- [x] tags
|
||||||
- [x] categories
|
- [x] categories
|
||||||
- [ ] licence
|
- [x] license: cca or not, affect only Youtube as Peertube uses Attribution by design
|
||||||
- [ ] thumbnail/preview
|
- [ ] thumbnail/preview
|
||||||
- [ ] Use a config file (NFO) file to retrieve videos arguments
|
- [ ] 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
|
- [ ] Record and forget: put the video in a directory, and the script uploads it for you
|
||||||
|
|
|
@ -56,7 +56,7 @@ def upload_video(oauth, config, options):
|
||||||
fields = [
|
fields = [
|
||||||
("name", options.get('--name') or splitext(basename(path))[0]),
|
("name", options.get('--name') or splitext(basename(path))[0]),
|
||||||
# look at the list numbers at /videos/licences
|
# look at the list numbers at /videos/licences
|
||||||
("licence", str(options.get('--licence') or 1)),
|
("licence", "1"),
|
||||||
("description", options.get('--description') or "default description"),
|
("description", options.get('--description') or "default description"),
|
||||||
# look at the list numbers at /videos/privacies
|
# look at the list numbers at /videos/privacies
|
||||||
("privacy", str(options.get('--privacy') or 3)),
|
("privacy", str(options.get('--privacy') or 3)),
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
|
|
||||||
|
### FOR CATEGORIE ###
|
||||||
YOUTUBE_CATEGORY = {
|
YOUTUBE_CATEGORY = {
|
||||||
"music":10,
|
"music":10,
|
||||||
"films":1,
|
"films":1,
|
||||||
|
@ -42,6 +43,8 @@ PEERTUBE_CATEGORY = {
|
||||||
"animals":16
|
"animals":16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
######################
|
||||||
|
|
||||||
def getCategory(category, type):
|
def getCategory(category, type):
|
||||||
if type == "youtube":
|
if type == "youtube":
|
||||||
return YOUTUBE_CATEGORY[category.lower()]
|
return YOUTUBE_CATEGORY[category.lower()]
|
||||||
|
|
|
@ -81,6 +81,10 @@ def initialize_upload(youtube, options):
|
||||||
if options.get('--category'):
|
if options.get('--category'):
|
||||||
category = utils.getCategory(options.get('--category'), 'youtube')
|
category = utils.getCategory(options.get('--category'), 'youtube')
|
||||||
|
|
||||||
|
license = None
|
||||||
|
if options.get('--cca'):
|
||||||
|
license = "creativeCommon"
|
||||||
|
|
||||||
body = {
|
body = {
|
||||||
"snippet": {
|
"snippet": {
|
||||||
"title": options.get('--name') or splitext(basename(path))[0],
|
"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)
|
#if no category, set default to 1 (Films)
|
||||||
"categoryId": str(category or 1),
|
"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.
|
# Call the API's videos.insert method to create and upload the video.
|
||||||
|
|
|
@ -13,7 +13,8 @@ Options:
|
||||||
--name=NAME Name of the video to upload. default to video file name
|
--name=NAME Name of the video to upload. default to video file name
|
||||||
-d, --description=STRING Description of the video.
|
-d, --description=STRING Description of the video.
|
||||||
-t, --tags=STRING Tags for the video. comma separated
|
-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.
|
-h --help Show this help.
|
||||||
--version Show version.
|
--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('--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('--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('--category'): Or(None, And(str, validateCategory, error="Category not recognized, please see --help")),
|
||||||
|
Optional('--cca'): bool,
|
||||||
'--help': bool,
|
'--help': bool,
|
||||||
'--version': bool
|
'--version': bool
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue