mirror of
https://git.lecygnenoir.info/LecygneNoir/prismedia.git
synced 2025-10-03 17:39:16 +02:00
add possibility to choose privacy
This commit is contained in:
parent
c8efa820ff
commit
2abcf711b8
3 changed files with 30 additions and 10 deletions
11
README.md
11
README.md
|
@ -28,11 +28,12 @@ Usage:
|
||||||
prismedia_upload.py --version
|
prismedia_upload.py --version
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--name=NAME Name of the video to upload. default to video file name
|
--name=NAME Name of the video to upload. [default: video filename]
|
||||||
-d, --description=STRING Description of the video.
|
-d, --description=STRING Description of the video. [default: default description]
|
||||||
-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: Films]
|
||||||
--cca License should be CreativeCommon Attribution (affects Youtube upload only)
|
--cca License should be CreativeCommon Attribution (affects Youtube upload only)
|
||||||
|
-p, --privacy=STRING Choose between public, unlisted or private. [default: private]
|
||||||
-h --help Show this help.
|
-h --help Show this help.
|
||||||
--version Show version.
|
--version Show version.
|
||||||
|
|
||||||
|
@ -44,7 +45,6 @@ Categories:
|
||||||
comedy, entertainment, news,
|
comedy, entertainment, news,
|
||||||
how to, education, activism, science & technology,
|
how to, education, activism, science & technology,
|
||||||
science, technology, animals
|
science, technology, animals
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
@ -56,6 +56,9 @@ Categories:
|
||||||
- [x] tags
|
- [x] tags
|
||||||
- [x] categories
|
- [x] categories
|
||||||
- [x] license: cca or not, affect only Youtube as Peertube uses Attribution by design
|
- [x] license: cca or not, affect only Youtube as Peertube uses Attribution by design
|
||||||
|
- [x] privacy (between public, unlisted or private)
|
||||||
|
- [ ] enabling/disabling comment
|
||||||
|
- [ ] nsfw
|
||||||
- [ ] 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
|
||||||
|
|
|
@ -14,6 +14,11 @@ from requests_toolbelt.multipart.encoder import MultipartEncoder
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
PEERTUBE_SECRETS_FILE = 'peertube_secret'
|
PEERTUBE_SECRETS_FILE = 'peertube_secret'
|
||||||
|
PEERTUBE_PRIVACY = {
|
||||||
|
"public": 1,
|
||||||
|
"unlisted": 2,
|
||||||
|
"private:": 3
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_authenticated_service(config):
|
def get_authenticated_service(config):
|
||||||
|
@ -59,8 +64,7 @@ def upload_video(oauth, config, options):
|
||||||
("licence", "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)),
|
("nsfw", "0"),
|
||||||
("nsfw", str(options.get('--nsfw') or 0)),
|
|
||||||
("commentsEnabled", "1"),
|
("commentsEnabled", "1"),
|
||||||
("channelId", get_userinfo()),
|
("channelId", get_userinfo()),
|
||||||
("videofile", get_videofile(path))
|
("videofile", get_videofile(path))
|
||||||
|
@ -77,6 +81,11 @@ def upload_video(oauth, config, options):
|
||||||
#if no category, set default to 2 (Films)
|
#if no category, set default to 2 (Films)
|
||||||
fields.append(("category", "2"))
|
fields.append(("category", "2"))
|
||||||
|
|
||||||
|
if options.get('--privacy'):
|
||||||
|
fields.append(("privacy", str(PEERTUBE_PRIVACY[options.get('--privacy').lower()])))
|
||||||
|
else:
|
||||||
|
fields.append(("privacy", "3"))
|
||||||
|
|
||||||
multipart_data = MultipartEncoder(fields)
|
multipart_data = MultipartEncoder(fields)
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
|
|
|
@ -10,11 +10,12 @@ Usage:
|
||||||
prismedia_upload.py --version
|
prismedia_upload.py --version
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--name=NAME Name of the video to upload. default to video file name
|
--name=NAME Name of the video to upload. [default: video filename]
|
||||||
-d, --description=STRING Description of the video.
|
-d, --description=STRING Description of the video. [default: default description]
|
||||||
-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: Films]
|
||||||
--cca License should be CreativeCommon Attribution (affects Youtube upload only)
|
--cca License should be CreativeCommon Attribution (affects Youtube upload only)
|
||||||
|
-p, --privacy=STRING Choose between public, unlisted or private. [default: private]
|
||||||
-h --help Show this help.
|
-h --help Show this help.
|
||||||
--version Show version.
|
--version Show version.
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ except ImportError:
|
||||||
try:
|
try:
|
||||||
import magic
|
import magic
|
||||||
except ImportError:
|
except ImportError:
|
||||||
exit('This program requires that the `magic` library'
|
exit('This program requires that the `python-magic` library'
|
||||||
' is installed, NOT the Python bindings to libmagic API \n'
|
' is installed, NOT the Python bindings to libmagic API \n'
|
||||||
'see https://github.com/ahupp/python-magic\n')
|
'see https://github.com/ahupp/python-magic\n')
|
||||||
|
|
||||||
|
@ -76,6 +77,12 @@ def validateCategory(category):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def validatePrivacy(privacy):
|
||||||
|
if privacy.lower() in VALID_PRIVACY_STATUSES:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
options = docopt(__doc__, version=VERSION)
|
options = docopt(__doc__, version=VERSION)
|
||||||
|
@ -86,6 +93,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('--privacy'): Or(None, And(str, validatePrivacy, error="Please use recognized privacy between public, unlisted or private")),
|
||||||
Optional('--cca'): bool,
|
Optional('--cca'): bool,
|
||||||
'--help': bool,
|
'--help': bool,
|
||||||
'--version': bool
|
'--version': bool
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue