From 7a529aa27b654e2409902c50363f4eba3f07fbf5 Mon Sep 17 00:00:00 2001 From: projectdx Date: Sat, 28 Jan 2023 23:27:16 +0900 Subject: [PATCH] ohli24 api update 2023.01.18(01.) anilife api update 2023.01.18(02-03) --- logic_anilife.py | 46 +++++++++++----------------------------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/logic_anilife.py b/logic_anilife.py index 459365e..a27d356 100644 --- a/logic_anilife.py +++ b/logic_anilife.py @@ -580,7 +580,9 @@ class LogicAniLife(LogicModuleBase): return vod_url except Exception as e: logger.error("Exception:%s", e) - result = subprocess.run(["playwright", "install"], stdout=subprocess.PIPE, text=True) + result = subprocess.run( + ["playwright", "install"], stdout=subprocess.PIPE, text=True + ) print(result.stdout) logger.error(traceback.format_exc()) @@ -780,6 +782,7 @@ class LogicAniLife(LogicModuleBase): return render_template("sample.html", title="%s - %s" % (P.package_name, sub)) def process_ajax(self, sub, req): + data = [] try: if sub == "analysis": # code = req.form['code'] @@ -788,7 +791,6 @@ class LogicAniLife(LogicModuleBase): wr_id = request.form.get("wr_id", None) bo_table = request.form.get("bo_table", None) - data = [] # logger.info("code::: %s", code) P.ModelSetting.set("anilife_current_code", code) @@ -796,7 +798,6 @@ class LogicAniLife(LogicModuleBase): self.current_data = data return jsonify({"ret": "success", "data": data, "code": code}) elif sub == "anime_list": - data = [] cate = request.form["type"] page = request.form["page"] @@ -806,7 +807,6 @@ class LogicAniLife(LogicModuleBase): {"ret": "success", "cate": cate, "page": page, "data": data} ) elif sub == "complete_list": - data = [] cate = request.form["type"] logger.debug("cate:: %s", cate) @@ -818,9 +818,7 @@ class LogicAniLife(LogicModuleBase): {"ret": "success", "cate": cate, "page": page, "data": data} ) elif sub == "search": - data = [] - # cate = request.form["type"] - # page = request.form["page"] + cate = request.form["type"] query = request.form["query"] page = request.form["page"] @@ -1047,7 +1045,7 @@ class LogicAniLife(LogicModuleBase): "ep_num": ep_num, "title": f"{main_title} {ep_num}화 - {title}", "link": link, - "thumbnail": image, + "thumbnail": thumbnail, "date": date, "day": date, "_id": title, @@ -1058,21 +1056,6 @@ class LogicAniLife(LogicModuleBase): } ) - # print(lxml.etree.tostring(des_items, method="text")) - # - # for idx, item in enumerate(des_items): - # span = item.xpath(".//b/text()") - # logger.info(f"0: {span[0]}") - # key = description_dict[span[0].replace(":", "")] - # logger.debug(f"key:: {key}") - # try: - # print(item.xpath(".//text()")[1].strip()) - # des[key] = item.xpath(".//text()")[1].strip() - # except IndexError: - # if item.xpath(".//a"): - # des[key] = item.xpath(".//a")[0] - # des[key] = "" - ser_description = "작품 설명 부분" des = "" des1 = "" @@ -1233,7 +1216,7 @@ class AniLifeQueueEntity(FfmpegQueueEntity): tmp["epi_queue"] = self.epi_queue return tmp - def donwload_completed(self): + def download_completed(self): db_entity = ModelAniLifeItem.get_by_anilife_id(self.info["_id"]) if db_entity is not None: db_entity.status = "completed" @@ -1253,13 +1236,11 @@ class AniLifeQueueEntity(FfmpegQueueEntity): ourls = parse.urlparse(url) self.headers = { - "Referer": f"{ourls.scheme}://{ourls.netloc}", - "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Whale/3.12.129.46 Safari/537.36", + "Referer": LogicAniLife.episode_url, + "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) " + "Chrome/96.0.4664.110 Whale/3.12.129.46 Safari/537.36", } - headers["Referer"] = "https://anilife.live/detail/id/471" - headers["Referer"] = LogicAniLife.episode_url - logger.debug("make_episode_info()::url==> %s", url) logger.info(f"self.info:::> {self.info}") @@ -1285,13 +1266,9 @@ class AniLifeQueueEntity(FfmpegQueueEntity): ) ) - # vod_1080p_url = text - - # logger.debug(text) soup = BeautifulSoup(text, "lxml") all_scripts = soup.find_all("script") - # print(all_scripts) regex = r"(?Phttp?s:\/\/.*=jawcloud)" match = re.compile(regex).search(text) @@ -1364,10 +1341,9 @@ class AniLifeQueueEntity(FfmpegQueueEntity): vod_1080p_url = asyncio.run( LogicAniLife.get_vod_url(jawcloud_url, headless=True) ) - print(f"vod_1080p_url:: {vod_1080p_url}") + logger.debug(f"vod_1080p_url:: {vod_1080p_url}") self.url = vod_1080p_url - logger.info(self.url) except Exception as e: P.logger.error("Exception:%s", e) P.logger.error(traceback.format_exc())