오류 수정

This commit is contained in:
2022-04-17 13:45:37 +09:00
parent 9779d82ad7
commit a63baf44f4
2 changed files with 43 additions and 10 deletions

View File

@@ -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(