再将其它几个makedirs()一起修正,去掉错上加错的提升到admin建议信息
This commit is contained in:
@@ -214,13 +214,11 @@ def movie_lists(root, conf, regexstr):
|
|||||||
|
|
||||||
|
|
||||||
def create_failed_folder(failed_folder):
|
def create_failed_folder(failed_folder):
|
||||||
if not os.path.isdir(failed_folder): # 新建failed文件夹
|
if not os.path.exists(failed_folder): # 新建failed文件夹
|
||||||
try:
|
try:
|
||||||
os.makedirs(failed_folder)
|
os.makedirs(failed_folder)
|
||||||
if not os.path.isdir(failed_folder):
|
|
||||||
raise
|
|
||||||
except:
|
except:
|
||||||
print("[-]failed!can not be make folder 'failed'\n[-](Please run as Administrator)")
|
print(f"[-]Fatal error! Can not make folder '{failed_folder}'")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
34
core.py
34
core.py
@@ -83,17 +83,19 @@ def create_folder(json_data, conf: config.Config): # 创建文件夹
|
|||||||
location_rule = location_rule.replace(title, shorttitle)
|
location_rule = location_rule.replace(title, shorttitle)
|
||||||
|
|
||||||
path = os.path.join(success_folder, location_rule).strip()
|
path = os.path.join(success_folder, location_rule).strip()
|
||||||
if not os.path.isdir(path):
|
if not os.path.exists(path):
|
||||||
path = escape_path(path, conf.escape_literals())
|
path = escape_path(path, conf.escape_literals())
|
||||||
try:
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
if not os.path.isdir(path):
|
|
||||||
raise
|
|
||||||
except:
|
except:
|
||||||
path = success_folder + '/' + location_rule.replace('/[' + number + ')-' + title, "/number")
|
path = success_folder + '/' + location_rule.replace('/[' + number + ')-' + title, "/number")
|
||||||
path = escape_path(path, conf.escape_literals())
|
path = escape_path(path, conf.escape_literals())
|
||||||
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
|
except:
|
||||||
|
print(f"[-]Fatal error! Can not make folder '{path}'")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
@@ -106,10 +108,12 @@ def download_file_with_filename(url, filename, path, conf: config.Config, filepa
|
|||||||
for i in range(configProxy.retry):
|
for i in range(configProxy.retry):
|
||||||
try:
|
try:
|
||||||
if configProxy.enable:
|
if configProxy.enable:
|
||||||
if not os.path.isdir(path):
|
if not os.path.exists(path):
|
||||||
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
if not os.path.isdir(path):
|
except:
|
||||||
raise IOError
|
print(f"[-]Fatal error! Can not make folder '{path}'")
|
||||||
|
sys.exit(0)
|
||||||
proxies = configProxy.proxies()
|
proxies = configProxy.proxies()
|
||||||
headers = {
|
headers = {
|
||||||
'User-Agent': G_USER_AGENT}
|
'User-Agent': G_USER_AGENT}
|
||||||
@@ -121,10 +125,12 @@ def download_file_with_filename(url, filename, path, conf: config.Config, filepa
|
|||||||
code.write(r.content)
|
code.write(r.content)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
if not os.path.isdir(path):
|
if not os.path.exists(path):
|
||||||
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
if not os.path.isdir(path):
|
except:
|
||||||
raise IOError
|
print(f"[-]Fatal error! Can not make folder '{path}'")
|
||||||
|
sys.exit(0)
|
||||||
headers = {
|
headers = {
|
||||||
'User-Agent': G_USER_AGENT}
|
'User-Agent': G_USER_AGENT}
|
||||||
r = requests.get(url, timeout=configProxy.timeout, headers=headers)
|
r = requests.get(url, timeout=configProxy.timeout, headers=headers)
|
||||||
@@ -224,10 +230,12 @@ def print_files(path, leak_word, c_word, naming_rule, part, cn_sub, json_data, f
|
|||||||
else:
|
else:
|
||||||
nfo_path = os.path.join(path,f"{number}{part}{leak_word}{c_word}.nfo")
|
nfo_path = os.path.join(path,f"{number}{part}{leak_word}{c_word}.nfo")
|
||||||
try:
|
try:
|
||||||
if not os.path.isdir(path):
|
if not os.path.exists(path):
|
||||||
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
if not os.path.isdir(path):
|
except:
|
||||||
raise IOError
|
print(f"[-]Fatal error! can not make folder '{path}'")
|
||||||
|
sys.exit(0)
|
||||||
with open(nfo_path, "wt", encoding='UTF-8') as code:
|
with open(nfo_path, "wt", encoding='UTF-8') as code:
|
||||||
print('<?xml version="1.0" encoding="UTF-8" ?>', file=code)
|
print('<?xml version="1.0" encoding="UTF-8" ?>', file=code)
|
||||||
print("<movie>", file=code)
|
print("<movie>", file=code)
|
||||||
|
|||||||
Reference in New Issue
Block a user