javdb*.json path search order

This commit is contained in:
lededev
2021-09-27 22:20:37 +08:00
parent 07893de121
commit 75b71888d9
2 changed files with 21 additions and 5 deletions

View File

@@ -590,10 +590,26 @@ def is_uncensored(number):
# 从网站登录后,通过浏览器插件(CookieBro或EdittThisCookie)或者直接在地址栏网站链接信息处都可以复制或者导出cookie内容
# 并填写到以上json文件的相应字段中
def load_cookies(filename):
filename = os.path.basename(filename)
if not len(filename):
return None, None
path_search_order = [
f"./{filename}",
os.path.join(Path.home(), filename),
os.path.join(Path.home(), f".avdc/{filename}"),
os.path.join(Path.home(), f".local/share/avdc/{filename}")
]
cookies_filename = None
for p in path_search_order:
if os.path.exists(p):
cookies_filename = p
break
if not cookies_filename:
return None, None
try:
return json.load(open(filename))
return json.load(open(cookies_filename)), cookies_filename
except:
return None
return None, None
# 文件修改时间距此时的天数
def file_modification_days(filename) -> int: