anime-downloader bug fix 20.
add search routine check download fix
This commit is contained in:
@@ -15,6 +15,7 @@ import hashlib
|
|||||||
import requests
|
import requests
|
||||||
from lxml import html
|
from lxml import html
|
||||||
from urllib import parse
|
from urllib import parse
|
||||||
|
import urllib
|
||||||
|
|
||||||
# third-party
|
# third-party
|
||||||
from flask import request, render_template, jsonify
|
from flask import request, render_template, jsonify
|
||||||
@@ -146,6 +147,15 @@ class LogicOhli24(LogicModuleBase):
|
|||||||
return jsonify(
|
return jsonify(
|
||||||
{"ret": "success", "cate": cate, "page": page, "data": data}
|
{"ret": "success", "cate": cate, "page": page, "data": data}
|
||||||
)
|
)
|
||||||
|
elif sub == "search":
|
||||||
|
data = []
|
||||||
|
# cate = request.form["type"]
|
||||||
|
# page = request.form["page"]
|
||||||
|
query = request.form["query"]
|
||||||
|
|
||||||
|
data = self.get_search_result(query)
|
||||||
|
# self.current_data = data
|
||||||
|
return jsonify({"ret": "success", "query": query, "data": data})
|
||||||
|
|
||||||
elif sub == "add_queue":
|
elif sub == "add_queue":
|
||||||
ret = {}
|
ret = {}
|
||||||
@@ -394,6 +404,48 @@ class LogicOhli24(LogicModuleBase):
|
|||||||
P.logger.error(traceback.format_exc())
|
P.logger.error(traceback.format_exc())
|
||||||
return {"ret": "exception", "log": str(e)}
|
return {"ret": "exception", "log": str(e)}
|
||||||
|
|
||||||
|
# @staticmethod
|
||||||
|
def get_search_result(self, query):
|
||||||
|
try:
|
||||||
|
_query = urllib.parse.quote(query)
|
||||||
|
url = (
|
||||||
|
P.ModelSetting.get("ohli24_url")
|
||||||
|
+ "/bbs/search.php?srows=24&gr_id=&sfl=wr_subject&stx="
|
||||||
|
+ _query
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.info("url:::> %s", url)
|
||||||
|
data = {}
|
||||||
|
response_data = LogicOhli24.get_html(url, timeout=10)
|
||||||
|
tree = html.fromstring(response_data)
|
||||||
|
tmp_items = tree.xpath('//div[@class="list-row"]')
|
||||||
|
data["anime_count"] = len(tmp_items)
|
||||||
|
data["anime_list"] = []
|
||||||
|
|
||||||
|
for item in tmp_items:
|
||||||
|
entity = {}
|
||||||
|
entity["link"] = item.xpath(".//a/@href")[0]
|
||||||
|
# entity["code"] = entity["link"].split("/")[-1]
|
||||||
|
entity["wr_id"] = entity["link"].split("=")[-1]
|
||||||
|
# logger.debug(item.xpath(".//div[@class='post-title']/text()").join())
|
||||||
|
entity["title"] = "".join(
|
||||||
|
item.xpath(".//div[@class='post-title']/text()")
|
||||||
|
).strip()
|
||||||
|
entity["image_link"] = item.xpath(".//div[@class='img-item']/img/@src")[
|
||||||
|
0
|
||||||
|
].replace("..", P.ModelSetting.get("ohli24_url"))
|
||||||
|
|
||||||
|
entity["code"] = item.xpath(".//div[@class='img-item']/img/@alt")[0]
|
||||||
|
|
||||||
|
data["ret"] = "success"
|
||||||
|
data["anime_list"].append(entity)
|
||||||
|
|
||||||
|
return data
|
||||||
|
except Exception as e:
|
||||||
|
P.logger.error("Exception:%s", e)
|
||||||
|
P.logger.error(traceback.format_exc())
|
||||||
|
return {"ret": "exception", "log": str(e)}
|
||||||
|
|
||||||
# @staticmethod
|
# @staticmethod
|
||||||
def plugin_load(self):
|
def plugin_load(self):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1,27 +1,37 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %} {% block content %}
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
<!--{#<div>#}-->
|
<div class="input-group mb-2">
|
||||||
<!--{# <form id='program_list'>#}-->
|
<input
|
||||||
<!--{# {{ macros.setting_input_text_and_buttons('code', '작품 Code', [['analysis_btn', '분석'], ['go_ohli24_btn', 'Go OHLI24']], desc='예) "https://ohli24.net/c/녹을 먹는 비스코" 이나 "녹을 먹는 비스코"') }}#}-->
|
id="input_search"
|
||||||
<!--{# </form>#}-->
|
type="search"
|
||||||
<!--{# <form id="program_auto_form">#}-->
|
class="form-control rounded"
|
||||||
<!--{# <div id='episode_list'></div>#}-->
|
placeholder="Search"
|
||||||
<!--{# </form>#}-->
|
aria-label="Search"
|
||||||
<!--{#</div> <!–전체–>#}-->
|
aria-describedby="search-addon"
|
||||||
|
/>
|
||||||
|
<button id="btn_search" type="button" class="btn btn-outline-primary">
|
||||||
|
search
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div id="anime_category" class="btn-group" role="group" aria-label="Basic example">
|
<div
|
||||||
|
id="anime_category"
|
||||||
|
class="btn-group"
|
||||||
|
role="group"
|
||||||
|
aria-label="Basic example"
|
||||||
|
>
|
||||||
<button id="ing" type="button" class="btn btn-success">방영중</button>
|
<button id="ing" type="button" class="btn btn-success">방영중</button>
|
||||||
<button id="movie" type="button" class="btn btn-primary">극장판</button>
|
<button id="movie" type="button" class="btn btn-primary">극장판</button>
|
||||||
<button id="complete_anilist" type="button" class="btn btn-dark">완결</button>
|
<button id="complete_anilist" type="button" class="btn btn-dark">
|
||||||
|
완결
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<form id="airing_list_form">
|
<form id="airing_list_form">
|
||||||
<div id="airing_list"></div>
|
<div id="airing_list"></div>
|
||||||
</form>
|
</form>
|
||||||
<form id="screen_movie_list_form">
|
<form id="screen_movie_list_form">
|
||||||
<div id="screen_movie_list" class="container">
|
<div id="screen_movie_list" class="container"></div>
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<div id="spinner" class="spinner-border" role="status">
|
<div id="spinner" class="spinner-border" role="status">
|
||||||
@@ -29,11 +39,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form id="program_auto_form">
|
<form id="program_auto_form">
|
||||||
<div id='episode_list'></div>
|
<div id="episode_list"></div>
|
||||||
</form>
|
</form>
|
||||||
</div> <!--전체-->
|
</div>
|
||||||
|
<!--전체-->
|
||||||
|
|
||||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lozad/dist/lozad.min.js"></script>
|
<script
|
||||||
|
type="text/javascript"
|
||||||
|
src="https://cdn.jsdelivr.net/npm/lozad/dist/lozad.min.js"
|
||||||
|
></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
const package_name = "{{arg['package_name'] }}";
|
const package_name = "{{arg['package_name'] }}";
|
||||||
const sub = "{{arg['sub'] }}";
|
const sub = "{{arg['sub'] }}";
|
||||||
@@ -110,7 +124,7 @@
|
|||||||
tmp += '<img class="lozad" data-src="' + data.anime_list[i].image_link + '" />';
|
tmp += '<img class="lozad" data-src="' + data.anime_list[i].image_link + '" />';
|
||||||
tmp += '<div class="card-body">'
|
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">' +#}
|
{#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>';#}
|
// {# '<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 += '<h5 class="card-title">' + data.anime_list[i].title + '</h5>';
|
||||||
tmp += '<p class="card-text">' + data.anime_list[i].code + '</p>';
|
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?code=' + data.anime_list[i].code + '" class="btn btn-primary cut-text">' + data.anime_list[i].title + '</a>';
|
||||||
@@ -140,16 +154,57 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function make_search_result_list(data, page) {
|
||||||
|
let str = ''
|
||||||
|
let tmp = ''
|
||||||
|
|
||||||
|
console.log(data.anime_list, page)
|
||||||
|
|
||||||
|
str += '<div>';
|
||||||
|
str += '<button type="button" class="btn btn-info">Page <span class="badge bg-warning">' + page + '</span></button>';
|
||||||
|
str += '</div>';
|
||||||
|
str += '<div id="inner_screen_movie" class="row infinite-scroll">';
|
||||||
|
for (let i in data.anime_list) {
|
||||||
|
|
||||||
|
tmp = '<div class="col-sm-4">';
|
||||||
|
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.anime_list[i].title + '</a>';
|
||||||
|
tmp += '</div>';
|
||||||
|
tmp += '</div>';
|
||||||
|
tmp += '</div>';
|
||||||
|
str += tmp
|
||||||
|
|
||||||
|
}
|
||||||
|
str += '</div>';
|
||||||
|
str += m_hr_black();
|
||||||
|
|
||||||
|
if (page > 1) {
|
||||||
|
|
||||||
|
const temp = document.createElement('div')
|
||||||
|
temp.innerHTML = str;
|
||||||
|
while (temp.firstChild) {
|
||||||
|
document.getElementById("screen_movie_list").appendChild(temp.firstChild);
|
||||||
|
}
|
||||||
|
page++
|
||||||
|
|
||||||
|
} else {
|
||||||
|
document.getElementById("screen_movie_list").innerHTML = str;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function make_screen_movie_list(data, page) {
|
function make_screen_movie_list(data, page) {
|
||||||
let str = ''
|
let str = ''
|
||||||
let tmp = ''
|
let tmp = ''
|
||||||
|
|
||||||
// {#str += "<d"#}
|
console.log(data.anime_list, page)
|
||||||
// {#str += m_hr_black();#}
|
|
||||||
// {#str += m_row_start(0);#}
|
|
||||||
// {##}
|
|
||||||
// {#str += m_row_end();#}
|
|
||||||
// {#str += m_hr_black();#}
|
|
||||||
str += '<div>';
|
str += '<div>';
|
||||||
str += '<button type="button" class="btn btn-info">Page <span class="badge bg-warning">' + page + '</span></button>';
|
str += '<button type="button" class="btn btn-info">Page <span class="badge bg-warning">' + page + '</span></button>';
|
||||||
str += '</div>';
|
str += '</div>';
|
||||||
@@ -161,7 +216,7 @@
|
|||||||
tmp += '<img class="card-img-top" src="' + data.anime_list[i].image_link + '" />';
|
tmp += '<img class="card-img-top" src="' + data.anime_list[i].image_link + '" />';
|
||||||
tmp += '<div class="card-body">'
|
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">' +#}
|
{#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>';#}
|
// {# '<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 += '<h5 class="card-title">' + data.anime_list[i].title + '</h5>';
|
||||||
tmp += '<p class="card-text">' + data.anime_list[i].code + '</p>';
|
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.episode[i].title + '</a>';
|
||||||
@@ -184,9 +239,7 @@
|
|||||||
page++
|
page++
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
document.getElementById("screen_movie_list").innerHTML = str;
|
document.getElementById("screen_movie_list").innerHTML = str;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -199,8 +252,51 @@
|
|||||||
// // 값이 공백이 아니면 분석 버튼 계속 누름
|
// // 값이 공백이 아니면 분석 버튼 계속 누름
|
||||||
// document.getElementById("analysis_btn").click();
|
// document.getElementById("analysis_btn").click();
|
||||||
// }
|
// }
|
||||||
|
$("#input_search").keydown(function (key) {
|
||||||
|
if (key.keyCode === 13) {
|
||||||
|
// alert("엔터키를 눌렀습니다.");
|
||||||
|
$("#btn_search").trigger("click");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const observer = lozad('.lozad', {
|
||||||
|
rootMargin: '10px 0px', // syntax similar to that of CSS Margin
|
||||||
|
threshold: 0.1, // ratio of element convergence
|
||||||
|
enableAutoReload: true // it will reload the new image when validating attributes changes
|
||||||
|
});
|
||||||
|
observer.observe();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$("body").on("click", "#btn_search", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
let query = $("#input_search").val();
|
||||||
|
console.log(query);
|
||||||
|
|
||||||
|
if ($("#input_search").val() === "") {
|
||||||
|
console.log("search keyword nothing");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/" + package_name + "/ajax/" + sub + "/search",
|
||||||
|
type: "POST",
|
||||||
|
cache: false,
|
||||||
|
data: { query: query },
|
||||||
|
// dataType: "json",
|
||||||
|
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
|
||||||
|
success: function (ret) {
|
||||||
|
if (ret.ret) {
|
||||||
|
console.log('ret:::', ret)
|
||||||
|
make_search_result_list(ret.data, 1);
|
||||||
|
} else {
|
||||||
|
$.notify("<strong>분석 실패</strong><br>" + ret.log, {
|
||||||
|
type: "warning",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$('#anime_category #ing').on("click", function() {
|
$('#anime_category #ing').on("click", function() {
|
||||||
// {#console.log(this.id)#}
|
// {#console.log(this.id)#}
|
||||||
@@ -272,24 +368,19 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
// const observer = lozad();
|
// const observer = lozad();
|
||||||
const observer = lozad('.lozad', {
|
|
||||||
rootMargin: '10px 0px', // syntax similar to that of CSS Margin
|
|
||||||
threshold: 0.1, // ratio of element convergence
|
|
||||||
enableAutoReload: true // it will reload the new image when validating attributes changes
|
|
||||||
});
|
|
||||||
observer.observe();
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// const el = document.querySelector('img');
|
// const el = document.querySelector('img');
|
||||||
// const observer = lozad(el); // passing a `NodeList` (e.g. `document.querySelectorAll()`) is also valid
|
// const observer = lozad(el); // passing a `NodeList` (e.g. `document.querySelectorAll()`) is also valid
|
||||||
// observer.observe();
|
// observer.observe();
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
button.code-button { min-width: 82px!important;}
|
button.code-button {
|
||||||
|
min-width: 82px !important;
|
||||||
|
}
|
||||||
.tooltip {
|
.tooltip {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: block;
|
display: block;
|
||||||
@@ -305,9 +396,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
[data-tooltip-text]:after {
|
[data-tooltip-text]:after {
|
||||||
-webkit-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 .3s ease-in-out, opacity .3s ease-in-out;
|
-moz-transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out;
|
||||||
transition: bottom .3s ease-in-out, opacity .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);
|
background-color: rgba(0, 0, 0, 0.8);
|
||||||
|
|
||||||
@@ -319,7 +410,7 @@
|
|||||||
-moz-border-radius: 5px;
|
-moz-border-radius: 5px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
|
||||||
color: #FFFFFF;
|
color: #ffffff;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
padding: 7px 12px;
|
padding: 7px 12px;
|
||||||
@@ -342,14 +433,15 @@
|
|||||||
top: 230%;
|
top: 230%;
|
||||||
left: 0;
|
left: 0;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}[data-tooltip-text]:hover {
|
}
|
||||||
|
[data-tooltip-text]:hover {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-tooltip-text]:after {
|
[data-tooltip-text]:after {
|
||||||
-webkit-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 .3s ease-in-out, opacity .3s ease-in-out;
|
-moz-transition: bottom 0.3s ease-in-out, opacity 0.3s ease-in-out;
|
||||||
transition: bottom .3s ease-in-out, opacity .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);
|
background-color: rgba(0, 0, 0, 0.8);
|
||||||
|
|
||||||
@@ -361,7 +453,7 @@
|
|||||||
-moz-border-radius: 5px;
|
-moz-border-radius: 5px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
|
||||||
color: #FFFFFF;
|
color: #ffffff;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
padding: 7px 12px;
|
padding: 7px 12px;
|
||||||
@@ -398,7 +490,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#screen_movie_list {
|
#screen_movie_list {
|
||||||
margin-top: 10px
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user