Anilife GDM integration: CachedSession, ModuleQueue, Go GDM button
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
title: "애니 다운로더"
|
title: "애니 다운로더"
|
||||||
version: "0.5.40"
|
version: "0.5.41"
|
||||||
package_name: "anime_downloader"
|
package_name: "anime_downloader"
|
||||||
developer: "projectdx"
|
developer: "projectdx"
|
||||||
description: "anime downloader"
|
description: "anime downloader"
|
||||||
|
|||||||
@@ -65,6 +65,13 @@ from typing import Awaitable, TypeVar
|
|||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
|
|
||||||
from .setup import *
|
from .setup import *
|
||||||
|
from requests_cache import CachedSession
|
||||||
|
|
||||||
|
# GDM Integration
|
||||||
|
try:
|
||||||
|
from gommi_downloader_manager.mod_queue import ModuleQueue
|
||||||
|
except ImportError:
|
||||||
|
ModuleQueue = None
|
||||||
|
|
||||||
logger = P.logger
|
logger = P.logger
|
||||||
name = "anilife"
|
name = "anilife"
|
||||||
@@ -150,6 +157,7 @@ class LogicAniLife(AnimeModuleBase):
|
|||||||
return lib_exists
|
return lib_exists
|
||||||
|
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
|
cached_session = None # Will be initialized on first use
|
||||||
headers = {
|
headers = {
|
||||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
|
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
|
||||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
||||||
@@ -1318,7 +1326,40 @@ class LogicAniLife(AnimeModuleBase):
|
|||||||
db_entity.save()
|
db_entity.save()
|
||||||
return "file_exists"
|
return "file_exists"
|
||||||
|
|
||||||
# 4. Proceed with queue addition
|
# 4. Try GDM if available (like Ohli24)
|
||||||
|
if ModuleQueue is not None:
|
||||||
|
entity = AniLifeQueueEntity(P, self, episode_info)
|
||||||
|
logger.debug("entity:::> %s", entity.as_dict())
|
||||||
|
|
||||||
|
# Save to DB first
|
||||||
|
if db_entity is None:
|
||||||
|
ModelAniLifeItem.append(entity.as_dict())
|
||||||
|
|
||||||
|
# Prepare GDM options (same pattern as Ohli24)
|
||||||
|
gdm_options = {
|
||||||
|
"url": entity.url,
|
||||||
|
"save_path": entity.savepath,
|
||||||
|
"filename": entity.filename,
|
||||||
|
"source_type": "anilife",
|
||||||
|
"caller_plugin": f"{P.package_name}_{self.name}",
|
||||||
|
"callback_id": episode_info["_id"],
|
||||||
|
"title": entity.filename or episode_info.get('title'),
|
||||||
|
"thumbnail": episode_info.get('image'),
|
||||||
|
"meta": {
|
||||||
|
"series": entity.content_title,
|
||||||
|
"season": entity.season,
|
||||||
|
"episode": entity.epi_queue,
|
||||||
|
"source": "anilife"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
task = ModuleQueue.add_download(**gdm_options)
|
||||||
|
if task:
|
||||||
|
logger.info(f"Delegated Anilife download to GDM: {entity.filename}")
|
||||||
|
return "enqueue_gdm_success"
|
||||||
|
|
||||||
|
# 5. Fallback to FfmpegQueue if GDM not available
|
||||||
|
logger.warning("GDM Module not found, falling back to FfmpegQueue")
|
||||||
if db_entity is None:
|
if db_entity is None:
|
||||||
logger.debug(f"episode_info:: {episode_info}")
|
logger.debug(f"episode_info:: {episode_info}")
|
||||||
entity = AniLifeQueueEntity(P, self, episode_info)
|
entity = AniLifeQueueEntity(P, self, episode_info)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<div class="d-flex justify-content-start align-items-center gap-2 mb-4">
|
<div class="d-flex justify-content-start align-items-center gap-2 mb-4">
|
||||||
<button id="reset_btn" class="btn custom-btn btn-reset-queue"><i class="fa fa-refresh mr-2"></i> 초기화</button>
|
<button id="reset_btn" class="btn custom-btn btn-reset-queue"><i class="fa fa-refresh mr-2"></i> 초기화</button>
|
||||||
<button id="delete_completed_btn" class="btn custom-btn btn-delete-completed"><i class="fa fa-trash-o mr-2"></i> 완료 목록 삭제</button>
|
<button id="delete_completed_btn" class="btn custom-btn btn-delete-completed"><i class="fa fa-trash-o mr-2"></i> 완료 목록 삭제</button>
|
||||||
<button id="go_ffmpeg_btn" class="btn custom-btn btn-ffmpeg"><i class="fa fa-film mr-2"></i> Go FFMPEG</button>
|
<button id="go_gdm_btn" class="btn custom-btn btn-gdm"><i class="fa fa-download mr-2"></i> Go GDM</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id='page1'></div>
|
<div id='page1'></div>
|
||||||
@@ -329,9 +329,9 @@
|
|||||||
queue_command(send_data)
|
queue_command(send_data)
|
||||||
});
|
});
|
||||||
|
|
||||||
$("body").on('click', '#go_ffmpeg_btn', function (e) {
|
$("body").on('click', '#go_gdm_btn', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
window.location.href = '/ffmpeg/list';
|
window.location.href = '/gommi_downloader_manager/queue/list';
|
||||||
});
|
});
|
||||||
|
|
||||||
function queue_command(data) {
|
function queue_command(data) {
|
||||||
@@ -412,8 +412,8 @@
|
|||||||
.btn-delete-completed { background: rgba(239, 68, 68, 0.2); border-color: rgba(239, 68, 68, 0.3); }
|
.btn-delete-completed { background: rgba(239, 68, 68, 0.2); border-color: rgba(239, 68, 68, 0.3); }
|
||||||
.btn-delete-completed:hover { background: rgba(239, 68, 68, 0.4); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3); }
|
.btn-delete-completed:hover { background: rgba(239, 68, 68, 0.4); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3); }
|
||||||
|
|
||||||
.btn-ffmpeg { background: rgba(139, 92, 246, 0.2); border-color: rgba(139, 92, 246, 0.3); }
|
.btn-gdm { background: rgba(56, 189, 248, 0.2); border-color: rgba(56, 189, 248, 0.3); }
|
||||||
.btn-ffmpeg:hover { background: rgba(139, 92, 246, 0.4); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(139, 92, 246, 0.3); }
|
.btn-gdm:hover { background: rgba(56, 189, 248, 0.4); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(56, 189, 248, 0.3); }
|
||||||
|
|
||||||
/* Action buttons inside table */
|
/* Action buttons inside table */
|
||||||
.action-btn {
|
.action-btn {
|
||||||
|
|||||||
Reference in New Issue
Block a user