add category options with conversion between peertube/youtube

This commit is contained in:
LecygneNoir 2018-03-09 15:36:25 +01:00
parent c79309e091
commit 4c58f14cdf
4 changed files with 90 additions and 7 deletions

View file

@ -13,14 +13,25 @@ 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
-h --help Show this help.
--version Show version.
Categories:
Category is the type of video you upload. Default is films.
Here are available categories from Peertube and Youtube:
music, films, vehicles,
sports, travels, gaming, people,
comedy, entertainment, news,
how to, education, activism, science & technology,
science, technology, animals
"""
from os.path import dirname, realpath
import sys
from docopt import docopt
# Allows you to a relative import from the parent folder
sys.path.insert(0, dirname(realpath(__file__)) + "/lib")
@ -40,8 +51,15 @@ except ImportError:
' is installed, NOT the Python bindings to libmagic API \n'
'see https://github.com/ahupp/python-magic\n')
VERSION = "ptyt 0.1-alpha"
VERSION = "ptyt 0.2-alpha"
VALID_PRIVACY_STATUSES = ('public', 'private', 'unlisted')
VALID_CATEGORIES = (
"music", "films", "vehicles",
"sports", "travels", "gaming", "people",
"comedy", "entertainment", "news",
"how to", "education", "activism", "science & technology",
"science", "technology", "animals"
)
def validateVideo(path):
@ -51,6 +69,11 @@ def validateVideo(path):
else:
return False
def validateCategory(category):
if category.lower() in VALID_CATEGORIES:
return True
else:
return False
if __name__ == '__main__':
@ -61,6 +84,7 @@ if __name__ == '__main__':
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")),
'--help': bool,
'--version': bool
})