Merge pull request #598 from lededev/javdbjson-mpath
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 = os.path.abspath(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'
|
||||
|
||||
4
core.py
4
core.py
@@ -29,14 +29,14 @@ def moveFailedFolder(filepath, conf):
|
||||
# 模式3或软连接,改为维护一个失败列表,启动扫描时加载用于排除该路径,以免反复处理
|
||||
# 原先的创建软连接到失败目录,并不直观,不方便找到失败文件位置,不如直接记录该文件路径
|
||||
if conf.main_mode() == 3 or soft_link:
|
||||
ftxt = os.path.join(failed_folder, 'failed_list.txt')
|
||||
ftxt = os.path.abspath(os.path.join(failed_folder, 'failed_list.txt'))
|
||||
print("[-]Add to Failed List file, see '%s'" % ftxt)
|
||||
with open(ftxt, 'a', encoding='utf-8') as flt:
|
||||
flt.write(f'{filepath}\n')
|
||||
flt.close()
|
||||
elif conf.failed_move() and not soft_link:
|
||||
failed_name = os.path.join(failed_folder, os.path.basename(filepath))
|
||||
mtxt = os.path.join(failed_folder, 'where_was_i_before_being_moved.txt')
|
||||
mtxt = os.path.abspath(os.path.join(failed_folder, 'where_was_i_before_being_moved.txt'))
|
||||
print("'[-]Move to Failed output folder, see '%s'" % mtxt)
|
||||
with open(mtxt, 'a', encoding='utf-8') as wwibbmt:
|
||||
tmstr = datetime.now().strftime("%Y-%m-%d %H:%M")
|
||||
|
||||
Reference in New Issue
Block a user