Fix some bugs.
This commit is contained in:
parent
1bc924a6ac
commit
09dc684ff6
@ -130,11 +130,12 @@ def getNumber(filepath):
|
||||
print('[-]' + str(os.path.basename(filepath)) + ' Cannot catch the number :')
|
||||
print('[-]' + str(os.path.basename(filepath)) + ' :', e)
|
||||
print('[-]Move ' + os.path.basename(filepath) + ' to failed folder')
|
||||
print('[-]' + filepath + ' -> ' + output_dir + '/failed/')
|
||||
shutil.move(filepath, output_dir + '/failed/')
|
||||
except IOError as e2:
|
||||
print('[-]' + str(os.path.basename(filepath)) + ' Cannot catch the number :')
|
||||
print('[-]' + str(os.path.basename(filepath)) + ' :', e2)
|
||||
print('[-]Move ' + os.path.basename(filepath) + ' to failed folder')
|
||||
print('[-]' + filepath + ' -> ' + output_dir + '/failed/')
|
||||
shutil.move(filepath, output_dir + '/failed/')
|
||||
|
||||
def RunCore(movie):
|
||||
@ -163,7 +164,12 @@ if __name__ =='__main__':
|
||||
print('[+]Find ' + str(len(movies)) + ' movies.')
|
||||
process_list=[]
|
||||
for movie in movies: #遍历电影列表 交给core处理
|
||||
print("[!]Making Data for [" + movie + "], the number is [" + getNumber(movie) + "]")
|
||||
num=getNumber(movie) # 获取番号
|
||||
if num is None:
|
||||
movies.remove(movie) # 未获取到番号, 则将影片从列表移除
|
||||
count_all=count_all-1
|
||||
continue
|
||||
print("[!]Making Data for [" + movie + "], the number is [" + num + "]")
|
||||
process=RunCore(movie)
|
||||
process_list.append(process)
|
||||
print("[*]=====================================")
|
||||
|
15
core.py
15
core.py
@ -51,7 +51,8 @@ except:
|
||||
def moveFailedFolder():
|
||||
global filepath
|
||||
print('[-]Move to "failed"')
|
||||
shutil.move(filepath, output_dir + '/failed/')
|
||||
print('[-]' + filepath + ' -> ' + output_dir + '/failed/')
|
||||
os.rename(filepath, output_dir + '/failed/')
|
||||
os._exit(0)
|
||||
def argparse_get_file():
|
||||
parser = argparse.ArgumentParser()
|
||||
@ -377,18 +378,20 @@ def pasteFileToFolder(filepath, path): #文件路径,番号,后缀,要移
|
||||
global houzhui
|
||||
houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group())
|
||||
try:
|
||||
os.rename(filepath, number + houzhui)
|
||||
print('[*]' + filepath + ' -> ' + output_dir + number + houzhui)
|
||||
os.rename(filepath, output_dir + '/' + number + houzhui)
|
||||
except FileExistsError:
|
||||
print('[-]File Exists! Please check your movie!')
|
||||
print('[-]move to the root folder of the program.')
|
||||
os._exit(0)
|
||||
try:
|
||||
shutil.move(number + houzhui, path)
|
||||
print('[*]' + output_dir + '/' + number + houzhui + ' -> ' + path)
|
||||
os.rename(output_dir + '/' + number + houzhui, path)
|
||||
except:
|
||||
print('[-]File Exists! Please check your movie!')
|
||||
print('[-]move to the root folder of the program.')
|
||||
os._exit(0)
|
||||
def renameJpgToBackdrop_copy():
|
||||
def moveJpgToBackdrop_copy():
|
||||
if option == 'plex':
|
||||
shutil.copy(path + '/fanart.jpg', path + '/Backdrop.jpg')
|
||||
shutil.copy(path + '/poster.png', path + '/thumb.png')
|
||||
@ -406,7 +409,7 @@ if __name__ == '__main__':
|
||||
number = str(re.findall(r'(.+?)\.',str(re.search('([^<>/\\\\|:""\\*\\?]+)\\.\\w+$',filepath).group()))).strip("['']").replace('_','-')
|
||||
print("[!]Making Data for [" + number + "]")
|
||||
except:
|
||||
print("[-]failed!Please rename the filename again!")
|
||||
print("[-]failed!Please move the filename again!")
|
||||
moveFailedFolder()
|
||||
else:
|
||||
number = argparse_get_file()[1]
|
||||
@ -418,4 +421,4 @@ if __name__ == '__main__':
|
||||
PrintFiles(filepath) # 打印文件
|
||||
cutImage() # 裁剪图
|
||||
pasteFileToFolder(filepath, path) # 移动文件
|
||||
renameJpgToBackdrop_copy()
|
||||
moveJpgToBackdrop_copy()
|
||||
|
Loading…
Reference in New Issue
Block a user