v0.5.5: Automate Zendriver system browser installation and dependency check

This commit is contained in:
2026-01-03 20:52:39 +09:00
parent cce87118c4
commit a24aa76459
3 changed files with 187 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
title: "애니 다운로더" title: "애니 다운로더"
version: "0.5.4" version: "0.5.5"
package_name: "anime_downloader" package_name: "anime_downloader"
developer: "projectdx" developer: "projectdx"
description: "anime downloader" description: "anime downloader"

View File

@@ -229,6 +229,85 @@ class LogicOhli24(AnimeModuleBase):
except Exception as e: except Exception as e:
return {"success": False, "error": str(e)} return {"success": False, "error": str(e)}
@classmethod
def system_check(cls) -> Dict[str, Any]:
"""시스템 의존성 확인 (브라우저 등)"""
import shutil
import platform
res = {
"browser_found": False,
"browser_path": "",
"os": platform.system(),
"dist": "",
"can_install": False,
"install_cmd": "apt-get update && apt-get install -y chromium-browser"
}
# 브라우저 찾기
manual_path = P.ModelSetting.get("ohli24_zendriver_browser_path")
if manual_path and os.path.exists(manual_path):
res["browser_found"] = True
res["browser_path"] = manual_path
else:
for cmd in ["google-chrome", "google-chrome-stable", "chromium-browser", "chromium"]:
found = shutil.which(cmd)
if found:
res["browser_found"] = True
res["browser_path"] = found
break
# OS 및 설치 가능 여부 확인
if res["os"] == "Linux":
try:
if os.path.exists("/etc/debian_version"):
res["dist"] = "debian/ubuntu"
res["can_install"] = True
except:
pass
return res
@classmethod
def install_system_browser(cls) -> Dict[str, Any]:
"""시스템 브라우저 자동 설치 (Ubuntu/Debian 전용)"""
import subprocess as sp
check = cls.system_check()
if not check["can_install"]:
return {"ret": "error", "msg": "자동 설치가 지원되지 않는 OS 환경입니다. 안내된 명령어를 터미널에서 직접 실행해 주세요."}
try:
logger.info("[Zendriver] Starting system browser installation...")
# apt-get update
sp.run(["apt-get", "update"], capture_output=True, text=True, timeout=300)
# apt-get install
process = sp.run(
["apt-get", "install", "-y", "chromium-browser"],
capture_output=True,
text=True,
timeout=600
)
if process.returncode == 0:
logger.info("[Zendriver] System browser installed successfully")
# 설치 후 다시 찾기
new_check = cls.system_check()
if new_check["browser_found"]:
P.ModelSetting.set("ohli24_zendriver_browser_path", new_check["browser_path"])
return {"ret": "success", "msg": "브라우저 설치 및 경로 설정이 완료되었습니다.", "path": new_check["browser_path"]}
return {"ret": "success", "msg": "설치는 완료되었으나 경로를 자동으로 찾지 못했습니다. 직접 입력해 주세요."}
else:
logger.error(f"[Zendriver] Installation failed: {process.stderr}")
return {"ret": "error", "msg": f"설치 중 오류가 발생했습니다: {process.stderr[:200]}"}
except sp.TimeoutExpired:
return {"ret": "error", "msg": "설치 시간이 초과되었습니다. 네트워크 상태를 확인하거나 터미널에서 직접 실행해 주세요."}
except Exception as e:
logger.error(f"[Zendriver] Install exception: {e}")
return {"ret": "error", "msg": f"설치 중 예외가 발생했습니다: {str(e)}"}
def __init__(self, P: Any) -> None: def __init__(self, P: Any) -> None:
self.name: str = name self.name: str = name
@@ -432,6 +511,12 @@ class LogicOhli24(AnimeModuleBase):
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
return jsonify({"error": str(e)}), 500 return jsonify({"error": str(e)}), 500
elif sub == "system_check":
return jsonify(self.system_check())
elif sub == "install_browser":
return jsonify(self.install_system_browser())
elif sub == "stream_video": elif sub == "stream_video":
# 비디오 스트리밍 (MP4 파일 직접 서빙) # 비디오 스트리밍 (MP4 파일 직접 서빙)
try: try:

View File

@@ -78,9 +78,37 @@
{{ macros.setting_buttons([['global_one_execute_btn', '1회 실행']], left='1회 실행' ) }} {{ macros.setting_buttons([['global_one_execute_btn', '1회 실행']], left='1회 실행' ) }}
<hr style="border-color: rgba(255,255,255,0.1);"> <hr style="border-color: rgba(255,255,255,0.1);">
{{ macros.setting_buttons([['global_reset_db_btn', 'DB 초기화']], left='DB정리' ) }} {{ macros.setting_buttons([['global_reset_db_btn', 'DB 초기화']], left='DB정리' ) }}
<hr style="border-color: rgba(255,255,255,0.1);">
<h5 class="text-info mb-3"><i class="bi bi-cpu-fill mr-2"></i>시스템 상태 및 의존성</h5>
<div id="system_check_result" class="mb-3 p-3 rounded" style="background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.05);">
<div class="d-flex align-items-center mb-2">
<span class="mr-2">Chromium/Chrome:</span>
<span id="browser_status_badge" class="badge badge-secondary">확인 중...</span>
</div>
<div id="browser_path_display" class="small text-muted mb-2" style="font-family: monospace;"></div>
<div id="install_guide_section" style="display:none;">
<p class="small text-warning mb-2"><i class="bi bi-exclamation-triangle-fill mr-1"></i>브라우저가 발견되지 않았습니다. Zendriver 기능을 위해 설치가 필요합니다.</p>
<div id="auto_install_div" style="display:none;">
<button type="button" id="auto_install_btn" class="btn btn-sm btn-outline-info mb-2">
<i class="bi bi-download mr-1"></i>자동 설치 (Ubuntu/Docker)
</button>
</div>
<div class="mt-2">
<small class="d-block text-muted mb-1">수동 설치 명령어:</small>
<div class="input-group input-group-sm">
<input type="text" id="manual_install_cmd" class="form-control form-control-sm bg-dark border-secondary text-info" readonly value="apt-get update && apt-get install -y chromium-browser">
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" id="copy_cmd_btn"><i class="bi bi-clipboard"></i></button>
</div>
</div>
</div>
</div>
</div>
<hr style="border-color: rgba(255,255,255,0.1);"> <hr style="border-color: rgba(255,255,255,0.1);">
<h5 class="text-info mb-3"><i class="bi bi-browser-chrome mr-2"></i>Zendriver 설정</h5> <h5 class="text-info mb-3"><i class="bi bi-browser-chrome mr-2"></i>Zendriver 설정</h5>
{{ macros.setting_input_text('ohli24_zendriver_browser_path', '브라우저 경로', value=arg.get('ohli24_zendriver_browser_path', ''), desc=['Zendriver가 사용할 Chrome/Chromium 실행 파일 경로입니다.', 'Docker 환경에서 자동 탐지에 실패할 경우 직접 입력하세요.', '예: /usr/bin/chromium-browser']) }} {{ macros.setting_input_text('ohli24_zendriver_browser_path', '브라우저 경로', value=arg.get('ohli24_zendriver_browser_path', ''), desc=['Zendriver가 사용할 Chrome/Chromium 실행 파일 경로입니다.', '위의 시스템 상태에서 자동으로 찾은 경우 비워두셔도 됩니다 (수동 설정 시 우선 적용).']) }}
</div> </div>
{{ macros.m_tab_content_end() }} {{ macros.m_tab_content_end() }}
@@ -567,6 +595,78 @@ function escapeHtml(text) {
return div.innerHTML; return div.innerHTML;
} }
// ======================================
// 시스템 체크 및 브라우저 설치
// ======================================
function runSystemCheck() {
$.ajax({
url: '/' + package_name + '/ajax/' + sub + '/system_check',
type: 'POST',
success: function(ret) {
if (ret.browser_found) {
$('#browser_status_badge').removeClass('badge-secondary badge-danger').addClass('badge-success').text('발견됨');
$('#browser_path_display').text('경로: ' + ret.browser_path);
$('#install_guide_section').hide();
} else {
$('#browser_status_badge').removeClass('badge-secondary badge-success').addClass('badge-danger').text('미설치');
$('#browser_path_display').text('');
$('#install_guide_section').show();
$('#manual_install_cmd').val(ret.install_cmd);
if (ret.can_install) {
$('#auto_install_div').show();
} else {
$('#auto_install_div').hide();
}
}
}
});
}
// 자동 설치 버튼
$('#auto_install_btn').on('click', function() {
if (!confirm('시스템 브라우저 설치를 시작하시겠습니까?\n(Ubuntu/Debian 기반 도커 환경에서만 작동합니다)')) return;
var btn = $(this);
btn.prop('disabled', true).html('<i class="bi bi-arrow-repeat spin mr-1"></i>설치 중 (최대 10분 소요)...');
$.ajax({
url: '/' + package_name + '/ajax/' + sub + '/install_browser',
type: 'POST',
success: function(ret) {
if (ret.ret === 'success') {
$.notify(ret.msg, {type: 'success'});
if (ret.path) {
$('#ohli24_zendriver_browser_path').val(ret.path);
}
runSystemCheck();
} else {
$.notify(ret.msg, {type: 'danger'});
}
},
error: function() {
$.notify('설치 요청 중 오류가 발생했습니다.', {type: 'danger'});
},
complete: function() {
btn.prop('disabled', false).html('<i class="bi bi-download mr-1"></i>자동 설치 (Ubuntu/Docker)');
}
});
});
// 명령어 복사 버튼
$('#copy_cmd_btn').on('click', function() {
var copyText = document.getElementById("manual_install_cmd");
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand("copy");
$.notify('명령어가 복사되었습니다.', {type: 'info'});
});
// 초기 실행
$(document).ready(function() {
// Action 탭이 활성화될 때 체크 (또는 그냥 로딩 시 한 번)
runSystemCheck();
});
</script> </script>
{% endblock %} {% endblock %}