2022-04-30 16:45:26 +09:00
|
|
|
let current_data = "";
|
|
|
|
|
let current_airing_data = "";
|
|
|
|
|
let code = "";
|
|
|
|
|
let div_visible = false;
|
|
|
|
|
let total_page = "";
|
|
|
|
|
|
|
|
|
|
const params = new Proxy(new URLSearchParams(window.location.search), {
|
2022-05-13 20:24:03 +09:00
|
|
|
get: (searchParams, prop) => searchParams.get(prop),
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// console.log('current_airing_data', current_airing_data);
|
|
|
|
|
|
2022-05-13 20:24:03 +09:00
|
|
|
// const get_airing_list = () => {
|
|
|
|
|
// $.ajax({
|
|
|
|
|
// url: "/" + package_name + "/ajax/airing_list",
|
|
|
|
|
// type: "GET",
|
|
|
|
|
// cache: false,
|
|
|
|
|
// dataType: "json",
|
|
|
|
|
// success: (ret) => {
|
|
|
|
|
// if (ret.ret == "success" && ret.episode != null) {
|
|
|
|
|
// current_airing_data = ret;
|
|
|
|
|
// total_page = ret.total_page;
|
|
|
|
|
// // console.log(ret)
|
|
|
|
|
// if (current_airing_data !== "") {
|
|
|
|
|
// make_airing_list(ret);
|
|
|
|
|
// div_visible = true;
|
|
|
|
|
// // console.log(div_visible)
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// $.notify("<strong>분석 실패</strong><br>" + ret.log, {
|
|
|
|
|
// type: "warning",
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// if (div_visible) {
|
|
|
|
|
// // {#$('#airing_list').toggle()#}
|
|
|
|
|
// }
|
|
|
|
|
// };
|
2022-04-30 16:45:26 +09:00
|
|
|
|
|
|
|
|
// console.log(div_visible)
|
|
|
|
|
|
|
|
|
|
$(document).on("click", "button.code-button", function (e) {
|
2022-05-13 20:24:03 +09:00
|
|
|
e.preventDefault();
|
|
|
|
|
// console.log('click')
|
|
|
|
|
// console.log('code to click:' + $(this).data("code"))
|
|
|
|
|
document.getElementById("code").value = $(this).data("code");
|
|
|
|
|
$("#code").val($(this).data("code"));
|
|
|
|
|
$("#airing_list").toggle();
|
|
|
|
|
code = document.getElementById("code").value;
|
|
|
|
|
document.getElementById("analysis_btn").click();
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
|
|
|
|
$(".code-button").tooltip();
|
|
|
|
|
|
|
|
|
|
$("body").on("click", "#analysis_btn", function (e) {
|
2022-05-13 20:24:03 +09:00
|
|
|
e.preventDefault();
|
|
|
|
|
if (document.getElementById("code").value !== "") {
|
|
|
|
|
code = document.getElementById("code").value;
|
|
|
|
|
}
|
|
|
|
|
// console.log('#analysis_btn >>> code::', code)
|
|
|
|
|
if (code === "") {
|
|
|
|
|
console.log("code 값을 입력해주세요.");
|
|
|
|
|
$.notify("<strong>code 값을 입력해주세요.</strong><br>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (current_data === "" || current_data.data.code !== code) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/" + package_name + "/ajax/analysis",
|
|
|
|
|
type: "POST",
|
|
|
|
|
cache: false,
|
|
|
|
|
data: {code: code},
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: function (ret) {
|
|
|
|
|
if (ret.ret == "success" && ret.data != null) {
|
|
|
|
|
console.log(ret)
|
|
|
|
|
// console.log('분석: %s', ret)
|
|
|
|
|
make_program(ret.data);
|
|
|
|
|
run_time = Math.floor(new Date().getTime() / 1000)
|
|
|
|
|
current_data = ret
|
|
|
|
|
} else {
|
|
|
|
|
$.notify("<strong>분석 실패</strong><br>" + ret.log, {
|
|
|
|
|
type: "warning",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
2022-05-13 20:24:03 +09:00
|
|
|
} else {
|
|
|
|
|
console.log('과도한 사이트 조회 금지')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("body").on("click", "#go_inflearn_btn", function (e) {
|
2022-05-13 20:24:03 +09:00
|
|
|
e.preventDefault();
|
|
|
|
|
window.open(inflearn_url, "_blank");
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function make_airing_list(data) {
|
2022-05-13 20:24:03 +09:00
|
|
|
let str = "";
|
|
|
|
|
let tmp = "";
|
|
|
|
|
|
2022-04-30 16:45:26 +09:00
|
|
|
tmp =
|
2022-05-13 20:24:03 +09:00
|
|
|
'<div id="exModal" class="form-inline" role="dialog" aria-hidden="true">';
|
|
|
|
|
tmp += "</div>";
|
|
|
|
|
str += m_hr_black();
|
|
|
|
|
// {#str += m_row_start(0);#}
|
|
|
|
|
// {##}
|
|
|
|
|
// {#str += m_row_end();#}
|
|
|
|
|
// {#str += m_hr_black();#}
|
|
|
|
|
str +=
|
|
|
|
|
'<div id="inner_airing" class="d-flex align-content-between flex-wrapd-flex align-content-between flex-wrap">';
|
|
|
|
|
for (i in data.episode) {
|
|
|
|
|
// {#str += m_row_start();#}
|
|
|
|
|
// {#tmp = '<div class="col-sm"><strong>' + data.episode[i].title+ '</strong>';#}
|
|
|
|
|
//
|
|
|
|
|
// {#tmp += '<br />'#}
|
|
|
|
|
// {#tmp += '' + data.episode[i].code + '</div>';#}
|
|
|
|
|
// {#str += m_col(12, tmp)#}
|
|
|
|
|
tmp =
|
|
|
|
|
'<div class="mx-1 mb-1"><button id="code_button" data-code="' +
|
|
|
|
|
data.episode[i].code +
|
|
|
|
|
'" type="button" class="btn btn-primary code-button bootstrap-tooltip" data-toggle="button" data-tooltip="true" aria-pressed="true" autocomplete="off" data-placement="top">' +
|
|
|
|
|
'<span data-tooltip-text="' +
|
|
|
|
|
data.episode[i].title +
|
|
|
|
|
'">' +
|
|
|
|
|
data.episode[i].code +
|
|
|
|
|
"</span></button></div>";
|
|
|
|
|
// {#if (i === 10) {#}
|
|
|
|
|
// {# tmp += '<div class="w-100"></div>'#}
|
|
|
|
|
str += tmp;
|
|
|
|
|
}
|
|
|
|
|
str += "</div>";
|
|
|
|
|
str += m_hr_black();
|
2022-04-30 16:45:26 +09:00
|
|
|
|
2022-05-13 20:24:03 +09:00
|
|
|
document.getElementById("airing_list").innerHTML = str;
|
2022-04-30 16:45:26 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function make_program(data) {
|
2022-05-13 20:24:03 +09:00
|
|
|
current_data = data;
|
|
|
|
|
// console.log('current_data:: ', data)
|
|
|
|
|
str = "";
|
|
|
|
|
tmp = '<div class="form-inline w-100">';
|
|
|
|
|
tmp += m_button("check_download_btn", "선택 다운로드 추가", []);
|
|
|
|
|
tmp += m_button("all_check_on_btn", "전체 선택", []);
|
|
|
|
|
tmp += m_button("all_check_off_btn", "전체 해제", []);
|
|
|
|
|
tmp +=
|
|
|
|
|
' <input id="new_title" name="new_title" class="form-control form-control-sm" value="' +
|
|
|
|
|
data.title +
|
|
|
|
|
'">';
|
|
|
|
|
tmp += "</div>";
|
|
|
|
|
tmp += '<div class="form-inline">';
|
|
|
|
|
tmp += m_button("apply_new_title_btn", "저장폴더명 변경", []);
|
|
|
|
|
// tmp +=
|
|
|
|
|
// ' <input id="new_season" name="new_season" class="form-control form-control-sm" value="' +
|
|
|
|
|
// data.season +
|
|
|
|
|
// '">';
|
|
|
|
|
// tmp += m_button("apply_new_season_btn", "시즌 변경 (숫자만 가능)", []);
|
|
|
|
|
// tmp += m_button("search_tvdb_btn", "TVDB", []);
|
|
|
|
|
tmp += m_button("add_whitelist", "스케쥴링 추가", []);
|
|
|
|
|
tmp += "</div>";
|
|
|
|
|
tmp = m_button_group(tmp);
|
|
|
|
|
str += tmp;
|
|
|
|
|
// program
|
|
|
|
|
str += m_hr_black();
|
|
|
|
|
str += m_row_start(0);
|
|
|
|
|
tmp = "";
|
|
|
|
|
if (data.poster_url != null)
|
|
|
|
|
tmp = '<img src="' + data.poster_url + '" class="img-fluid">';
|
|
|
|
|
str += m_col(3, tmp);
|
|
|
|
|
tmp = "";
|
|
|
|
|
tmp += m_row_start(0);
|
|
|
|
|
tmp += m_col(3, "제목", "right");
|
|
|
|
|
tmp += m_col(9, data.title);
|
|
|
|
|
tmp += m_row_end();
|
2022-04-30 16:45:26 +09:00
|
|
|
tmp += m_row_start(0);
|
2022-05-13 20:24:03 +09:00
|
|
|
tmp += m_col(3, "시즌", "right");
|
|
|
|
|
tmp += m_col(9, data.season);
|
2022-04-30 16:45:26 +09:00
|
|
|
tmp += m_row_end();
|
2022-05-13 20:24:03 +09:00
|
|
|
for (i in data.detail) {
|
|
|
|
|
tmp += m_row_start(0);
|
|
|
|
|
key = Object.keys(data.detail[i])[0];
|
|
|
|
|
value = data.detail[i][key];
|
|
|
|
|
tmp += m_col(3, key, "right");
|
|
|
|
|
tmp += m_col(9, value);
|
|
|
|
|
tmp += m_row_end();
|
|
|
|
|
}
|
2022-04-30 16:45:26 +09:00
|
|
|
|
2022-05-13 20:24:03 +09:00
|
|
|
str += m_col(9, tmp);
|
|
|
|
|
str += m_row_end();
|
2022-04-30 16:45:26 +09:00
|
|
|
|
2022-05-13 20:24:03 +09:00
|
|
|
str += m_hr_black();
|
|
|
|
|
for (i in data.episode) {
|
|
|
|
|
str += m_row_start();
|
|
|
|
|
// tmp = '<img src="' + data.episode[i].image + '" class="img-fluid">'
|
|
|
|
|
// str += m_col(3, tmp)
|
|
|
|
|
tmp = "<strong>" + data.episode[i].title + "</strong>";
|
|
|
|
|
tmp += "<br>";
|
|
|
|
|
tmp += data.episode[i].filename + "<br><p></p>";
|
2022-04-30 16:45:26 +09:00
|
|
|
|
2022-05-13 20:24:03 +09:00
|
|
|
tmp += '<div class="form-inline">';
|
|
|
|
|
tmp +=
|
|
|
|
|
'<input id="checkbox_' +
|
|
|
|
|
data.episode[i].data_id +
|
|
|
|
|
'" name="checkbox_' +
|
|
|
|
|
data.episode[i].data_id +
|
|
|
|
|
'" type="checkbox" checked data-toggle="toggle" data-on="선 택" data-off="-" data-onstyle="success" data-offstyle="danger" data-size="small"> ';
|
|
|
|
|
// tmp += m_button('add_queue_btn', '다운로드 추가', [{'key': 'code', 'value': data.episode[i].code}])
|
|
|
|
|
tmp += m_button("add_download", "다운로드 추가", [
|
|
|
|
|
{key: "idx", value: i},
|
|
|
|
|
]);
|
|
|
|
|
tmp += "</div>";
|
|
|
|
|
str += m_col(12, tmp);
|
|
|
|
|
str += m_row_end();
|
|
|
|
|
if (i != data.length - 1) str += m_hr(0);
|
|
|
|
|
}
|
|
|
|
|
document.getElementById("episode_list").innerHTML = str;
|
|
|
|
|
$('input[id^="checkbox_"]').bootstrapToggle();
|
2022-04-30 16:45:26 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("body").on("click", "#all_check_on_btn", function (e) {
|
2022-05-13 20:24:03 +09:00
|
|
|
e.preventDefault();
|
|
|
|
|
$('input[id^="checkbox_"]').bootstrapToggle("on");
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("body").on("click", "#all_check_off_btn", function (e) {
|
2022-05-13 20:24:03 +09:00
|
|
|
e.preventDefault();
|
|
|
|
|
$('input[id^="checkbox_"]').bootstrapToggle("off");
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("body").on("click", "#search_tvdb_btn", function (e) {
|
2022-05-13 20:24:03 +09:00
|
|
|
e.preventDefault();
|
|
|
|
|
const new_title = document.getElementById("new_title").value;
|
|
|
|
|
let url = "https://www.thetvdb.com/search?query=" + new_title;
|
|
|
|
|
window.open(url, "_blank");
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("body").on("click", "#add_whitelist", function (e) {
|
2022-05-13 20:24:03 +09:00
|
|
|
e.preventDefault();
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/" + package_name + "/ajax/add_whitelist",
|
|
|
|
|
type: "POST",
|
|
|
|
|
cache: false,
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: function (ret) {
|
|
|
|
|
if (ret.ret) {
|
|
|
|
|
$.notify("<strong>추가하였습니다.</strong><br>", {
|
|
|
|
|
type: "success",
|
|
|
|
|
});
|
|
|
|
|
make_program(ret);
|
|
|
|
|
} else {
|
|
|
|
|
$.notify("<strong>추가 실패</strong><br>" + ret.log, {
|
|
|
|
|
type: "warning",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("body").on("click", "#apply_new_title_btn", function (e) {
|
2022-05-13 20:24:03 +09:00
|
|
|
e.preventDefault();
|
|
|
|
|
const new_title = document.getElementById("new_title").value;
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/" + package_name + "/ajax/apply_new_title",
|
|
|
|
|
type: "POST",
|
|
|
|
|
cache: false,
|
|
|
|
|
data: {new_title: new_title},
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: function (ret) {
|
|
|
|
|
if (ret.ret) {
|
|
|
|
|
$.notify("<strong>적용하였습니다.</strong><br>", {
|
|
|
|
|
type: "success",
|
|
|
|
|
});
|
|
|
|
|
// console.log(ret)
|
|
|
|
|
make_program(ret);
|
|
|
|
|
} else {
|
|
|
|
|
$.notify("<strong>적용 실패</strong><br>" + ret.log, {
|
|
|
|
|
type: "warning",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("body").on("click", "#apply_new_season_btn", function (e) {
|
2022-05-13 20:24:03 +09:00
|
|
|
e.preventDefault();
|
|
|
|
|
const new_season = document.getElementById("new_season").value;
|
|
|
|
|
if ($.isNumeric(new_season) == false) {
|
|
|
|
|
$.notify("<strong>시즌은 숫자여야 합니다.</strong><br>" + ret.log, {
|
2022-04-30 16:45:26 +09:00
|
|
|
type: "warning",
|
2022-05-13 20:24:03 +09:00
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/" + package_name + "/ajax/apply_new_season",
|
|
|
|
|
type: "POST",
|
|
|
|
|
cache: false,
|
|
|
|
|
data: {new_season: new_season},
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: function (ret) {
|
|
|
|
|
if (ret.ret) {
|
|
|
|
|
$.notify("<strong>적용하였습니다.</strong><br>", {
|
|
|
|
|
type: "success",
|
|
|
|
|
});
|
|
|
|
|
make_program(ret);
|
|
|
|
|
} else {
|
|
|
|
|
$.notify("<strong>적용 실패</strong><br>" + ret.log, {
|
|
|
|
|
type: "warning",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 하나씩 다운로드 추가
|
2022-05-13 20:24:03 +09:00
|
|
|
$("body").on("click", "#add_download", function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
// code = $(this).data('code');
|
|
|
|
|
code = current_data.data.episode[$(this).data("idx")].code;
|
|
|
|
|
// console.log('code:: ', code)
|
|
|
|
|
let data = current_data.data.episode[$(this).data("idx")];
|
|
|
|
|
// console.log('data:: ', data)
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/" + package_name + "/ajax/add_download",
|
|
|
|
|
type: "POST",
|
|
|
|
|
cache: false,
|
|
|
|
|
data: {code: code, data: JSON.stringify(data)},
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: function (data) {
|
|
|
|
|
// console.log('#add_queue_btn::data >>', data)
|
|
|
|
|
if (data.ret === "enqueue_db_append") {
|
|
|
|
|
$.notify("<strong>다운로드 작업을 추가 하였습니다.</strong>", {
|
|
|
|
|
type: "success",
|
|
|
|
|
});
|
|
|
|
|
} else if (data.ret === "enqueue_db_exist") {
|
|
|
|
|
$.notify("<strong>DB에 존재하는 에피소드입니다.</strong>", {
|
|
|
|
|
type: "warning",
|
|
|
|
|
});
|
|
|
|
|
} else if (data.ret === "db_completed") {
|
|
|
|
|
$.notify("<strong>DB에 완료 기록이 있습니다.</strong>", {
|
|
|
|
|
type: "warning",
|
|
|
|
|
});
|
|
|
|
|
} else if (data.ret === "fail") {
|
|
|
|
|
$.notify("<strong>이미 큐에 있습니다. 삭제 후 추가하세요.</strong>", {
|
|
|
|
|
type: "warning",
|
|
|
|
|
});
|
|
|
|
|
} else if (data.ret === "no_data") {
|
|
|
|
|
$.notify("<strong>잘못된 코드입니다.</strong>", {
|
|
|
|
|
type: "warning",
|
|
|
|
|
});
|
|
|
|
|
} else if (data.ret === "Debugging") {
|
|
|
|
|
$.notify("<strong>Debugging</strong>", {
|
|
|
|
|
type: "warning",
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
$.notify("<strong>추가 실패</strong><br>" + ret.log, {
|
|
|
|
|
type: "warning",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("body").on("click", "#check_download_btn", function (e) {
|
2022-05-13 20:24:03 +09:00
|
|
|
e.preventDefault();
|
|
|
|
|
const checked_items = $('input[id^="checkbox_"]');
|
|
|
|
|
console.log(checked_items)
|
|
|
|
|
let str = "";
|
|
|
|
|
for (let i in checked_items) {
|
|
|
|
|
if (checked_items[i].checked) {
|
|
|
|
|
code = checked_items[i].id.split("_")[1];
|
|
|
|
|
str += code + ",";
|
|
|
|
|
}
|
2022-04-30 16:45:26 +09:00
|
|
|
}
|
2022-05-13 20:24:03 +09:00
|
|
|
lecture_id = current_data.data.episode[0].item_id
|
|
|
|
|
|
|
|
|
|
console.log(`checked_items: ${checked_items}`)
|
|
|
|
|
|
|
|
|
|
console.log(str)
|
|
|
|
|
if (str === "") {
|
|
|
|
|
$.notify("<strong>선택하세요.</strong>", {
|
|
|
|
|
type: "warning",
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
2022-05-13 20:24:03 +09:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/" + package_name + "/ajax/add_queue_checked_list",
|
|
|
|
|
type: "POST",
|
|
|
|
|
cache: false,
|
|
|
|
|
data: {code: str, lecture_id: lecture_id},
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.ret == "success") {
|
|
|
|
|
$.notify("<strong>" + data.log + "개를 추가하였습니다.</strong>", {
|
|
|
|
|
type: "success",
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
$.notify("<strong>" + data.log + "</strong>", {
|
|
|
|
|
type: "warning",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#go_modal_airing").on("shown.bs.modal", function () {
|
2022-05-13 20:24:03 +09:00
|
|
|
// {#get_airing_list()#}
|
|
|
|
|
$("#exModal").trigger("focus");
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#go_modal_airing").click(function (e) {
|
2022-05-13 20:24:03 +09:00
|
|
|
e.preventDefault();
|
|
|
|
|
// console.log('open modal')
|
|
|
|
|
$("#exModal").bootstrapToggle();
|
|
|
|
|
if (current_airing_data === "") {
|
|
|
|
|
get_airing_list();
|
|
|
|
|
}
|
|
|
|
|
$("#inner_airing").toggle();
|
|
|
|
|
$("#airing_list").toggle();
|
2022-04-30 16:45:26 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#go_modal_airing").attr("class", "btn btn-primary");
|
|
|
|
|
|