mirror of
https://git.lecygnenoir.info/LecygneNoir/prismedia.git
synced 2025-10-03 09:29:16 +02:00
correction to be more pep8 compliant (mostly typo)
This commit is contained in:
parent
7c12bcbc31
commit
5d68cc79f7
5 changed files with 79 additions and 56 deletions
|
@ -35,7 +35,7 @@ Options:
|
|||
--cca License should be CreativeCommon Attribution (affects Youtube upload only)
|
||||
-p, --privacy=STRING Choose between public, unlisted or private. [default: private]
|
||||
--disable-comments Disable comments (Peertube only) [default: comments are enabled]
|
||||
--nsfw Set the video as NSFW (Peertube only as YT API does not support) [default: video is not restricted]
|
||||
--nsfw Set the video as No Safe For Work (Peertube only as YT API does not support) [default: video is safe]
|
||||
-h --help Show this help.
|
||||
--version Show version.
|
||||
|
||||
|
@ -57,7 +57,7 @@ Categories:
|
|||
- [x] description
|
||||
- [x] tags
|
||||
- [x] categories
|
||||
- [x] license: cca or not, affect only Youtube as Peertube uses Attribution by design
|
||||
- [x] license: cca or not (Youtube only as Peertube uses Attribution by design)
|
||||
- [x] privacy (between public, unlisted or private)
|
||||
- [x] enabling/disabling comment (Peertube only as Youtube API does not support it)
|
||||
- [x] nsfw (Peertube only as Youtube API does not support it)
|
||||
|
|
|
@ -52,7 +52,6 @@ def upload_video(oauth, config, options):
|
|||
|
||||
path = options.get('--file')
|
||||
url = config.get('peertube', 'peertube_url')
|
||||
tags = None
|
||||
|
||||
# We need to transform fields into tuple to deal with tags as
|
||||
# MultipartEncoder does not support list refer
|
||||
|
@ -120,4 +119,4 @@ def run(options):
|
|||
if hasattr(e, 'message'):
|
||||
print("Error: " + e.message)
|
||||
else:
|
||||
print("Error: " + e)
|
||||
print("Error: " + str(e))
|
||||
|
|
|
@ -45,6 +45,7 @@ PEERTUBE_CATEGORY = {
|
|||
|
||||
######################
|
||||
|
||||
|
||||
def getCategory(category, type):
|
||||
if type == "youtube":
|
||||
return YOUTUBE_CATEGORY[category.lower()]
|
||||
|
|
|
@ -17,7 +17,7 @@ Options:
|
|||
--cca License should be CreativeCommon Attribution (affects Youtube upload only)
|
||||
-p, --privacy=STRING Choose between public, unlisted or private. [default: private]
|
||||
--disable-comments Disable comments (Peertube only as YT API does not support) [default: comments are enabled]
|
||||
--nsfw Set the video as NSFW (Peertube only as YT API does not support) [default: video is not restricted]
|
||||
--nsfw Set the video as No Safe For Work (Peertube only as YT API does not support) [default: video is safe]
|
||||
-h --help Show this help.
|
||||
--version Show version.
|
||||
|
||||
|
@ -36,7 +36,7 @@ import sys
|
|||
from docopt import docopt
|
||||
|
||||
|
||||
# Allows you to a relative import from the parent folder
|
||||
# Allows a relative import from the parent folder
|
||||
sys.path.insert(0, dirname(realpath(__file__)) + "/lib")
|
||||
|
||||
import yt_upload
|
||||
|
@ -45,13 +45,13 @@ import pt_upload
|
|||
try:
|
||||
from schema import Schema, And, Or, Optional, SchemaError
|
||||
except ImportError:
|
||||
e('This program requires that the `schema` data-validation library'
|
||||
exit('This program requires that the `schema` data-validation library'
|
||||
' is installed: \n'
|
||||
'see https://github.com/halst/schema\n')
|
||||
try:
|
||||
import magic
|
||||
except ImportError:
|
||||
e('This program requires that the `python-magic` library'
|
||||
exit('This program requires that the `python-magic` library'
|
||||
' is installed, NOT the Python bindings to libmagic API \n'
|
||||
'see https://github.com/ahupp/python-magic\n')
|
||||
|
||||
|
@ -73,29 +73,52 @@ def validateVideo(path):
|
|||
else:
|
||||
return False
|
||||
|
||||
|
||||
def validateCategory(category):
|
||||
if category.lower() in VALID_CATEGORIES:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def validatePrivacy(privacy):
|
||||
if privacy.lower() in VALID_PRIVACY_STATUSES:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
options = docopt(__doc__, version=VERSION)
|
||||
|
||||
schema = Schema({
|
||||
'--file': And(str, validateVideo, error='file is not supported, please use mp4'),
|
||||
Optional('--name'): 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('--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('--name'): 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('--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('--disable-comments'): bool,
|
||||
Optional('--nsfw'): bool,
|
||||
|
@ -106,7 +129,7 @@ if __name__ == '__main__':
|
|||
try:
|
||||
options = schema.validate(options)
|
||||
except SchemaError as e:
|
||||
e(e)
|
||||
exit(e)
|
||||
|
||||
# yt_upload.run(options)
|
||||
yt_upload.run(options)
|
||||
pt_upload.run(options)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue