diff --git a/logic_ohli24.py b/logic_ohli24.py index 643f93f..5276571 100644 --- a/logic_ohli24.py +++ b/logic_ohli24.py @@ -16,19 +16,24 @@ import requests from lxml import html from urllib import parse import urllib +import asyncio + +# import aiohttp # third-party from flask import request, render_template, jsonify from sqlalchemy import or_, and_, func, not_, desc from pip._internal import main -pkgs = ["beautifulsoup4", "jsbeautifier"] +pkgs = ["beautifulsoup4", "jsbeautifier", "aiohttp"] for pkg in pkgs: try: import pkg except ImportError: main(["install", pkg]) +import aiohttp + from bs4 import BeautifulSoup import jsbeautifier @@ -89,7 +94,7 @@ class LogicOhli24(LogicModuleBase): } def __init__(self, P): - super(LogicOhli24, self).__init__(P, "setting", scheduler_desc="ani365 자동 다운로드") + super(LogicOhli24, self).__init__(P, "setting", scheduler_desc="ohli24 자동 다운로드") self.name = "ohli24" self.queue = None default_route_socketio(P, self) @@ -223,6 +228,32 @@ class LogicOhli24(LogicModuleBase): P.ModelSetting.get_int("ohli24_max_ffmpeg_process_count") ) + def scheduler_function(self): + # Todo: 스케쥴링 함수 미구현 + logger.debug(f"scheduler_function::=========================") + url = P.ModelSetting.get("ohli24_url") + "/bbs/board.php?bo_table=ing" + + content_code_list = P.ModelSetting.get_list("ohli24_auto_code_list", "|") + logger.debug(f"content_code_list::: {content_code_list}") + url_list = ["https://www.naver.com/", "https://www.daum.net/"] + # result = asyncio.run(LogicOhli24.main(url_list)) + # logger.debug(f"result:: {result}") + pass + + @staticmethod + async def get_data(url): + async with aiohttp.ClientSession() as session: + async with session.get(url) as response: + content = await response.text() + # print(response) + return content + + @staticmethod + async def main(url_list): + input_coroutines = [LogicOhli24.get_data(url_) for url_ in url_list] + res = await asyncio.gather(*input_coroutines) + return res + def get_series_info(self, code, wr_id, bo_table): code_type = "c" @@ -316,21 +347,23 @@ class LogicOhli24(LogicModuleBase): } list_body_li = tree.xpath('//ul[@class="list-body"]/li') - logger.info(list_body_li) + # logger.debug(f"list_body_li:: {list_body_li}") episodes = [] vi = None for li in list_body_li: + # logger.debug(li) title = li.xpath(".//a/text()")[0].strip() thumbnail = image - logger.info(li.xpath('//a[@class="item-subject"]/@href')) + # logger.info(li.xpath('//a[@class="item-subject"]/@href')) link = ( P.ModelSetting.get("ohli24_url") - + li.xpath('//a[@class="item-subject"]/@href')[0] + + li.xpath('.//a[@class="item-subject"]/@href')[0] ) + # logger.debug(f"link:: {link}") date = li.xpath('.//div[@class="wr-date"]/text()')[0] m = hashlib.md5(title.encode("utf-8")) # _vi = hashlib.md5(title.encode('utf-8').hexdigest()) - logger.info(m.hexdigest()) + # logger.info(m.hexdigest()) _vi = m.hexdigest() episodes.append( { @@ -350,16 +383,16 @@ class LogicOhli24(LogicModuleBase): for idx, item in enumerate(des_items): # key = des_key[idx] span = item.xpath(".//span//text()") - logger.info(span) + # logger.info(span) key = description_dict[span[0]] try: des[key] = item.xpath(".//span/text()")[1] except IndexError: des[key] = "" - logger.info(f"des::>> {des}") + # logger.info(f"des::>> {des}") image = image.replace("..", P.ModelSetting.get("ohli24_url")) - logger.info("images:: %s", image) + # logger.info("images:: %s", image) logger.info("title:: %s", title) ser_description = tree.xpath( diff --git a/templates/anime_downloader_ohli24_setting.html b/templates/anime_downloader_ohli24_setting.html index cc8002f..3f1622f 100644 --- a/templates/anime_downloader_ohli24_setting.html +++ b/templates/anime_downloader_ohli24_setting.html @@ -23,7 +23,7 @@ {{ macros.setting_input_text('ohli24_finished_insert', '완결 표시', col='3', value=arg['ohli24_finished_insert'], desc=['완결된 컨텐츠 폴더명 앞에 넣을 문구입니다.']) }} {{ macros.setting_checkbox('ohli24_auto_make_season_folder', '시즌 폴더 생성', value=arg['ohli24_auto_make_season_folder'], desc=['On : Season 번호 폴더를 만듭니다.']) }} -{# {{ macros.setting_checkbox('ani365_incompleted_auto_enqueue', '자동으로 다시 받기', value=arg['ani365_incompleted_auto_enqueue'], desc=['On : 플러그인 로딩시 미완료인 항목은 자동으로 다시 받습니다.']) }}#} + {{ macros.setting_checkbox('ohli24_uncompleted_auto_enqueue', '자동으로 다시 받기', value=arg['ohli24_uncompleted_auto_enqueue'], desc=['On : 플러그인 로딩시 미완료인 항목은 자동으로 다시 받습니다.']) }} {{ macros.m_tab_content_end() }}