reformatting
This commit is contained in:
@@ -1,96 +1,96 @@
|
||||
{% macro setting_select2(id, title, options, col='9', desc=None, value=None) %}
|
||||
{{ macros.setting_top(title) }}
|
||||
<div class="input-group col-sm-{{ col }}">
|
||||
<select id="{{ id }}" name="{{ id }}" class="form-control form-control-sm">
|
||||
{% set ns = namespace(optgroup=none) %}
|
||||
{% for item in options %}
|
||||
{% if ns.optgroup != item[2] %}
|
||||
{% if ns.optgroup is not none %}
|
||||
</optgroup>
|
||||
{% endif %}
|
||||
{% if item[2] is not none %}
|
||||
<optgroup label="{{ item[2] }}">
|
||||
{% endif %}
|
||||
{% set ns.optgroup = item[2] %}
|
||||
{% endif %}
|
||||
{% if value is not none and value == item[0] %}
|
||||
<option value="{{ item[0] }}" selected>{{ item[1] }}</option>
|
||||
{% else %}
|
||||
<option value="{{ item[0] }}">{{ item[1] }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if ns.optgroup is not none %}
|
||||
</optgroup>
|
||||
{% endif %}
|
||||
</select>
|
||||
</div>
|
||||
{{ macros.setting_bottom(desc) }}
|
||||
{{ macros.setting_top(title) }}
|
||||
<div class="input-group col-sm-{{ col }}">
|
||||
<select id="{{ id }}" name="{{ id }}" class="form-control form-control-sm">
|
||||
{% set ns = namespace(optgroup=none) %}
|
||||
{% for item in options %}
|
||||
{% if ns.optgroup != item[2] %}
|
||||
{% if ns.optgroup is not none %}
|
||||
</optgroup>
|
||||
{% endif %}
|
||||
{% if item[2] is not none %}
|
||||
<optgroup label="{{ item[2] }}">
|
||||
{% endif %}
|
||||
{% set ns.optgroup = item[2] %}
|
||||
{% endif %}
|
||||
{% if value is not none and value == item[0] %}
|
||||
<option value="{{ item[0] }}" selected>{{ item[1] }}</option>
|
||||
{% else %}
|
||||
<option value="{{ item[0] }}">{{ item[1] }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if ns.optgroup is not none %}
|
||||
</optgroup>
|
||||
{% endif %}
|
||||
</select>
|
||||
</div>
|
||||
{{ macros.setting_bottom(desc) }}
|
||||
{% endmacro %}
|
||||
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
|
||||
<div>
|
||||
{{ macros.setting_input_text('url', 'URL', placeholder='http:// 주소', desc='유튜브, 네이버TV 등 동영상 주소') }}
|
||||
{{ macros.setting_input_text('filename', '파일명', value=arg['file_name'], desc='템플릿 규칙은 https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template 참고') }}
|
||||
{{ macros.setting_select('preset', '동영상 포맷 프리셋', arg['preset_list'], col='3') }}
|
||||
{{ macros.setting_input_text('format', '동영상 포맷', desc=['포맷 지정은 https://github.com/ytdl-org/youtube-dl/blob/master/README.md#format-selection 참고', '빈칸으로 두면 최고 화질로 다운로드합니다.']) }}
|
||||
{{ setting_select2('postprocessor', '후처리', arg['postprocessor_list'], col='3', desc='다운로드 후 FFmpeg로 후처리합니다.') }}
|
||||
{{ macros.setting_button([['download_start', '다운로드']]) }}
|
||||
{{ macros.setting_input_text('url', 'URL', placeholder='http:// 주소', desc='유튜브, 네이버TV 등 동영상 주소') }}
|
||||
{{ macros.setting_input_text('filename', '파일명', value=arg['file_name'], desc='템플릿 규칙은 https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template 참고') }}
|
||||
{{ macros.setting_select('preset', '동영상 포맷 프리셋', arg['preset_list'], col='3') }}
|
||||
{{ macros.setting_input_text('format', '동영상 포맷', desc=['포맷 지정은 https://github.com/ytdl-org/youtube-dl/blob/master/README.md#format-selection 참고', '빈칸으로 두면 최고 화질로 다운로드합니다.']) }}
|
||||
{{ setting_select2('postprocessor', '후처리', arg['postprocessor_list'], col='3', desc='다운로드 후 FFmpeg로 후처리합니다.') }}
|
||||
{{ macros.setting_button([['download_start', '다운로드']]) }}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
const package_name = '{{ arg["package_name"] }}';
|
||||
"use strict";
|
||||
const package_name = '{{ arg["package_name"] }}';
|
||||
|
||||
$(function () {
|
||||
// 프리셋 변경
|
||||
$('#preset').change(function () {
|
||||
if ($(this).val() === '_custom') {
|
||||
return;
|
||||
}
|
||||
$('#format').val($(this).val());
|
||||
});
|
||||
$('#format').change(function () {
|
||||
$('#preset').val('_custom');
|
||||
});
|
||||
$(function () {
|
||||
// 프리셋 변경
|
||||
$('#preset').change(function () {
|
||||
if ($(this).val() === '_custom') {
|
||||
return;
|
||||
}
|
||||
$('#format').val($(this).val());
|
||||
});
|
||||
$('#format').change(function () {
|
||||
$('#preset').val('_custom');
|
||||
});
|
||||
|
||||
// 후처리 변경
|
||||
$('#postprocessor').change(function () {
|
||||
if ($(this).find($('option[value="' + $(this).val() + '"]')).parent().attr('label') === '오디오 추출') {
|
||||
$('#preset').val('bestaudio/best').change();
|
||||
}
|
||||
});
|
||||
// 후처리 변경
|
||||
$('#postprocessor').change(function () {
|
||||
if ($(this).find($('option[value="' + $(this).val() + '"]')).parent().attr('label') === '오디오 추출') {
|
||||
$('#preset').val('bestaudio/best').change();
|
||||
}
|
||||
});
|
||||
|
||||
// 다운로드
|
||||
$('#download_start').click(function () {
|
||||
let url = $('#url').val();
|
||||
if (url.startsWith('http') === false) {
|
||||
$.notify('<strong>URL을 입력하세요.</strong>', {
|
||||
type: 'warning'
|
||||
});
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url: '/' + package_name + '/ajax/download',
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
data: {
|
||||
url: url,
|
||||
filename: $('#filename').val(),
|
||||
format: $('#format').val(),
|
||||
postprocessor: $('#postprocessor').val()
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function () {
|
||||
$.notify('<strong>분석중..</strong>', {
|
||||
type: 'info'
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
// 다운로드
|
||||
$('#download_start').click(function () {
|
||||
let url = $('#url').val();
|
||||
if (url.startsWith('http') === false) {
|
||||
$.notify('<strong>URL을 입력하세요.</strong>', {
|
||||
type: 'warning'
|
||||
});
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url: '/' + package_name + '/ajax/download',
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
data: {
|
||||
url: url,
|
||||
filename: $('#filename').val(),
|
||||
format: $('#format').val(),
|
||||
postprocessor: $('#postprocessor').val()
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function () {
|
||||
$.notify('<strong>분석중..</strong>', {
|
||||
type: 'info'
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -2,162 +2,165 @@
|
||||
{% block content %}
|
||||
|
||||
<style>
|
||||
.row > div {
|
||||
padding-top: 3px;
|
||||
padding-bottom: 3px;
|
||||
}
|
||||
.row {
|
||||
align-items: center;
|
||||
word-break: break-all;
|
||||
}
|
||||
.row > div:nth-child(odd) {
|
||||
text-align: right;
|
||||
}
|
||||
.row > div:nth-child(even) {
|
||||
text-align: left;
|
||||
}
|
||||
.row > div {
|
||||
padding-top: 3px;
|
||||
padding-bottom: 3px;
|
||||
}
|
||||
|
||||
.row {
|
||||
align-items: center;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.row > div:nth-child(odd) {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.row > div:nth-child(even) {
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
|
||||
<table id="result_table" class="table table-sm tableRowHover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 5%">IDX</th>
|
||||
<th style="width: 8%">Plugin</th>
|
||||
<th style="width: 10%">시작시간</th>
|
||||
<th style="width: 10%">타입</th>
|
||||
<th style="width: 28%">제목</th>
|
||||
<th style="width: 8%">상태</th>
|
||||
<th style="width: 15%">진행률</th>
|
||||
<th style="width: 8%">진행시간</th>
|
||||
<th style="width: 8%">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="list"></tbody>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 5%">IDX</th>
|
||||
<th style="width: 8%">Plugin</th>
|
||||
<th style="width: 10%">시작시간</th>
|
||||
<th style="width: 10%">타입</th>
|
||||
<th style="width: 28%">제목</th>
|
||||
<th style="width: 8%">상태</th>
|
||||
<th style="width: 15%">진행률</th>
|
||||
<th style="width: 8%">진행시간</th>
|
||||
<th style="width: 8%">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="list"></tbody>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
const package_name = '{{ arg["package_name"] }}';
|
||||
"use strict";
|
||||
const package_name = '{{ arg["package_name"] }}';
|
||||
|
||||
$(function () {
|
||||
let socket = io.connect(location.origin + '/' + package_name);
|
||||
$(function () {
|
||||
let socket = io.connect(location.origin + '/' + package_name);
|
||||
|
||||
socket.on('add', function (data) {
|
||||
$('#list').append(make_item(data));
|
||||
});
|
||||
socket.on('add', function (data) {
|
||||
$('#list').append(make_item(data));
|
||||
});
|
||||
|
||||
socket.on('status', function (data) {
|
||||
status_html(data);
|
||||
});
|
||||
socket.on('status', function (data) {
|
||||
status_html(data);
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: '/' + package_name + '/ajax/list',
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
data: { },
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
let str = '';
|
||||
for (let i of data) {
|
||||
str += make_item(i);
|
||||
}
|
||||
$('#list').html(str);
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: '/' + package_name + '/ajax/list',
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
data: {},
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
let str = '';
|
||||
for (let i of data) {
|
||||
str += make_item(i);
|
||||
}
|
||||
$('#list').html(str);
|
||||
}
|
||||
});
|
||||
|
||||
$('#list').on('click', '.youtube-dl_stop', function () {
|
||||
let index = $(this).data('index');
|
||||
$.ajax({
|
||||
url: '/' + package_name + '/ajax/stop',
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
data: {
|
||||
index: index
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function () {
|
||||
location.reload(); // 새로고침
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
$('#list').on('click', '.youtube-dl_stop', function () {
|
||||
let index = $(this).data('index');
|
||||
$.ajax({
|
||||
url: '/' + package_name + '/ajax/stop',
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
data: {
|
||||
index: index
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function () {
|
||||
location.reload(); // 새로고침
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
function make_item(data) {
|
||||
let str = `<tr id="item_${data.index}" aria-expanded="true" style="cursor: pointer" data-toggle="collapse" data-target="#collapse_${data.index}">`;
|
||||
str += get_item(data);
|
||||
str += '</tr>';
|
||||
str += `<tr id="collapse_${data.index}" class="collapse tableRowHoverOff" style="cursor: pointer">`;
|
||||
str += '<td colspan="9">';
|
||||
str += `<div id="detail_${data.index}">`;
|
||||
str += get_detail(data);
|
||||
str += '</div>';
|
||||
str += '</td>';
|
||||
str += '</tr>';
|
||||
return str;
|
||||
}
|
||||
function make_item(data) {
|
||||
let str = `<tr id="item_${data.index}" aria-expanded="true" style="cursor: pointer" data-toggle="collapse" data-target="#collapse_${data.index}">`;
|
||||
str += get_item(data);
|
||||
str += '</tr>';
|
||||
str += `<tr id="collapse_${data.index}" class="collapse tableRowHoverOff" style="cursor: pointer">`;
|
||||
str += '<td colspan="9">';
|
||||
str += `<div id="detail_${data.index}">`;
|
||||
str += get_detail(data);
|
||||
str += '</div>';
|
||||
str += '</td>';
|
||||
str += '</tr>';
|
||||
return str;
|
||||
}
|
||||
|
||||
function get_item(data) {
|
||||
let str = `<td>${data.index + 1}</td>`;
|
||||
str += `<td>${data.plugin}</td>`;
|
||||
str += `<td>${data.start_time}</td>`;
|
||||
str += `<td>${data.extractor}</td>`;
|
||||
str += `<td>${data.title}</td>`;
|
||||
str += `<td>${data.status_ko}</td>`;
|
||||
let visi = 'hidden';
|
||||
if (parseInt(data.percent) > 0 && data.status_str !== 'STOP') {
|
||||
visi = 'visible';
|
||||
}
|
||||
str += `<td><div class="progress"><div class="progress-bar" style="visibility: ${visi}; width: ${data.percent}%">${data.percent}%</div></div></td>`;
|
||||
str += `<td>${data.download_time}</td>`;
|
||||
str += '<td class="tableRowHoverOff">';
|
||||
if (data.status_str === 'START' || data.status_str === 'DOWNLOADING' || data.status_str === 'FINISHED') {
|
||||
str += `<button class="align-middle btn btn-outline-danger btn-sm youtube-dl_stop" data-index="${data.index}">중지</button>`;
|
||||
}
|
||||
str += '</td>';
|
||||
return str;
|
||||
}
|
||||
function get_item(data) {
|
||||
let str = `<td>${data.index + 1}</td>`;
|
||||
str += `<td>${data.plugin}</td>`;
|
||||
str += `<td>${data.start_time}</td>`;
|
||||
str += `<td>${data.extractor}</td>`;
|
||||
str += `<td>${data.title}</td>`;
|
||||
str += `<td>${data.status_ko}</td>`;
|
||||
let visi = 'hidden';
|
||||
if (parseInt(data.percent) > 0 && data.status_str !== 'STOP') {
|
||||
visi = 'visible';
|
||||
}
|
||||
str += `<td><div class="progress"><div class="progress-bar" style="visibility: ${visi}; width: ${data.percent}%">${data.percent}%</div></div></td>`;
|
||||
str += `<td>${data.download_time}</td>`;
|
||||
str += '<td class="tableRowHoverOff">';
|
||||
if (data.status_str === 'START' || data.status_str === 'DOWNLOADING' || data.status_str === 'FINISHED') {
|
||||
str += `<button class="align-middle btn btn-outline-danger btn-sm youtube-dl_stop" data-index="${data.index}">중지</button>`;
|
||||
}
|
||||
str += '</td>';
|
||||
return str;
|
||||
}
|
||||
|
||||
function get_detail(data) {
|
||||
let str = info_html('URL', data.url, data.url);
|
||||
str += info_html('업로더', data.uploader, data.uploader_url);
|
||||
str += info_html('임시폴더', data.temp_path);
|
||||
str += info_html('저장폴더', data.save_path);
|
||||
str += info_html('종료시간', data.end_time);
|
||||
if (data.status_str === 'DOWNLOADING') {
|
||||
str += info_html('', '<b>현재 다운로드 중인 파일에 대한 정보</b>');
|
||||
str += info_html('파일명', data.filename);
|
||||
str += info_html('진행률(current/total)', `${data.percent}% (${data.downloaded_bytes_str} / ${data.total_bytes_str})`);
|
||||
str += info_html('남은 시간', `${data.eta}초`);
|
||||
str += info_html('다운 속도', data.speed_str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
function get_detail(data) {
|
||||
let str = info_html('URL', data.url, data.url);
|
||||
str += info_html('업로더', data.uploader, data.uploader_url);
|
||||
str += info_html('임시폴더', data.temp_path);
|
||||
str += info_html('저장폴더', data.save_path);
|
||||
str += info_html('종료시간', data.end_time);
|
||||
if (data.status_str === 'DOWNLOADING') {
|
||||
str += info_html('', '<b>현재 다운로드 중인 파일에 대한 정보</b>');
|
||||
str += info_html('파일명', data.filename);
|
||||
str += info_html('진행률(current/total)', `${data.percent}% (${data.downloaded_bytes_str} / ${data.total_bytes_str})`);
|
||||
str += info_html('남은 시간', `${data.eta}초`);
|
||||
str += info_html('다운 속도', data.speed_str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function info_html(left, right, option) {
|
||||
let str = '<div class="row">';
|
||||
let link = (left === 'URL' || left === '업로더');
|
||||
str += '<div class="col-sm-2">';
|
||||
str += `<b>${left}</b>`;
|
||||
str += '</div>';
|
||||
str += '<div class="col-sm-10">';
|
||||
str += '<div class="input-group col-sm-9">';
|
||||
str += '<span class="text-left" style="padding-left: 10px; padding-top: 3px">';
|
||||
if (link) {
|
||||
str += `<a href="${option}" target="_blank">`;
|
||||
}
|
||||
str += right;
|
||||
if (link) {
|
||||
str += '</a>';
|
||||
}
|
||||
str += '</span></div></div></div>';
|
||||
return str;
|
||||
}
|
||||
function info_html(left, right, option) {
|
||||
let str = '<div class="row">';
|
||||
let link = (left === 'URL' || left === '업로더');
|
||||
str += '<div class="col-sm-2">';
|
||||
str += `<b>${left}</b>`;
|
||||
str += '</div>';
|
||||
str += '<div class="col-sm-10">';
|
||||
str += '<div class="input-group col-sm-9">';
|
||||
str += '<span class="text-left" style="padding-left: 10px; padding-top: 3px">';
|
||||
if (link) {
|
||||
str += `<a href="${option}" target="_blank">`;
|
||||
}
|
||||
str += right;
|
||||
if (link) {
|
||||
str += '</a>';
|
||||
}
|
||||
str += '</span></div></div></div>';
|
||||
return str;
|
||||
}
|
||||
|
||||
function status_html(data) {
|
||||
$('#item_' + data.index).html(get_item(data));
|
||||
$('#detail_' + data.index).html(get_detail(data));
|
||||
}
|
||||
function status_html(data) {
|
||||
$('#item_' + data.index).html(get_item(data));
|
||||
$('#detail_' + data.index).html(get_detail(data));
|
||||
}
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
{% block content %}
|
||||
|
||||
<div>
|
||||
{{ macros.setting_input_text('youtube_dl_version', 'youtube-dl 버전', value=arg['youtube_dl_version']) }}
|
||||
<form id="setting">
|
||||
{{ macros.setting_input_text('temp_path', '임시 폴더', value=arg['temp_path'], placeholder='임시 폴더 경로', desc='다운로드 파일이 임시로 저장될 폴더 입니다.') }}
|
||||
{{ macros.setting_input_text('save_path', '저장 폴더', value=arg['save_path'], placeholder='저장 폴더 경로', desc='정상적으로 완료된 파일이 이동할 폴더 입니다.') }}
|
||||
{{ macros.setting_input_text('default_filename', '기본 파일명', value=arg['default_filename'], placeholder='저장 폴더 경로', desc=['템플릿 규칙은 https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template 참고', '기본값은 "%(title)s-%(id)s.%(ext)s"입니다.']) }}
|
||||
{{ macros.setting_input_text('proxy', '프록시', value=arg['proxy'], placeholder='프록시 주소', desc=['HTTP/HTTPS/SOCKS를 지원합니다. 예) socks5://127.0.0.1:1080/', '빈칸으로 두면 프록시를 사용하지 않습니다.']) }}
|
||||
{{ macros.setting_checkbox('activate_cors', 'CORS 허용', value=arg['activate_cors'], desc='API로의 크로스 도메인 요청을 허용합니다. 설정 저장 후 재시작이 필요합니다.') }}
|
||||
{{ macros.setting_button([['global_setting_save_btn', '저장']]) }}
|
||||
</form>
|
||||
{{ macros.setting_input_text('youtube_dl_version', 'youtube-dl 버전', value=arg['youtube_dl_version']) }}
|
||||
<form id="setting">
|
||||
{{ macros.setting_input_text('temp_path', '임시 폴더', value=arg['temp_path'], placeholder='임시 폴더 경로', desc='다운로드 파일이 임시로 저장될 폴더 입니다.') }}
|
||||
{{ macros.setting_input_text('save_path', '저장 폴더', value=arg['save_path'], placeholder='저장 폴더 경로', desc='정상적으로 완료된 파일이 이동할 폴더 입니다.') }}
|
||||
{{ macros.setting_input_text('default_filename', '기본 파일명', value=arg['default_filename'], placeholder='저장 폴더 경로', desc=['템플릿 규칙은 https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template 참고', '기본값은 "%(title)s-%(id)s.%(ext)s"입니다.']) }}
|
||||
{{ macros.setting_input_text('proxy', '프록시', value=arg['proxy'], placeholder='프록시 주소', desc=['HTTP/HTTPS/SOCKS를 지원합니다. 예) socks5://127.0.0.1:1080/', '빈칸으로 두면 프록시를 사용하지 않습니다.']) }}
|
||||
{{ macros.setting_checkbox('activate_cors', 'CORS 허용', value=arg['activate_cors'], desc='API로의 크로스 도메인 요청을 허용합니다. 설정 저장 후 재시작이 필요합니다.') }}
|
||||
{{ macros.setting_button([['global_setting_save_btn', '저장']]) }}
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
const package_name = '{{ arg["package_name"] }}';
|
||||
"use strict";
|
||||
const package_name = '{{ arg["package_name"] }}';
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user