Files
anime_downloader/templates/anime_downloader_ohli24_queue.html

453 lines
16 KiB
HTML
Raw Normal View History

2022-10-29 17:21:14 +09:00
{% extends "base.html" %}
{% block content %}
<link rel="stylesheet" href="{{ url_for('.static', filename='css/mobile_custom.css') }}"/>
<link rel="stylesheet" href="{{ url_for('.static', filename='css/' ~ arg['sub'] ~ '.css') }}"/>
2022-10-29 17:21:14 +09:00
<div id="ohli24_queue_wrapper" class="ohli24-common-wrapper container-fluid mt-4 content-cloak ohli24-queue-page">
<div class="glass-card p-4">
<!-- 헤더 버튼 그룹 -->
<div class="ohli24-header">
<div class="ohli24-header-left">
<div class="ohli24-icon-box">
<i class="bi bi-cloud-download-fill text-primary" style="font-size: 1.5rem;"></i>
</div>
<div>
<h3 class="ohli24-header-title">다운로드 큐</h3>
<span class="ohli24-header-subtitle"><span id="queue_count" class="text-info font-weight-bold">0</span>개의 항목</span>
</div>
</div>
<div class="ohli24-header-right d-flex flex-wrap">
<button id="reset_btn" class="btn-modern btn-modern-danger mr-2 mb-2">
<i class="bi bi-arrow-counterclockwise mr-1"></i> 전체 초기화
</button>
<button id="delete_completed_btn" class="btn-modern btn-modern-warning mr-2 mb-2">
<i class="bi bi-trash mr-1"></i> 완료 항목 삭제
</button>
</div>
</div>
<!-- 다운로드 목록 -->
<div id="download_list_div" class="queue-list d-flex flex-column gap-3"></div>
<!-- 빈 상태 표시 -->
<div id="empty_state" class="empty-state d-flex flex-column align-items-center justify-content-center py-5" style="display: none; min-height: 300px;">
<div class="empty-icon-wrapper mb-4">
<i class="bi bi-inbox-fill text-muted opacity-20" style="font-size: 5rem;"></i>
</div>
<h4 class="text-white-50 font-weight-bold mb-2">다운로드 대기 항목 없음</h4>
<p class="text-muted mb-0">새로운 에피소드를 추가하면 이곳에 실시간으로 나타납니다.</p>
<div class="mt-4">
<span class="badge badge-pill badge-dark py-2 px-3" style="background: rgba(255,255,255,0.05); color: #64748b; font-weight: 500;">
<i class="bi bi-info-circle mr-1"></i> 에피소드 목록에서 '다운로드'를 눌러보세요
</span>
</div>
</div>
</div>
</div>
2022-11-30 23:03:41 +09:00
<style>
/* Premium Glassmorphism UI */
.ohli24-queue-page {
animation: fadeIn 0.5s ease-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.icon-box {
width: 48px;
height: 48px;
background: rgba(59, 130, 246, 0.1);
border-radius: 14px;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid rgba(59, 130, 246, 0.2);
}
/* Modern Buttons */
.btn-modern {
border: none;
border-radius: 12px;
padding: 10px 18px;
font-weight: 600;
font-size: 0.9rem;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
display: inline-flex;
align-items: center;
justify-content: center;
color: white;
text-transform: none;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.btn-modern:hover {
transform: translateY(-2px);
box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
filter: brightness(1.1);
}
.btn-modern:active {
transform: translateY(0);
}
.btn-modern-danger { background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%); }
.btn-modern-warning { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.btn-modern-info { background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%); }
.btn-modern-secondary { background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); }
/* Queue Items */
.queue-item {
background: rgba(0, 0, 0, 0.2);
border: 1px solid rgba(255, 255, 255, 0.05);
border-radius: 16px;
padding: 16px;
transition: all 0.3s ease;
display: flex;
align-items: center;
gap: 15px;
}
.queue-item:hover {
background: rgba(255, 255, 255, 0.03);
border-color: rgba(255, 255, 255, 0.1);
transform: translateX(4px);
}
.item-number {
font-family: 'JetBrains Mono', monospace;
font-weight: 700;
color: #64748b;
font-size: 1.1rem;
min-width: 40px;
}
.item-info {
flex: 1;
min-width: 0;
}
.item-filename {
color: #f1f5f9;
font-weight: 600;
font-size: 0.95rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-bottom: 4px;
}
.item-meta {
font-size: 0.8rem;
color: #94a3b8;
}
/* Modern Progress Bar */
.progress-container {
flex: 1.5;
min-width: 150px;
}
.progress-wrapper {
position: relative;
height: 28px;
background: rgba(0, 0, 0, 0.3);
border-radius: 14px;
overflow: hidden;
border: 1px solid rgba(255, 255, 255, 0.05);
}
.progress-bar {
height: 100%;
border-radius: 14px;
transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
}
.status-waiting { background: linear-gradient(90deg, #64748b, #475569); }
.status-downloading {
background: linear-gradient(90deg, #3b82f6, #2563eb);
box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}
.status-completed {
background: linear-gradient(90deg, #10b981, #059669);
box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}
.status-failed { background: linear-gradient(90deg, #ef4444, #dc2626); }
.progress-label {
position: absolute;
top: 0; left: 0; width: 100%; height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.75rem;
font-weight: 700;
color: white;
text-shadow: 0 1px 2px rgba(0,0,0,0.5);
pointer-events: none;
padding: 0 10px;
white-space: nowrap;
overflow: hidden;
}
/* Actions */
.cancel-btn {
background: rgba(239, 68, 68, 0.1);
border: 1px solid rgba(239, 68, 68, 0.2);
color: #f87171;
padding: 6px 12px;
border-radius: 8px;
font-size: 0.8rem;
font-weight: 600;
transition: all 0.2s;
cursor: pointer;
}
.cancel-btn:hover {
background: #ef4444;
color: white;
}
@media (max-width: 992px) {
.queue-item { flex-direction: column; align-items: stretch; }
.progress-container { flex: none; width: 100%; }
.item-actions { display: flex; justify-content: flex-end; }
}
.empty-state {
animation: fadeIn 0.8s ease-out;
}
.empty-icon-wrapper i {
display: inline-block;
transition: transform 0.3s ease;
}
.empty-state:hover .empty-icon-wrapper i {
transform: translateY(-10px);
color: #3b82f6 !important;
opacity: 0.4 !important;
}
</style>
2022-11-30 23:03:41 +09:00
<script src="{{ url_for('.static', filename='js/sjva_ui14.js') }}"></script>
<script type="text/javascript">
var package_name = "{{arg['package_name'] }}";
var sub = "{{arg['sub'] }}";
var current_data = null;
$(document).ready(function () {
// Force parent container to be fluid to allow full width
$("#main_container").removeClass("container").addClass("container-fluid");
// Smooth Load Trigger
setTimeout(function() {
$('.content-cloak, #menu_module_div, #menu_page_div').addClass('visible');
}, 100);
var socket = io.connect(window.location.href);
socket.on('on_start', (data) => {})
socket.on('start', function (data) {
2025-12-27 23:27:46 +09:00
on_start();
});
socket.on('list_refresh', function (data) {
on_start()
});
socket.on('status', function (data) {
on_status(data)
2022-11-30 23:03:41 +09:00
});
on_start();
var refreshIntervalId = setInterval(silentRefresh, 3000);
});
var current_list_length = 0;
var refreshIntervalId = null;
function silentRefresh() {
$.ajax({
url: '/' + package_name + '/ajax/' + sub + '/entity_list',
type: "POST",
cache: false,
global: false,
data: {},
dataType: "json",
success: function (data) {
// 목록 길이 변경 시 전체 다시 그리기
if (data.length !== current_list_length) {
current_list_length = data.length;
make_download_list(data);
} else {
// 진행률만 업데이트 (전체 다시 그리기 없이)
for (var i = 0; i < data.length; i++) {
var item = data[i];
var progressBar = document.getElementById("progress_" + item.entity_id);
if (progressBar) {
progressBar.style.width = item.ffmpeg_percent + '%';
var label = item.ffmpeg_status_kor;
if (item.ffmpeg_percent != 0) label += " (" + item.ffmpeg_percent + "%)";
if (item.current_speed) label += " " + item.current_speed;
var labelEl = document.getElementById("progress_" + item.entity_id + "_label");
if (labelEl) labelEl.innerHTML = label;
// 상태 클래스 업데이트
var statusClass = getStatusClass(item.ffmpeg_status_kor);
$(progressBar).removeClass('status-waiting status-downloading status-completed status-failed').addClass(statusClass);
}
}
}
var hasActive = false;
for (var i = 0; i < data.length; i++) {
if (data[i].ffmpeg_status_kor === '다운로드중' || data[i].ffmpeg_status_kor === '대기중' || data[i].ffmpeg_status_kor === '추출중') {
hasActive = true;
break;
2025-12-27 23:27:46 +09:00
}
}
if (!hasActive && refreshIntervalId) {
clearInterval(refreshIntervalId);
refreshIntervalId = null;
2022-11-30 23:03:41 +09:00
}
if (hasActive && !refreshIntervalId) {
refreshIntervalId = setInterval(silentRefresh, 2000);
}
}
});
}
2022-11-30 23:03:41 +09:00
function on_start() {
$.ajax({
url: '/' + package_name + '/ajax/' + sub + '/entity_list',
type: "POST",
cache: false,
data: {},
dataType: "json",
success: function (data) {
current_list_length = data.length;
make_download_list(data)
2022-11-30 23:03:41 +09:00
}
});
}
function on_status(data) {
var entity_id = data.entity_id;
var percent = data.ffmpeg_percent;
var status_kor = data.ffmpeg_status_kor;
var speed = data.current_speed;
var progressBar = document.getElementById("progress_" + entity_id);
if (progressBar != null) {
// Update percentage and label
progressBar.style.width = percent + '%';
var label = status_kor;
if (percent != 0) label += " (" + percent + "%)";
if (speed) label += " " + speed;
document.getElementById("progress_" + entity_id + "_label").innerHTML = label;
// Real-time status class (color) update
var statusClass = getStatusClass(status_kor);
$(progressBar).removeClass('status-waiting status-downloading status-completed status-failed').addClass(statusClass);
// Auto-refresh list if completed to show 'Watch' button or other actions
if (status_kor === '완료' || status_kor === 'completed') {
// Throttle refresh to avoid flickering if multiple complete
if (window.statusRefreshTimeout) clearTimeout(window.statusRefreshTimeout);
window.statusRefreshTimeout = setTimeout(on_start, 1000);
}
2022-11-30 23:03:41 +09:00
}
}
2022-11-30 23:03:41 +09:00
function getStatusClass(status) {
if (status === '다운로드중') return 'status-downloading';
if (status === '완료' || status === 'completed') return 'status-completed';
if (status === '실패' || status === 'FAILED') return 'status-failed';
return 'status-waiting';
}
2022-11-30 23:03:41 +09:00
function make_download_list(data) {
document.getElementById('queue_count').textContent = data.length;
if (data.length === 0) {
document.getElementById('download_list_div').style.display = 'none';
document.getElementById('empty_state').style.display = 'flex';
return;
}
document.getElementById('download_list_div').style.display = 'flex';
document.getElementById('empty_state').style.display = 'none';
var str = '';
for (var i in data) {
var item = data[i];
var statusClass = getStatusClass(item.ffmpeg_status_kor);
var label = item.ffmpeg_status_kor;
if (item.ffmpeg_percent != 0) {
label += ' (' + item.ffmpeg_percent + '%)';
2022-11-30 23:03:41 +09:00
}
str += '<div class="queue-item">';
str += '<div class="item-number">#' + item.entity_id + '</div>';
str += '<div class="item-info">';
str += '<div class="item-filename">' + (item.filename || '파일명 없음') + '</div>';
str += '<div class="item-meta">';
str += '<span class="item-time"><i class="fa fa-clock-o"></i> ' + item.created_time + '</span>';
str += '</div>';
str += '</div>';
str += '<div class="progress-container">';
str += '<div class="progress-wrapper">';
str += '<div id="progress_' + item.entity_id + '" class="progress-bar ' + statusClass + '" style="width: ' + item.ffmpeg_percent + '%;"></div>';
str += '<span id="progress_' + item.entity_id + '_label" class="progress-label">' + label + '</span>';
str += '</div>';
str += '</div>';
str += '<div class="item-actions">';
str += '<button class="cancel-btn" data-id="' + item.entity_id + '" onclick="cancelItem(' + item.entity_id + ')"><i class="fa fa-times"></i> 취소</button>';
str += '</div>';
str += '</div>';
2022-11-30 23:03:41 +09:00
}
document.getElementById("download_list_div").innerHTML = str;
}
2022-11-30 23:03:41 +09:00
function cancelItem(entity_id) {
queue_command({'command': 'cancel', 'entity_id': entity_id});
}
2022-11-30 23:03:41 +09:00
$("body").on('click', '#reset_btn', function (e) {
e.preventDefault();
if (!confirm('정말 큐를 초기화하시겠습니까?')) return;
queue_command({'command': 'reset', 'entity_id': -1});
});
2022-11-30 23:03:41 +09:00
$("body").on('click', '#delete_completed_btn', function (e) {
e.preventDefault();
queue_command({'command': 'delete_completed', 'entity_id': -1});
});
2022-11-30 23:03:41 +09:00
function queue_command(data) {
$.ajax({
url: '/' + package_name + '/ajax/' + sub + '/queue_command',
type: "POST",
cache: false,
data: data,
dataType: "json",
success: function (ret) {
if (ret.ret == 'notify') {
$.notify('<strong>' + ret.log + '</strong>', {type: 'warning'});
2022-11-30 23:03:41 +09:00
}
on_start();
}
2022-11-30 23:03:41 +09:00
});
2023-01-26 15:33:59 +09:00
}
$("body").on('click', '#go_ffmpeg_btn', function (e) {
e.preventDefault();
$(location).attr('href', '/ffmpeg')
});
</script>
</script>
2022-11-30 23:03:41 +09:00
{% endblock %}