mirror of
https://git.lecygnenoir.info/LecygneNoir/prismedia.git
synced 2025-10-03 09:29:16 +02:00
decode stdin strins arguments
This commit is contained in:
parent
7e4f9d995c
commit
dffd3ffa84
2 changed files with 12 additions and 11 deletions
14
lib/utils.py
14
lib/utils.py
|
@ -123,7 +123,6 @@ def searchThumbnail(options):
|
||||||
options['--thumbnail'] = video_directory + video_file + ".jpeg"
|
options['--thumbnail'] = video_directory + video_file + ".jpeg"
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
|
||||||
# return the nfo as a RawConfigParser object
|
# return the nfo as a RawConfigParser object
|
||||||
def loadNFO(options):
|
def loadNFO(options):
|
||||||
video_directory = dirname(options.get('--file')) + "/"
|
video_directory = dirname(options.get('--file')) + "/"
|
||||||
|
@ -168,7 +167,6 @@ def loadNFO(options):
|
||||||
logging.info("No suitable NFO found, skipping.")
|
logging.info("No suitable NFO found, skipping.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def parseNFO(options):
|
def parseNFO(options):
|
||||||
nfo = loadNFO(options)
|
nfo = loadNFO(options)
|
||||||
if nfo:
|
if nfo:
|
||||||
|
@ -189,11 +187,9 @@ def parseNFO(options):
|
||||||
exit(1)
|
exit(1)
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
|
||||||
def upcaseFirstLetter(s):
|
def upcaseFirstLetter(s):
|
||||||
return s[0].upper() + s[1:]
|
return s[0].upper() + s[1:]
|
||||||
|
|
||||||
|
|
||||||
def cleanString(toclean):
|
def cleanString(toclean):
|
||||||
toclean = toclean.split(' ')
|
toclean = toclean.split(' ')
|
||||||
cleaned = ''
|
cleaned = ''
|
||||||
|
@ -208,3 +204,13 @@ def cleanString(toclean):
|
||||||
cleaned = cleaned + strtoclean
|
cleaned = cleaned + strtoclean
|
||||||
|
|
||||||
return cleaned
|
return cleaned
|
||||||
|
|
||||||
|
def decodeArgumentStrings(options, encoding):
|
||||||
|
if options["--name"] is not None:
|
||||||
|
options["--name"] = options["--name"].decode(encoding)
|
||||||
|
|
||||||
|
if options["--description"] is not None:
|
||||||
|
options["--description"] = options["--description"].decode(encoding)
|
||||||
|
|
||||||
|
if options["--tags"] is not None:
|
||||||
|
options["--tags"] = options["--tags"].decode(encoding)
|
||||||
|
|
|
@ -64,12 +64,12 @@ Languages:
|
||||||
from os.path import dirname, realpath
|
from os.path import dirname, realpath
|
||||||
import sys
|
import sys
|
||||||
import datetime
|
import datetime
|
||||||
|
import locale
|
||||||
import logging
|
import logging
|
||||||
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
|
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
|
||||||
|
|
||||||
from docopt import docopt
|
from docopt import docopt
|
||||||
|
|
||||||
|
|
||||||
# Allows a relative import from the parent folder
|
# Allows a relative import from the parent folder
|
||||||
sys.path.insert(0, dirname(realpath(__file__)) + "/lib")
|
sys.path.insert(0, dirname(realpath(__file__)) + "/lib")
|
||||||
|
|
||||||
|
@ -110,7 +110,6 @@ VALID_LANGUAGES = ('arabic', 'english', 'french',
|
||||||
'japanese', 'korean', 'mandarin',
|
'japanese', 'korean', 'mandarin',
|
||||||
'portuguese', 'punjabi', 'russian', 'spanish')
|
'portuguese', 'punjabi', 'russian', 'spanish')
|
||||||
|
|
||||||
|
|
||||||
def validateVideo(path):
|
def validateVideo(path):
|
||||||
supported_types = ['video/mp4']
|
supported_types = ['video/mp4']
|
||||||
if magic.from_file(path, mime=True) in supported_types:
|
if magic.from_file(path, mime=True) in supported_types:
|
||||||
|
@ -118,21 +117,18 @@ def validateVideo(path):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def validateCategory(category):
|
def validateCategory(category):
|
||||||
if category.lower() in VALID_CATEGORIES:
|
if category.lower() in VALID_CATEGORIES:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def validatePrivacy(privacy):
|
def validatePrivacy(privacy):
|
||||||
if privacy.lower() in VALID_PRIVACY_STATUSES:
|
if privacy.lower() in VALID_PRIVACY_STATUSES:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def validatePlatform(platform):
|
def validatePlatform(platform):
|
||||||
for plfrm in platform.split(','):
|
for plfrm in platform.split(','):
|
||||||
if plfrm.lower().replace(" ", "") not in VALID_PLATFORM:
|
if plfrm.lower().replace(" ", "") not in VALID_PLATFORM:
|
||||||
|
@ -140,14 +136,12 @@ def validatePlatform(platform):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def validateLanguage(language):
|
def validateLanguage(language):
|
||||||
if language.lower() in VALID_LANGUAGES:
|
if language.lower() in VALID_LANGUAGES:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def validatePublish(publish):
|
def validatePublish(publish):
|
||||||
# Check date format and if date is future
|
# Check date format and if date is future
|
||||||
try:
|
try:
|
||||||
|
@ -222,6 +216,7 @@ if __name__ == '__main__':
|
||||||
'--version': bool
|
'--version': bool
|
||||||
})
|
})
|
||||||
|
|
||||||
|
utils.decodeArgumentStrings(options, locale.getpreferredencoding())
|
||||||
options = utils.parseNFO(options)
|
options = utils.parseNFO(options)
|
||||||
|
|
||||||
if not options.get('--thumbnail'):
|
if not options.get('--thumbnail'):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue