From 1d9bbbf922a68491f2b77270d7edda3beacc4192 Mon Sep 17 00:00:00 2001 From: projectdx Date: Sat, 9 Apr 2022 19:37:36 +0900 Subject: [PATCH] anime-downloader bug fix 20. add search routine check download fix --- logic_ohli24.py | 52 ++ .../anime_downloader_ohli24_category.html | 756 ++++++++++-------- 2 files changed, 476 insertions(+), 332 deletions(-) diff --git a/logic_ohli24.py b/logic_ohli24.py index aa3d1c7..40bb1f3 100644 --- a/logic_ohli24.py +++ b/logic_ohli24.py @@ -15,6 +15,7 @@ import hashlib import requests from lxml import html from urllib import parse +import urllib # third-party from flask import request, render_template, jsonify @@ -146,6 +147,15 @@ class LogicOhli24(LogicModuleBase): return jsonify( {"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": ret = {} @@ -394,6 +404,48 @@ class LogicOhli24(LogicModuleBase): P.logger.error(traceback.format_exc()) 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 def plugin_load(self): try: diff --git a/templates/anime_downloader_ohli24_category.html b/templates/anime_downloader_ohli24_category.html index 64d5574..129a401 100644 --- a/templates/anime_downloader_ohli24_category.html +++ b/templates/anime_downloader_ohli24_category.html @@ -1,404 +1,496 @@ -{% extends "base.html" %} -{% block content %} +{% extends "base.html" %} {% block content %} - - - - - - - - +
+ + +
-
- - - +
+ + + +
+
+
+
+
+
+
+
+
+ Loading...
-
-
-
-
-
-
-
-
-
- Loading... -
-
-
-
-
-
+
+
+
+
+
+ - + - -{% endblock %} \ No newline at end of file + #screen_movie_list { + margin-top: 10px; + } + +{% endblock %}