anime-downloader bug fix 21.

add search routine
check download fix
This commit is contained in:
2022-04-10 14:24:23 +09:00
parent 1d9bbbf922
commit dec47f900b
2 changed files with 442 additions and 349 deletions

View File

@@ -22,7 +22,7 @@
aria-label="Basic example"
>
<button id="ing" type="button" class="btn btn-success">방영중</button>
<button id="movie" type="button" class="btn btn-primary">극장판</button>
<button id="theater" type="button" class="btn btn-primary">극장판</button>
<button id="complete_anilist" type="button" class="btn btn-dark">
완결
</button>
@@ -53,6 +53,9 @@
const sub = "{{arg['sub'] }}";
const ohli24_url = "{{arg['ohli24_url']}}";
let current_data = null;
let page = 1;
let next_page = Number
let current_cate = ''
const observer = lozad('.lozad', {
rootMargin: '10px 0px', // syntax similar to that of CSS Margin
@@ -70,12 +73,19 @@
switch (type) {
case 'ing':
url = '/' + package_name + '/ajax/'+sub+'/anime_list'
current_cate = 'ing'
break;
case 'movie':
url = '/' + package_name + '/ajax/'+sub+'screen_movie_list'
url = '/' + package_name + '/ajax/'+sub+'/screen_movie_list'
current_cate = 'movie'
break;
case 'complete':
url = '/' + package_name + '/ajax/'+sub+'screen_movie_list'
case 'theater':
url = '/' + package_name + '/ajax/'+sub+'/anime_list'
current_cate = 'theater'
break;
case 'fin':
url = '/' + package_name + '/ajax/'+sub+'/complete_list'
current_cate = 'fin'
break
default:
break;
@@ -94,12 +104,15 @@
if (current_screen_movie_data !== '') {
if (type === "ing") {
make_airing_list(ret.data, page)
// setTimeout(() => {
// observer.observe();
// }, 1000);
observer.observe();
} else if (type === "fin") {
make_screen_movie_list(ret.data, page)
observer.observe();
} else if (type === "theater") {
make_screen_movie_list(ret.data, page)
observer.observe();
} else {
make_screen_movie_list(ret, page)
make_screen_movie_list(ret.data, page)
}
div_visible = true
console.log(div_visible)
@@ -165,6 +178,14 @@
str += '</div>';
str += '<div id="inner_screen_movie" class="row infinite-scroll">';
for (let i in data.anime_list) {
if (data.anime_list[i].wr_id !== '') {
const re = /bo_table=([^&]+)/
const bo_table = data.anime_list[i].link.match(re)
// console.log(bo_table)
request_url = './request?code=' + data.anime_list[i].code + '&amp;wr_id='+ data.anime_list[i].wr_id + '&amp;bo_table='+bo_table[1]
} else {
request_url = './request?code=' + data.anime_list[i].code
}
tmp = '<div class="col-sm-4">';
tmp += '<div class="card">';
@@ -174,7 +195,7 @@
// {# '<span data-tooltip-text="'+data.episode[i].title+'">' + data.episode[i].code + '</span></button></div>';#}
tmp += '<h5 class="card-title">' + data.anime_list[i].title + '</h5>';
tmp += '<p class="card-text">' + data.anime_list[i].code + '</p>';
tmp += '<a href="./request?code=' + data.anime_list[i].code + '" class="btn btn-primary cut-text">' + data.anime_list[i].title + '</a>';
tmp += '<a href="'+request_url+'" class="btn btn-primary cut-text">' + data.anime_list[i].title + '</a>';
tmp += '</div>';
tmp += '</div>';
tmp += '</div>';
@@ -215,11 +236,9 @@
tmp += '<div class="card">';
tmp += '<img class="card-img-top" src="' + data.anime_list[i].image_link + '" />';
tmp += '<div class="card-body">'
{#tmp += '<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>';#}
tmp += '<h5 class="card-title">' + data.anime_list[i].title + '</h5>';
tmp += '<p class="card-text">' + data.anime_list[i].code + '</p>';
tmp += '<a href="./request?code=' + data.anime_list[i].code + '" class="btn btn-primary cut-text">' + data.episode[i].title + '</a>';
tmp += '<a href="./request?code=' + data.anime_list[i].code + '" class="btn btn-primary cut-text">' + data.anime_list[i].title + '</a>';
tmp += '</div>';
tmp += '</div>';
tmp += '</div>';
@@ -305,6 +324,20 @@
get_anime_list("ing", 1)
})
$('#anime_category #complete_anilist').on("click", function() {
// {#console.log(this.id)#}
let spinner = document.getElementById('spinner');
spinner.style.visibility = 'visible';
get_anime_list("fin", 1)
})
$('#anime_category #theater').on("click", function() {
// {#console.log(this.id)#}
let spinner = document.getElementById('spinner');
spinner.style.visibility = 'visible';
get_anime_list("theater", 1)
})
// 분석 버튼 클릭시 호출
$("body").on('click', '#analysis_btn', function(e) {
e.preventDefault();
@@ -368,14 +401,77 @@
});
});
// const observer = lozad();
// const el = document.querySelector('img');
// const observer = lozad(el); // passing a `NodeList` (e.g. `document.querySelectorAll()`) is also valid
// observer.observe();
const loadNextAnimes = (cate, page) => {
spinner.style.display = "block";
const data = { type: cate, page: String(page) };
let url = ''
switch (cate) {
case 'ing':
url = '/' + package_name + '/ajax/'+sub+'/anime_list'
current_cate = 'ing'
break;
case 'movie':
url = '/' + package_name + '/ajax/'+sub+'/screen_movie_list'
current_cate = 'movie'
break;
case 'theater':
url = '/' + package_name + '/ajax/'+sub+'/anime_list'
current_cate = 'theater'
break;
case 'fin':
url = '/' + package_name + '/ajax/'+sub+'/complete_list'
current_cate = 'fin'
break
default:
break;
}
fetch(url, {
method: "POST",
cache: "no-cache",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: new URLSearchParams(data),
})
.then((res) => res.json())
.then((response) => {
console.log("Success:", JSON.stringify(response));
// {#imagesContainer.appendChild()#}
console.log("return page:::> ", response.page);
// {#page = response.page#}
make_screen_movie_list(response.data, response.page);
page++;
next_page++;
})
.catch((error) => console.error("Error:", error));
};
const onScroll = (e) => {
console.dir(e.target.scrollingElement.scrollHeight);
const { scrollTop, scrollHeight, clientHeight } = e.target.scrollingElement;
if (Math.round(scrollHeight - scrollTop) <= clientHeight) {
document.getElementById("spinner").style.display = "block";
console.log("loading");
console.log("now page::> ", page);
console.log("next_page::> ", next_page);
loadNextAnimes(current_cate, next_page);
}
};
const debounce = (func, delay) => {
let timeoutId = null;
return (...args) => {
clearTimeout(timeoutId);
timeoutId = setTimeout(func.bind(null, ...args), delay);
};
};
document.addEventListener("scroll", debounce(onScroll, 300));
</script>
<style>
button.code-button {

View File

@@ -1,14 +1,16 @@
{% extends "base.html" %}
{% block content %}
{% extends "base.html" %} {% block content %}
<div>
<form id='program_list'>
{{ macros.setting_input_text_and_buttons('code', '작품 Code', [['analysis_btn', '분석'], ['go_ohli24_btn', 'Go OHLI24']], desc='예) "https://ohli24.net/c/녹을 먹는 비스코" 이나 "녹을 먹는 비스코"') }}
<form id="program_list">
{{ macros.setting_input_text_and_buttons('code', '작품 Code',
[['analysis_btn', '분석'], ['go_ohli24_btn', 'Go OHLI24']], desc='예)
"https://ohli24.net/c/녹을 먹는 비스코" 이나 "녹을 먹는 비스코"') }}
</form>
<form id="program_auto_form">
<div id='episode_list'></div>
<div id="episode_list"></div>
</form>
</div> <!--전체-->
</div>
<!--전체-->
<script type="text/javascript">
const package_name = "{{arg['package_name'] }}";
@@ -20,6 +22,8 @@
get: (searchParams, prop) => searchParams.get(prop),
})
function findGetParameter(parameterName) {
let result = null,
tmp = [];
@@ -31,7 +35,7 @@
return result;
}
function analyze() {
function analyze(wr_id, bo_table) {
// e.preventDefault();
const code = document.getElementById("code").value
console.log(code)
@@ -39,7 +43,7 @@
url: '/' + package_name + '/ajax/' + sub + '/analysis',
type: "POST",
cache: false,
data: {code:code},
data: {code: code, wr_id: wr_id, bo_table: bo_table},
dataType: "json",
success: function (ret) {
if (ret.ret === 'success' && ret.data != null) {
@@ -115,6 +119,8 @@
}
$(function () {
console.log(params.wr_id)
console.log(findGetParameter('wr_id'))
console.log(params.code)
if (params.code === '') {
@@ -135,7 +141,8 @@
console.log('params code exist')
console.log(params.code)
document.getElementById("code").value = params.code
analyze()
analyze(params.wr_id, params.bo_table)
// document.getElementById("analysis_btn").click();
// $('#analysis_btn').trigger('click')
}
@@ -149,20 +156,10 @@
$(document).ready(function(){
console.log('wr_id::', params.wr_id)
});
// $('#analysis_btn').unbind("click").bind('click', function (e) {
// e.preventDefault();
// e.stopPropagation()
// console.log('test')
// const code = document.getElementById("code").value
// console.log(code)
// })
// $("body").unbind('click', '#analysis_btn')
// 분석 버튼 클릭시 호출
// $("body").on('click', '#analysis_btn', function(e){
$("#analysis_btn").unbind("click").bind('click', function(e){
e.preventDefault();
e.stopPropagation()
@@ -253,11 +250,11 @@
}
});
});
</script>
<style>
button.code-button { min-width: 82px!important;}
button.code-button {
min-width: 82px !important;
}
.tooltip {
position: relative;
display: block;
@@ -268,9 +265,9 @@
}
[data-tooltip-text]:after {
-webkit-transition: bottom .3s ease-in-out, opacity .3s ease-in-out;
-moz-transition: bottom .3s ease-in-out, opacity .3s ease-in-out;
transition: bottom .3s ease-in-out, opacity .3s ease-in-out;
-webkit-transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out;
-moz-transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out;
transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out;
background-color: rgba(0, 0, 0, 0.8);
@@ -282,7 +279,7 @@
-moz-border-radius: 5px;
border-radius: 5px;
color: #FFFFFF;
color: #ffffff;
font-size: 12px;
margin-bottom: 10px;
padding: 7px 12px;
@@ -305,14 +302,15 @@
top: 230%;
left: 0;
opacity: 1;
}[data-tooltip-text]:hover {
}
[data-tooltip-text]:hover {
position: relative;
}
[data-tooltip-text]:after {
-webkit-transition: bottom .3s ease-in-out, opacity .3s ease-in-out;
-moz-transition: bottom .3s ease-in-out, opacity .3s ease-in-out;
transition: bottom .3s ease-in-out, opacity .3s ease-in-out;
-webkit-transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out;
-moz-transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out;
transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out;
background-color: rgba(0, 0, 0, 0.8);
@@ -324,7 +322,7 @@
-moz-border-radius: 5px;
border-radius: 5px;
color: #FFFFFF;
color: #ffffff;
font-size: 12px;
margin-bottom: 10px;
padding: 7px 12px;
@@ -338,7 +336,7 @@
opacity: 0;
left: -9999px;
top: -210%!important;
top: -210% !important;
content: attr(data-tooltip-text);
}
@@ -361,8 +359,7 @@
}
#screen_movie_list {
margin-top: 10px
}
margin-top: 10px;
}
</style>
{% endblock %}