|
|
@ -64,12 +64,12 @@ Languages: |
|
|
|
from os.path import dirname, realpath |
|
|
|
import sys |
|
|
|
import datetime |
|
|
|
import locale |
|
|
|
import logging |
|
|
|
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO) |
|
|
|
|
|
|
|
from docopt import docopt |
|
|
|
|
|
|
|
|
|
|
|
# Allows a relative import from the parent folder |
|
|
|
sys.path.insert(0, dirname(realpath(__file__)) + "/lib") |
|
|
|
|
|
|
@ -110,7 +110,6 @@ VALID_LANGUAGES = ('arabic', 'english', 'french', |
|
|
|
'japanese', 'korean', 'mandarin', |
|
|
|
'portuguese', 'punjabi', 'russian', 'spanish') |
|
|
|
|
|
|
|
|
|
|
|
def validateVideo(path): |
|
|
|
supported_types = ['video/mp4'] |
|
|
|
if magic.from_file(path, mime=True) in supported_types: |
|
|
@ -118,21 +117,18 @@ 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 |
|
|
|
|
|
|
|
|
|
|
|
def validatePlatform(platform): |
|
|
|
for plfrm in platform.split(','): |
|
|
|
if plfrm.lower().replace(" ", "") not in VALID_PLATFORM: |
|
|
@ -140,14 +136,12 @@ def validatePlatform(platform): |
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
def validateLanguage(language): |
|
|
|
if language.lower() in VALID_LANGUAGES: |
|
|
|
return True |
|
|
|
else: |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
def validatePublish(publish): |
|
|
|
# Check date format and if date is future |
|
|
|
try: |
|
|
@ -173,17 +167,17 @@ if __name__ == '__main__': |
|
|
|
schema = Schema({ |
|
|
|
'--file': And(str, validateVideo, error='file is not supported, please use mp4'), |
|
|
|
Optional('--name'): Or(None, And( |
|
|
|
str, |
|
|
|
basestring, |
|
|
|
lambda x: not x.isdigit(), |
|
|
|
error="The video name should be a string") |
|
|
|
), |
|
|
|
Optional('--description'): Or(None, And( |
|
|
|
str, |
|
|
|
basestring, |
|
|
|
lambda x: not x.isdigit(), |
|
|
|
error="The video name should be a string") |
|
|
|
error="The video description should be a string") |
|
|
|
), |
|
|
|
Optional('--tags'): Or(None, And( |
|
|
|
str, |
|
|
|
basestring, |
|
|
|
lambda x: not x.isdigit(), |
|
|
|
error="Tags should be a string") |
|
|
|
), |
|
|
@ -222,6 +216,7 @@ if __name__ == '__main__': |
|
|
|
'--version': bool |
|
|
|
}) |
|
|
|
|
|
|
|
utils.decodeArgumentStrings(options, locale.getpreferredencoding()) |
|
|
|
options = utils.parseNFO(options) |
|
|
|
|
|
|
|
if not options.get('--thumbnail'): |
|
|
|