|
@ -34,6 +34,10 @@ Options: |
|
|
DATE should be in the future |
|
|
DATE should be in the future |
|
|
--peertubeAt=DATE |
|
|
--peertubeAt=DATE |
|
|
--youtubeAt=DATE Override publishAt for the corresponding platform. Allow to create preview on specific platform |
|
|
--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 |
|
|
|
|
|
--auto-originalDate Automatically use the file modification time as original date |
|
|
--thumbnail=STRING Path to a file to use as a thumbnail for the video. |
|
|
--thumbnail=STRING Path to a file to use as a thumbnail for the video. |
|
|
Supported types are jpg and jpeg. |
|
|
Supported types are jpg and jpeg. |
|
|
By default, prismedia search for an image based on video name followed by .jpg or .jpeg |
|
|
By default, prismedia search for an image based on video name followed by .jpg or .jpeg |
|
@ -71,6 +75,7 @@ Strict options: |
|
|
--withTags Prevent the upload without tags |
|
|
--withTags Prevent the upload without tags |
|
|
--withPlaylist Prevent the upload if no playlist |
|
|
--withPlaylist Prevent the upload if no playlist |
|
|
--withPublishAt Prevent the upload if no schedule |
|
|
--withPublishAt Prevent the upload if no schedule |
|
|
|
|
|
--withOriginalDate Prevent the upload if no original date configured |
|
|
--withPlatform Prevent the upload if at least one platform is not specified |
|
|
--withPlatform Prevent the upload if at least one platform is not specified |
|
|
--withCategory Prevent the upload if no category |
|
|
--withCategory Prevent the upload if no category |
|
|
--withLanguage Prevent upload if no language |
|
|
--withLanguage Prevent upload if no language |
|
@ -190,11 +195,11 @@ def validateLanguage(language): |
|
|
return False |
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def validatePublish(publish): |
|
|
|
|
|
|
|
|
def validatePublishDate(publishDate): |
|
|
# Check date format and if date is future |
|
|
# Check date format and if date is future |
|
|
try: |
|
|
try: |
|
|
now = datetime.datetime.now() |
|
|
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: |
|
|
if now >= publishAt: |
|
|
return False |
|
|
return False |
|
|
except ValueError: |
|
|
except ValueError: |
|
@ -202,6 +207,18 @@ def validatePublish(publish): |
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def validateOriginalDate(originalDate): |
|
|
|
|
|
# Check date format and if date is past |
|
|
|
|
|
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): |
|
|
def validateThumbnail(thumbnail): |
|
|
supported_types = ['image/jpg', 'image/jpeg'] |
|
|
supported_types = ['image/jpg', 'image/jpeg'] |
|
|
if os.path.exists(thumbnail) and \ |
|
|
if os.path.exists(thumbnail) and \ |
|
@ -217,6 +234,7 @@ def validateLogLevel(loglevel): |
|
|
return False |
|
|
return False |
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _optionnalOrStrict(key, scope, error): |
|
|
def _optionnalOrStrict(key, scope, error): |
|
|
option = key.replace('-', '') |
|
|
option = key.replace('-', '') |
|
|
option = option[0].upper() + option[1:] |
|
|
option = option[0].upper() + option[1:] |
|
@ -280,6 +298,7 @@ def main(): |
|
|
Optional('--withTags', default=False): bool, |
|
|
Optional('--withTags', default=False): bool, |
|
|
Optional('--withPlaylist', default=False): bool, |
|
|
Optional('--withPlaylist', default=False): bool, |
|
|
Optional('--withPublishAt', default=False): bool, |
|
|
Optional('--withPublishAt', default=False): bool, |
|
|
|
|
|
Optional('--withOriginalDate', default=False): bool, |
|
|
Optional('--withPlatform', default=False): bool, |
|
|
Optional('--withPlatform', default=False): bool, |
|
|
Optional('--withCategory', default=False): bool, |
|
|
Optional('--withCategory', default=False): bool, |
|
|
Optional('--withLanguage', default=False): bool, |
|
|
Optional('--withLanguage', default=False): bool, |
|
@ -298,6 +317,7 @@ def main(): |
|
|
Hook('--language', handler=_optionnalOrStrict): object, |
|
|
Hook('--language', handler=_optionnalOrStrict): object, |
|
|
Hook('--platform', handler=_optionnalOrStrict): object, |
|
|
Hook('--platform', handler=_optionnalOrStrict): object, |
|
|
Hook('--publishAt', handler=_optionnalOrStrict): object, |
|
|
Hook('--publishAt', handler=_optionnalOrStrict): object, |
|
|
|
|
|
Hook('--originalDate', handler=_optionnalOrStrict): object, |
|
|
Hook('--thumbnail', handler=_optionnalOrStrict): object, |
|
|
Hook('--thumbnail', handler=_optionnalOrStrict): object, |
|
|
Hook('--channel', handler=_optionnalOrStrict): object, |
|
|
Hook('--channel', handler=_optionnalOrStrict): object, |
|
|
Hook('--playlist', handler=_optionnalOrStrict): object, |
|
|
Hook('--playlist', handler=_optionnalOrStrict): object, |
|
@ -336,19 +356,25 @@ def main(): |
|
|
Optional('--platform'): Or(None, And(str, validatePlatform, error="Sorry, upload platform not supported")), |
|
|
Optional('--platform'): Or(None, And(str, validatePlatform, error="Sorry, upload platform not supported")), |
|
|
Optional('--publishAt'): Or(None, And( |
|
|
Optional('--publishAt'): Or(None, And( |
|
|
str, |
|
|
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( |
|
|
Optional('--peertubeAt'): Or(None, And( |
|
|
str, |
|
|
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( |
|
|
Optional('--youtubeAt'): Or(None, And( |
|
|
str, |
|
|
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('--auto-originalDate'): bool, |
|
|
Optional('--cca'): bool, |
|
|
Optional('--cca'): bool, |
|
|
Optional('--disable-comments'): bool, |
|
|
Optional('--disable-comments'): bool, |
|
|
Optional('--nsfw'): bool, |
|
|
Optional('--nsfw'): bool, |
|
@ -377,6 +403,12 @@ def main(): |
|
|
|
|
|
|
|
|
options = utils.parseNFO(options) |
|
|
options = utils.parseNFO(options) |
|
|
|
|
|
|
|
|
|
|
|
# If after loading NFO we still has no original date and --auto-originalDate is enabled, |
|
|
|
|
|
# then we need to search from the file |
|
|
|
|
|
# We need to do that before the strict validation in case --withOriginalDate is enabled |
|
|
|
|
|
if not options.get('--originalDate') and options.get('--auto-originalDate'): |
|
|
|
|
|
options['--originalDate'] = utils.searchOriginalDate(options) |
|
|
|
|
|
|
|
|
# Once NFO are loaded, we need to revalidate strict options in case some were in NFO |
|
|
# Once NFO are loaded, we need to revalidate strict options in case some were in NFO |
|
|
try: |
|
|
try: |
|
|
options = earlyoptionSchema.validate(options) |
|
|
options = earlyoptionSchema.validate(options) |
|
|