Anilife: Implement HTTP caching with cache_ttl setting (default 300s)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
title: "애니 다운로더"
|
title: "애니 다운로더"
|
||||||
version: "0.6.4"
|
version: "0.6.5"
|
||||||
package_name: "anime_downloader"
|
package_name: "anime_downloader"
|
||||||
developer: "projectdx"
|
developer: "projectdx"
|
||||||
description: "anime downloader"
|
description: "anime downloader"
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ class LogicAniLife(AnimeModuleBase):
|
|||||||
"anilife_db_version": "1",
|
"anilife_db_version": "1",
|
||||||
"anilife_url": "https://anilife.live",
|
"anilife_url": "https://anilife.live",
|
||||||
"anilife_proxy_url": "",
|
"anilife_proxy_url": "",
|
||||||
|
"anilife_cache_ttl": "300", # HTTP cache TTL in seconds (5 minutes)
|
||||||
"anilife_download_path": os.path.join(path_data, P.package_name, "ohli24"),
|
"anilife_download_path": os.path.join(path_data, P.package_name, "ohli24"),
|
||||||
"anilife_auto_make_folder": "True",
|
"anilife_auto_make_folder": "True",
|
||||||
"anilife_auto_make_season_folder": "True",
|
"anilife_auto_make_season_folder": "True",
|
||||||
@@ -101,6 +102,10 @@ class LogicAniLife(AnimeModuleBase):
|
|||||||
"anilife_camoufox_installed": "False",
|
"anilife_camoufox_installed": "False",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Class variables for caching
|
||||||
|
cache_path = os.path.dirname(__file__)
|
||||||
|
session = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_proxy(cls) -> str:
|
def get_proxy(cls) -> str:
|
||||||
return P.ModelSetting.get("anilife_proxy_url")
|
return P.ModelSetting.get("anilife_proxy_url")
|
||||||
@@ -112,6 +117,20 @@ class LogicAniLife(AnimeModuleBase):
|
|||||||
return {"http": proxy, "https": proxy}
|
return {"http": proxy, "https": proxy}
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_session(cls):
|
||||||
|
"""Get or create a cached session for HTTP requests."""
|
||||||
|
if cls.session is None:
|
||||||
|
cache_ttl = P.ModelSetting.get_int("anilife_cache_ttl")
|
||||||
|
cls.session = CachedSession(
|
||||||
|
os.path.join(cls.cache_path, "anilife_cache"),
|
||||||
|
backend="sqlite",
|
||||||
|
expire_after=cache_ttl,
|
||||||
|
cache_control=True,
|
||||||
|
)
|
||||||
|
logger.info(f"[Anilife] CachedSession initialized with TTL: {cache_ttl}s")
|
||||||
|
return cls.session
|
||||||
|
|
||||||
current_headers = None
|
current_headers = None
|
||||||
current_data = None
|
current_data = None
|
||||||
referer = None
|
referer = None
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
<form id="setting" class="mt-4">
|
<form id="setting" class="mt-4">
|
||||||
<div class="tab-content" id="nav-tabContent">
|
<div class="tab-content" id="nav-tabContent">
|
||||||
{{ macros.m_tab_content_start('normal', true) }}
|
{{ macros.m_tab_content_start('normal', true) }}
|
||||||
{{ macros.setting_input_text_and_buttons('anilife_url', '애니라이프 URL', [['go_btn', 'GO']], value=arg['anilife_url']) }}\n {{ macros.setting_input_text('anilife_proxy_url', '프록시 URL', col='4', value=arg.get('anilife_proxy_url', ''), desc='차단 시 프록시 서버를 입력하세요. 예: http://IP:PORT') }}
|
{{ macros.setting_input_text_and_buttons('anilife_url', '애니라이프 URL', [['go_btn', 'GO']], value=arg['anilife_url']) }}\n {{ macros.setting_input_text('anilife_proxy_url', '프록시 URL', col='4', value=arg.get('anilife_proxy_url', ''), desc='차단 시 프록시 서버를 입력하세요. 예: http://IP:PORT') }}\n {{ macros.setting_input_int('anilife_cache_ttl', 'HTTP 캐시 TTL (초)', value=arg.get('anilife_cache_ttl', 300), desc='HTTP 응답 캐시 유지 시간 (초 단위, 기본: 300초 = 5분)') }}
|
||||||
|
|
||||||
<!-- 저장 폴더 (탐색 버튼 포함) -->
|
<!-- 저장 폴더 (탐색 버튼 포함) -->
|
||||||
<div class="row" style="padding-top: 10px; padding-bottom:10px; align-items: center;">
|
<div class="row" style="padding-top: 10px; padding-bottom:10px; align-items: center;">
|
||||||
|
|||||||
Reference in New Issue
Block a user