|
|
@ -34,6 +34,11 @@ Options: |
|
|
|
DATE should be in the future |
|
|
|
--peertubeAt=DATE |
|
|
|
--youtubeAt=DATE Override publishAt for the corresponding platform. Allow to create preview on specific platform |
|
|
|
--originalDate=DATE Configure the video as initially recorded at DATE |
|
|
|
DATE should be on the form YYYY-MM-DDThh:mm:ss eg: 2018-03-12T19:00:00 |
|
|
|
DATE should be in the past |
|
|
|
Default use the last modification date of the file. |
|
|
|
--no-originalDate Do not set the initial record field when uploading |
|
|
|
--thumbnail=STRING Path to a file to use as a thumbnail for the video. |
|
|
|
Supported types are jpg and jpeg. |
|
|
|
By default, prismedia search for an image based on video name followed by .jpg or .jpeg |
|
|
@ -190,11 +195,11 @@ def validateLanguage(language): |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
def validatePublish(publish): |
|
|
|
def validatePublishDate(publishDate): |
|
|
|
# Check date format and if date is future |
|
|
|
try: |
|
|
|
now = datetime.datetime.now() |
|
|
|
publishAt = datetime.datetime.strptime(publish, '%Y-%m-%dT%H:%M:%S') |
|
|
|
publishAt = datetime.datetime.strptime(publishDate, '%Y-%m-%dT%H:%M:%S') |
|
|
|
if now >= publishAt: |
|
|
|
return False |
|
|
|
except ValueError: |
|
|
@ -202,6 +207,18 @@ def validatePublish(publish): |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
def validateOriginalDate(originalDate): |
|
|
|
# Check date format and if date is future |
|
|
|
try: |
|
|
|
now = datetime.datetime.now() |
|
|
|
originalDate = datetime.datetime.strptime(originalDate, '%Y-%m-%dT%H:%M:%S') |
|
|
|
if now <= originalDate: |
|
|
|
return False |
|
|
|
except ValueError: |
|
|
|
return False |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
def validateThumbnail(thumbnail): |
|
|
|
supported_types = ['image/jpg', 'image/jpeg'] |
|
|
|
if os.path.exists(thumbnail) and \ |
|
|
@ -336,19 +353,25 @@ def main(): |
|
|
|
Optional('--platform'): Or(None, And(str, validatePlatform, error="Sorry, upload platform not supported")), |
|
|
|
Optional('--publishAt'): Or(None, And( |
|
|
|
str, |
|
|
|
validatePublish, |
|
|
|
error="DATE should be the form YYYY-MM-DDThh:mm:ss and has to be in the future") |
|
|
|
validatePublishDate, |
|
|
|
error="Publish Date should be the form YYYY-MM-DDThh:mm:ss and has to be in the future") |
|
|
|
), |
|
|
|
Optional('--peertubeAt'): Or(None, And( |
|
|
|
str, |
|
|
|
validatePublish, |
|
|
|
error="DATE should be the form YYYY-MM-DDThh:mm:ss and has to be in the future") |
|
|
|
validatePublishDate, |
|
|
|
error="Publish Date should be the form YYYY-MM-DDThh:mm:ss and has to be in the future") |
|
|
|
), |
|
|
|
Optional('--youtubeAt'): Or(None, And( |
|
|
|
str, |
|
|
|
validatePublish, |
|
|
|
error="DATE should be the form YYYY-MM-DDThh:mm:ss and has to be in the future") |
|
|
|
validatePublishDate, |
|
|
|
error="Publish Date should be the form YYYY-MM-DDThh:mm:ss and has to be in the future") |
|
|
|
), |
|
|
|
Optional('--originalDate'): Or(None, And( |
|
|
|
str, |
|
|
|
validateOriginalDate, |
|
|
|
error="Original date should be the form YYYY-MM-DDThh:mm:ss and has to be in the past") |
|
|
|
), |
|
|
|
Optional('--no-originalDate'): bool, |
|
|
|
Optional('--cca'): bool, |
|
|
|
Optional('--disable-comments'): bool, |
|
|
|
Optional('--nsfw'): bool, |
|
|
@ -387,6 +410,11 @@ def main(): |
|
|
|
if not options.get('--thumbnail'): |
|
|
|
options = utils.searchThumbnail(options) |
|
|
|
|
|
|
|
# If after loading NFO we still has no original date and --no-originalDate is not enabled, |
|
|
|
# then we need to search from the file |
|
|
|
if not options.get('--originalDate') and not options.get('--no-originalDate'): |
|
|
|
options['--originalDate'] = utils.searchOriginalDate(options) |
|
|
|
|
|
|
|
try: |
|
|
|
options = schema.validate(options) |
|
|
|
except SchemaError as e: |
|
|
|