Update Beta 11.7

This commit is contained in:
Yoshiko 2019-08-06 16:36:45 +08:00 committed by GitHub
parent 2adcfacf27
commit cfb3511360
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 44 deletions

View File

@ -12,20 +12,17 @@ import subprocess
import shutil import shutil
from configparser import ConfigParser from configparser import ConfigParser
version='0.11.6' version='0.11.7'
os.chdir(os.getcwd()) os.chdir(os.getcwd())
input_dir='.' # 电影的读取与输出路径, 默认为当前路径 input_dir='.' # 电影的读取与输出路径, 默认为当前路径
output_dir='.'
config = ConfigParser() config = ConfigParser()
config.read(config_file, encoding='UTF-8') config.read(config_file, encoding='UTF-8')
def UpdateCheck(): def UpdateCheck():
if UpdateCheckSwitch() == '1': if UpdateCheckSwitch() == '1':
html2 = get_html('https://raw.githubusercontent.com/wenead99/AV_Data_Capture/master/update_check.json') html = json.loads(get_html('https://raw.githubusercontent.com/wenead99/AV_Data_Capture/master/update_check.json'))
html = json.loads(str(html2))
if not version == html['version']: if not version == html['version']:
print('[*] * New update ' + html['version'] + ' *') print('[*] * New update ' + html['version'] + ' *')
print('[*] * Download *') print('[*] * Download *')
@ -36,21 +33,15 @@ def UpdateCheck():
def set_directory(): # 设置读取与存放路径 def set_directory(): # 设置读取与存放路径
global input_dir global input_dir
global output_dir
# 配置项switch为1且定义了新的路径时, 更改默认存取路径 # 配置项switch为1且定义了新的路径时, 更改默认存取路径
if config['directory_capture']['switch'] == '1': if config['directory_capture']['switch'] == '1':
custom_input = config['directory_capture']['input_directory'] custom_input = config['directory_capture']['input_directory']
custom_output = config['directory_capture']['output_directory']
if custom_input != '': # 自定义了输入路径 if custom_input != '': # 自定义了输入路径
input_dir = format_path(custom_input) input_dir = format_path(custom_input)
# 若自定义了输入路径, 输出路径默认在输入路径下 # 若自定义了输入路径, 输出路径默认在输入路径下
output_dir = input_dir
output_dir = format_path(custom_output) if custom_output != '' else output_dir # 自定义了输出路径
CreatFolder(output_dir)
CreatFolder(input_dir) CreatFolder(input_dir)
print('[+]Working directory is "' + os.getcwd() + '".') #print('[+]Working directory is "' + os.getcwd() + '".')
print('[+]Using "' + input_dir + '" as input directory.') #print('[+]Using "' + input_dir + '" as input directory.')
print('[+]Using "' + output_dir + '" as output directory.')
def format_path(path): # 使路径兼容Linux与MacOS def format_path(path): # 使路径兼容Linux与MacOS
if path.find('\\'): # 是仅兼容Windows的路径格式 if path.find('\\'): # 是仅兼容Windows的路径格式
@ -130,33 +121,33 @@ def getNumber(filepath):
print('[-]' + str(os.path.basename(filepath)) + ' Cannot catch the number :') print('[-]' + str(os.path.basename(filepath)) + ' Cannot catch the number :')
print('[-]' + str(os.path.basename(filepath)) + ' :', e) print('[-]' + str(os.path.basename(filepath)) + ' :', e)
print('[-]Move ' + os.path.basename(filepath) + ' to failed folder') print('[-]Move ' + os.path.basename(filepath) + ' to failed folder')
print('[-]' + filepath + ' -> ' + output_dir + '/failed/') #print('[-]' + filepath + ' -> ' + output_dir + '/failed/')
shutil.move(filepath, output_dir + '/failed/') #shutil.move(filepath, output_dir + '/failed/')
except IOError as e2: except IOError as e2:
print('[-]' + str(os.path.basename(filepath)) + ' Cannot catch the number :') print('[-]' + str(os.path.basename(filepath)) + ' Cannot catch the number :')
print('[-]' + str(os.path.basename(filepath)) + ' :', e2) print('[-]' + str(os.path.basename(filepath)) + ' :', e2)
print('[-]' + filepath + ' -> ' + output_dir + '/failed/') #print('[-]' + filepath + ' -> ' + output_dir + '/failed/')
shutil.move(filepath, output_dir + '/failed/') #shutil.move(filepath, output_dir + '/failed/')
def RunCore(movie): def RunCore(movie):
# 异步调用core.py, core.py作为子线程执行, 本程序继续执行. # 异步调用core.py, core.py作为子线程执行, 本程序继续执行.
if os.path.exists('core.py'): if os.path.exists('core.py'):
cmd_arg=[sys.executable,'core.py',movie,'--number',getNumber(movie),'--output',output_dir] #从py文件启动用于源码py cmd_arg=[sys.executable,'core.py',movie,'--number',getNumber(movie)] #从py文件启动用于源码py
elif os.path.exists('core.exe'): elif os.path.exists('core.exe'):
cmd_arg=['core.exe',movie,'--number',getNumber(movie),'--output',output_dir] #从exe启动用于EXE版程序 cmd_arg=['core.exe',movie,'--number',getNumber(movie)] #从exe启动用于EXE版程序
elif os.path.exists('core.py') and os.path.exists('core.exe'): elif os.path.exists('core.py') and os.path.exists('core.exe'):
cmd_arg=[sys.executable,'core.py',movie,'--number',getNumber(movie),'--output',output_dir] #从py文件启动用于源码py cmd_arg=[sys.executable,'core.py',movie,'--number',getNumber(movie)] #从py文件启动用于源码py
process=subprocess.Popen(cmd_arg) process=subprocess.Popen(cmd_arg)
return process return process
if __name__ =='__main__': if __name__ =='__main__':
print('[*]===========AV Data Capture===========') print('[*]===========AV Data Capture===========')
print('[*] Version '+version) print('[*] Version '+version)
print('[*]=====================================') print('[*]=====================================')
UpdateCheck() UpdateCheck()
os.chdir(os.getcwd()) os.chdir(os.getcwd())
set_directory() set_directory()
CreatFolder(output_dir+'/failed')
count = 0 count = 0
movies = movie_lists() movies = movie_lists()

View File

@ -1,5 +1,5 @@
[proxy] [proxy]
proxy=127.0.0.1:8001 proxy=127.0.0.1:1080
timeout=10 timeout=10
retry=3 retry=3
@ -16,8 +16,6 @@ media_warehouse=emby
#plex only test! #plex only test!
[directory_capture] [directory_capture]
switch=1
input_directory= input_directory=
output_directory=
#everyone switch:1=on, 0=off #everyone switch:1=on, 0=off

28
core.py
View File

@ -32,7 +32,6 @@ imagecut=''
tag=[] tag=[]
cn_sub='' cn_sub=''
path='' path=''
output_dir=''
houzhui='' houzhui=''
website='' website=''
json_data={} json_data={}
@ -51,20 +50,19 @@ except:
def moveFailedFolder(): def moveFailedFolder():
global filepath global filepath
print('[-]Move to "failed"') print('[-]Move to "failed"')
print('[-]' + filepath + ' -> ' + output_dir + '/failed/') #print('[-]' + filepath + ' -> ' + output_dir + '/failed/')
os.rename(filepath, output_dir + '/failed/') #os.rename(filepath, output_dir + '/failed/')
os._exit(0) os._exit(0)
def argparse_get_file(): def argparse_get_file():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("file", help="Write the file path on here") parser.add_argument("file", help="Write the file path on here")
parser.add_argument("--number", help="Enter Number on here", default='') parser.add_argument("--number", help="Enter Number on here", default='')
parser.add_argument("--output", help="Enter Output directory here", default='')
args = parser.parse_args() args = parser.parse_args()
return (args.file, args.number, args.output) return (args.file, args.number)
def CreatFailedFolder(): def CreatFailedFolder():
if not os.path.exists(output_dir+'/failed/'): # 新建failed文件夹 if not os.path.exists('/failed/'): # 新建failed文件夹
try: try:
os.makedirs(output_dir+'/failed/') os.makedirs('/failed/')
except: except:
print("[-]failed!can not be make folder 'failed'\n[-](Please run as Administrator)") print("[-]failed!can not be make folder 'failed'\n[-](Please run as Administrator)")
os._exit(0) os._exit(0)
@ -158,10 +156,10 @@ def creatFolder(): #创建文件夹
global actor global actor
global path global path
if len(actor) > 240: #新建成功输出文件夹 if len(actor) > 240: #新建成功输出文件夹
path = output_dir + '/' + location_rule.replace("'actor'","'超多人'",3).replace("actor","'超多人'",3) #path为影片+元数据所在目录 path = location_rule.replace("'actor'","'超多人'",3).replace("actor","'超多人'",3) #path为影片+元数据所在目录
#print(path) #print(path)
else: else:
path = output_dir + '/' + location_rule path = location_rule
#print(path) #print(path)
if not os.path.exists(path): if not os.path.exists(path):
try: try:
@ -377,16 +375,9 @@ def cutImage():
def pasteFileToFolder(filepath, path): #文件路径,番号,后缀,要移动至的位置 def pasteFileToFolder(filepath, path): #文件路径,番号,后缀,要移动至的位置
global houzhui global houzhui
houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group()) houzhui = str(re.search('[.](AVI|RMVB|WMV|MOV|MP4|MKV|FLV|TS|avi|rmvb|wmv|mov|mp4|mkv|flv|ts)$', filepath).group())
os.rename(filepath, number + houzhui)
try: try:
print('[*]' + filepath + ' -> ' + output_dir + number + houzhui) shutil.move(number + houzhui, path)
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:
print('[*]' + output_dir + '/' + number + houzhui + ' -> ' + path)
os.rename(output_dir + '/' + number + houzhui, path)
except: except:
print('[-]File Exists! Please check your movie!') print('[-]File Exists! Please check your movie!')
print('[-]move to the root folder of the program.') print('[-]move to the root folder of the program.')
@ -413,7 +404,6 @@ if __name__ == '__main__':
moveFailedFolder() moveFailedFolder()
else: else:
number = argparse_get_file()[1] number = argparse_get_file()[1]
output_dir = argparse_get_file()[2]
CreatFailedFolder() CreatFailedFolder()
getDataFromJSON(number) # 定义番号 getDataFromJSON(number) # 定义番号
creatFolder() # 创建文件夹 creatFolder() # 创建文件夹