Update 3.7.2

This commit is contained in:
yoshiko2
2020-09-08 20:44:55 +08:00
parent 1745c6ac3e
commit ee7f14ef20
6 changed files with 68 additions and 22 deletions

View File

@@ -22,11 +22,10 @@ def argparse_function() -> [str, str, bool]:
parser = argparse.ArgumentParser()
parser.add_argument("file", default='', nargs='?', help="Single Movie file path.")
parser.add_argument("-c", "--config", default='config.ini', nargs='?', help="The config file Path.")
parser.add_argument("-a", "--auto-exit", dest='autoexit', action="store_true", help="Auto exit after program complete")
parser.add_argument("-n", "--number", default='', nargs='?',help="Custom file number")
args = parser.parse_args()
return args.file, args.config, args.autoexit, args.number
return args.file, args.config, args.number
def movie_lists(root, escape_folder):
for folder in escape_folder:
@@ -65,7 +64,7 @@ def CEF(path):
def create_data_and_move(file_path: str, c: config.Config,debug):
# Normalized number, eg: 111xxx-222.mp4 -> xxx-222.mp4
n_number = get_number(file_path)
n_number = get_number(debug,file_path)
if debug == True:
print("[!]Making Data for [{}], the number is [{}]".format(file_path, n_number))
@@ -80,15 +79,21 @@ def create_data_and_move(file_path: str, c: config.Config,debug):
print("[-] [{}] ERROR:".format(file_path))
print('[-]', err)
if c.soft_link():
print("[-]Link {} to failed folder".format(file_path))
os.symlink(file_path, str(os.getcwd()) + "/" + conf.failed_folder() + "/")
else:
try:
print("[-]Move [{}] to failed folder".format(file_path))
shutil.move(file_path, str(os.getcwd()) + "/" + conf.failed_folder() + "/")
except Exception as err:
print('[!]', err)
# 3.7.2 New: Move or not move to failed folder.
if c.failed_move() == False:
if c.soft_link():
print("[-]Link {} to failed folder".format(file_path))
os.symlink(file_path, str(os.getcwd()) + "/" + conf.failed_folder() + "/")
elif c.failed_move() == True:
if c.soft_link():
print("[-]Link {} to failed folder".format(file_path))
os.symlink(file_path, str(os.getcwd()) + "/" + conf.failed_folder() + "/")
else:
try:
print("[-]Move [{}] to failed folder".format(file_path))
shutil.move(file_path, str(os.getcwd()) + "/" + conf.failed_folder() + "/")
except Exception as err:
print('[!]', err)
def create_data_and_move_with_custom_number(file_path: str, c: config.Config, custom_number=None):
try:
@@ -114,7 +119,7 @@ if __name__ == '__main__':
version = '3.7.2'
# Parse command line args
single_file_path, config_file, auto_exit, custom_number = argparse_function()
single_file_path, config_file, custom_number = argparse_function()
# Read config.ini
conf = config.Config(path=config_file)
@@ -159,6 +164,6 @@ if __name__ == '__main__':
CEF(conf.success_folder())
CEF(conf.failed_folder())
print("[+]All finished!!!")
if auto_exit:
if conf.auto_exit():
os._exit(0)
input("[+][+]Press enter key exit, you can check the error message before you exit.")

View File

@@ -3,6 +3,8 @@ main_mode=1
failed_output_folder=failed
success_output_folder=JAV_output
soft_link=0
failed_move=1
auto_exit=0
[proxy]
;proxytype: http or socks5 or socks5h

View File

@@ -29,6 +29,10 @@ class Config:
def soft_link(self) -> bool:
return self.conf.getboolean("common", "soft_link")
def failed_move(self) -> bool:
return self.conf.getboolean("common", "failed_move")
def auto_exit(self) -> bool:
return self.conf.getboolean("common", "auto_exit")
def proxy(self) -> [str, int, int, str]:
try:
@@ -81,6 +85,8 @@ class Config:
conf.set(sec1, "failed_output_folder", "failed")
conf.set(sec1, "success_output_folder", "JAV_output")
conf.set(sec1, "soft_link", "0")
conf.set(sec1, "failed_move", "1")
conf.set(sec1, "auto_exit", "0")
sec2 = "proxy"
conf.add_section(sec2)
@@ -120,6 +126,8 @@ if __name__ == "__main__":
print(config.failed_folder())
print(config.success_folder())
print(config.soft_link())
print(config.failed_move())
print(config.auto_exit())
print(config.proxy())
print(config.naming_rule())
print(config.location_rule())

10
core.py
View File

@@ -68,22 +68,32 @@ def get_data_from_json(file_number, filepath, conf: config.Config): # 从JSON
if "avsox" in sources and (re.match(r"^\d{5,}", file_number) or
"HEYZO" in file_number or "heyzo" in file_number or "Heyzo" in file_number
):
if conf.debug() == True:
print('[+]select avsox')
sources.insert(0, sources.pop(sources.index("avsox")))
elif "fanza" in sources and (re.match(r"\d+\D+", file_number) or
"siro" in file_number or "SIRO" in file_number or "Siro" in file_number
):
if conf.debug() == True:
print('[+]select fanza')
sources.insert(0, sources.pop(sources.index("fanza")))
elif "fc2" in sources and ("fc2" in file_number or "FC2" in file_number
):
if conf.debug() == True:
print('[+]select fc2')
sources.insert(0, sources.pop(sources.index("fc2")))
elif "dlsite" in sources and (
"RJ" in file_number or "rj" in file_number or "VJ" in file_number or "vj" in file_number
):
if conf.debug() == True:
print('[+]select dlsite')
sources.insert(0, sources.pop(sources.index("dlsite")))
json_data = {}
for source in sources:
try:
if conf.debug() == True:
print('[+]select',source)
json_data = json.loads(func_mapping[source](file_number))
# if any service return a valid return, break
if get_data_state(json_data):

View File

@@ -1,8 +1,10 @@
import os
import re
from core import *
def get_number(filepath: str) -> str:
def get_number(debug,filepath: str) -> str:
"""
>>> from number_parser import get_number
>>> get_number("/Users/Guest/AV_Data_Capture/snis-829.mp4")
@@ -28,7 +30,28 @@ def get_number(filepath: str) -> str:
"""
filepath = os.path.basename(filepath)
try:
if debug == False:
try:
if '-' in filepath or '_' in filepath: # 普通提取番号 主要处理包含减号-和_的番号
filepath = filepath.replace("_", "-")
filepath.strip('22-sht.me').strip('-HD').strip('-hd')
filename = str(re.sub("\[\d{4}-\d{1,2}-\d{1,2}\] - ", "", filepath)) # 去除文件名中时间
if 'FC2' or 'fc2' in filename:
filename = filename.replace('PPV', '').replace('ppv', '').replace('--', '-').replace('_', '-')
file_number = re.search(r'\w+-\w+', filename, re.A).group()
return file_number
else: # 提取不含减号-的番号FANZA CID
try:
return str(
re.findall(r'(.+?)\.',
str(re.search('([^<>/\\\\|:""\\*\\?]+)\\.\\w+$', filepath).group()))).strip(
"['']").replace('_', '-')
except:
return re.search(r'(.+?)\.', filepath)[0]
except Exception as e:
print('[-]' + str(e))
return
elif debug == True:
if '-' in filepath or '_' in filepath: # 普通提取番号 主要处理包含减号-和_的番号
filepath = filepath.replace("_", "-")
filepath.strip('22-sht.me').strip('-HD').strip('-hd')
@@ -40,13 +63,11 @@ def get_number(filepath: str) -> str:
else: # 提取不含减号-的番号FANZA CID
try:
return str(
re.findall(r'(.+?)\.', str(re.search('([^<>/\\\\|:""\\*\\?]+)\\.\\w+$', filepath).group()))).strip(
re.findall(r'(.+?)\.',
str(re.search('([^<>/\\\\|:""\\*\\?]+)\\.\\w+$', filepath).group()))).strip(
"['']").replace('_', '-')
except:
return re.search(r'(.+?)\.', filepath)[0]
except Exception as e:
print('[-]' + str(e))
return
if __name__ == "__main__":

View File

@@ -1,5 +1,5 @@
{
"version": "3.7.1",
"version_show": "3.7.1",
"version": "3.7.2",
"version_show": "3.7.2",
"download": "https://github.com/yoshiko2/AV_Data_Capture/releases"
}