javdb*.json path search order
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -220,10 +220,10 @@ def main(number):
|
||||
# 不加载过期的cookie,javdb登录界面显示为7天免登录,故假定cookie有效期为7天
|
||||
cdays = file_modification_days(cookie_json)
|
||||
if cdays < 7:
|
||||
javdb_cookies = load_cookies(cookie_json)
|
||||
javdb_cookies, cookies_filepath = load_cookies(cookie_json)
|
||||
elif cdays != 9999:
|
||||
print('[!]Cookies file ' + cookie_json + ' was updated ' + str(cdays) +
|
||||
' days ago, it will not be used for HTTP requests.')
|
||||
print(
|
||||
f'[!]Cookies file {cookies_filepath} was updated {cdays} days ago, it will not be used for HTTP requests.')
|
||||
|
||||
try:
|
||||
javdb_url = 'https://' + javdb_site + '.com/search?q=' + number + '&f=all'
|
||||
|
||||
Reference in New Issue
Block a user