Calling core.py asynchronously. Allow to specify input and output paths.

This commit is contained in:
RRRRRm
2019-08-05 15:48:44 +08:00
parent 1086447369
commit 00db4741bc
3 changed files with 87 additions and 55 deletions

17
core.py
View File

@@ -32,6 +32,7 @@ imagecut=''
tag=[]
cn_sub=''
path=''
output_dir=''
houzhui=''
website=''
json_data={}
@@ -50,18 +51,19 @@ except:
def moveFailedFolder():
global filepath
print('[-]Move to "failed"')
shutil.move(filepath, str(os.getcwd()) + '/' + 'failed/')
shutil.move(filepath, output_dir + '/failed/')
os._exit(0)
def argparse_get_file():
parser = argparse.ArgumentParser()
parser.add_argument("--number", help="Enter Number on here", default='')
parser.add_argument("file", help="Write the file path on here")
parser.add_argument("--number", help="Enter Number on here", default='')
parser.add_argument("--output", help="Enter Output directory here", default='')
args = parser.parse_args()
return (args.file, args.number)
return (args.file, args.number, args.output)
def CreatFailedFolder():
if not os.path.exists('failed/'): # 新建failed文件夹
if not os.path.exists(output_dir+'/failed/'): # 新建failed文件夹
try:
os.makedirs('failed/')
os.makedirs(output_dir+'/failed/')
except:
print("[-]failed!can not be make folder 'failed'\n[-](Please run as Administrator)")
os._exit(0)
@@ -155,10 +157,10 @@ def creatFolder(): #创建文件夹
global actor
global path
if len(actor) > 240: #新建成功输出文件夹
path = location_rule.replace("'actor'","'超多人'",3).replace("actor","'超多人'",3) #path为影片+元数据所在目录
path = output_dir + '/' + location_rule.replace("'actor'","'超多人'",3).replace("actor","'超多人'",3) #path为影片+元数据所在目录
#print(path)
else:
path = location_rule
path = output_dir + '/' + location_rule
#print(path)
if not os.path.exists(path):
try:
@@ -408,6 +410,7 @@ if __name__ == '__main__':
moveFailedFolder()
else:
number = argparse_get_file()[1]
output_dir = argparse_get_file()[2]
CreatFailedFolder()
getDataFromJSON(number) # 定义番号
creatFolder() # 创建文件夹