edit fix3
This commit is contained in:
125
logic_ohli24.py
125
logic_ohli24.py
@@ -68,7 +68,9 @@ class LogicOhli24(LogicModuleBase):
|
||||
db_default = {
|
||||
"ohli24_db_version": "1.1",
|
||||
"ohli24_url": "https://a18.ohli24.com",
|
||||
"ohli24_download_path": os.path.join(path_data, P.package_name, "ohli24"),
|
||||
"ohli24_download_path": os.path.join(
|
||||
path_data, P.package_name, "ohli24"
|
||||
),
|
||||
"ohli24_auto_make_folder": "True",
|
||||
"ohli24_auto_make_season_folder": "True",
|
||||
"ohli24_finished_insert": "[완결]",
|
||||
@@ -106,7 +108,9 @@ class LogicOhli24(LogicModuleBase):
|
||||
}
|
||||
|
||||
def __init__(self, P):
|
||||
super(LogicOhli24, self).__init__(P, "setting", scheduler_desc="ohli24 자동 다운로드")
|
||||
super(LogicOhli24, self).__init__(
|
||||
P, "setting", scheduler_desc="ohli24 자동 다운로드"
|
||||
)
|
||||
self.name = "ohli24"
|
||||
self.queue = None
|
||||
self.last_post_title = ""
|
||||
@@ -216,7 +220,9 @@ class LogicOhli24(LogicModuleBase):
|
||||
try:
|
||||
if engine == "chrome":
|
||||
browser = await p.chromium.launch(
|
||||
channel="chrome", args=browser_args, headless=headless
|
||||
channel="chrome",
|
||||
args=browser_args,
|
||||
headless=headless,
|
||||
)
|
||||
elif engine == "webkit":
|
||||
browser = await p.webkit.launch(
|
||||
@@ -232,7 +238,9 @@ class LogicOhli24(LogicModuleBase):
|
||||
# user_agent=ua,
|
||||
# )
|
||||
|
||||
LogicOhli24.headers["Referer"] = "https://anilife.com/detail/id/471"
|
||||
LogicOhli24.headers["Referer"] = (
|
||||
"https://anilife.com/detail/id/471"
|
||||
)
|
||||
# print(LogicAniLife.headers)
|
||||
|
||||
LogicOhli24.headers["Referer"] = LogicOhli24.episode_url
|
||||
@@ -242,7 +250,8 @@ class LogicOhli24(LogicModuleBase):
|
||||
|
||||
# logger.debug(f"LogicAniLife.headers::: {LogicOhli24.headers}")
|
||||
context = await browser.new_context(
|
||||
extra_http_headers=LogicOhli24.headers, ignore_https_errors=True
|
||||
extra_http_headers=LogicOhli24.headers,
|
||||
ignore_https_errors=True,
|
||||
)
|
||||
# await context.add_cookies(LogicOhli24.cookies)
|
||||
|
||||
@@ -336,7 +345,9 @@ class LogicOhli24(LogicModuleBase):
|
||||
),
|
||||
arg=arg,
|
||||
)
|
||||
return render_template("sample.html", title="%s - %s" % (P.package_name, sub))
|
||||
return render_template(
|
||||
"sample.html", title="%s - %s" % (P.package_name, sub)
|
||||
)
|
||||
|
||||
# @staticmethod
|
||||
def process_ajax(self, sub, req):
|
||||
@@ -421,7 +432,8 @@ class LogicOhli24(LogicModuleBase):
|
||||
count += 1
|
||||
notify = {
|
||||
"type": "success",
|
||||
"msg": "%s 개의 에피소드를 큐에 추가 하였습니다." % count,
|
||||
"msg": "%s 개의 에피소드를 큐에 추가 하였습니다."
|
||||
% count,
|
||||
}
|
||||
socketio.emit(
|
||||
"notify", notify, namespace="/framework", broadcast=True
|
||||
@@ -512,7 +524,8 @@ class LogicOhli24(LogicModuleBase):
|
||||
whitelist_program = P.ModelSetting.get("ohli24_auto_code_list")
|
||||
|
||||
whitelist_programs = [
|
||||
str(x.strip()) for x in whitelist_program.replace("\n", "|").split("|")
|
||||
str(x.strip())
|
||||
for x in whitelist_program.replace("\n", "|").split("|")
|
||||
]
|
||||
|
||||
if code not in whitelist_programs:
|
||||
@@ -557,11 +570,21 @@ class LogicOhli24(LogicModuleBase):
|
||||
# Todo: 스케쥴링 함수 미구현
|
||||
logger.debug(f"ohli24 scheduler_function::=========================")
|
||||
|
||||
content_code_list = P.ModelSetting.get_list("ohli24_auto_code_list", "|")
|
||||
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/"]
|
||||
|
||||
week = ["월요일", "화요일", "수요일", "목요일", "금요일", "토요일", "일요일"]
|
||||
week = [
|
||||
"월요일",
|
||||
"화요일",
|
||||
"수요일",
|
||||
"목요일",
|
||||
"금요일",
|
||||
"토요일",
|
||||
"일요일",
|
||||
]
|
||||
today = date.today()
|
||||
# print(today)
|
||||
# print()
|
||||
@@ -855,9 +878,9 @@ class LogicOhli24(LogicModuleBase):
|
||||
entity = {}
|
||||
entity["link"] = item.xpath(".//a/@href")[0]
|
||||
entity["code"] = entity["link"].split("/")[-1]
|
||||
entity["title"] = item.xpath(".//div[@class='post-title']/text()")[
|
||||
0
|
||||
].strip()
|
||||
entity["title"] = item.xpath(
|
||||
".//div[@class='post-title']/text()"
|
||||
)[0].strip()
|
||||
# logger.debug(item.xpath(".//div[@class='img-item']/img/@src")[0])
|
||||
# logger.debug(item.xpath(".//div[@class='img-item']/img/@data-ezsrc")[0])
|
||||
# entity["image_link"] = item.xpath(".//div[@class='img-item']/img/@src")[
|
||||
@@ -897,12 +920,12 @@ class LogicOhli24(LogicModuleBase):
|
||||
entity = {}
|
||||
entity["link"] = item.xpath(".//a/@href")[0]
|
||||
entity["code"] = entity["link"].split("/")[-1]
|
||||
entity["title"] = item.xpath(".//div[@class='post-title']/text()")[
|
||||
0
|
||||
].strip()
|
||||
entity["image_link"] = item.xpath(".//div[@class='img-item']/img/@src")[
|
||||
0
|
||||
].replace("..", P.ModelSetting.get("ohli24_url"))
|
||||
entity["title"] = item.xpath(
|
||||
".//div[@class='post-title']/text()"
|
||||
)[0].strip()
|
||||
entity["image_link"] = item.xpath(
|
||||
".//div[@class='img-item']/img/@src"
|
||||
)[0].replace("..", P.ModelSetting.get("ohli24_url"))
|
||||
data["ret"] = "success"
|
||||
data["anime_list"].append(entity)
|
||||
|
||||
@@ -941,11 +964,13 @@ class LogicOhli24(LogicModuleBase):
|
||||
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["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]
|
||||
entity["code"] = item.xpath(
|
||||
".//div[@class='img-item']/img/@alt"
|
||||
)[0]
|
||||
|
||||
data["ret"] = "success"
|
||||
data["anime_list"].append(entity)
|
||||
@@ -992,7 +1017,9 @@ class LogicOhli24(LogicModuleBase):
|
||||
# discord_client.close()
|
||||
|
||||
webhook = DiscordWebhook(url=self.discord_webhook_url)
|
||||
embed = DiscordEmbed(title=self.discord_title, color=self.discord_color)
|
||||
embed = DiscordEmbed(
|
||||
title=self.discord_title, color=self.discord_color
|
||||
)
|
||||
embed.set_timestamp()
|
||||
path = self.last_post_title
|
||||
embed.set_image(url=latest_post_image)
|
||||
@@ -1096,7 +1123,10 @@ class LogicOhli24(LogicModuleBase):
|
||||
}
|
||||
|
||||
page_content = LogicOhli24.session.get(
|
||||
url, headers=LogicOhli24.headers, timeout=timeout, proxies=proxies
|
||||
url,
|
||||
headers=LogicOhli24.headers,
|
||||
timeout=timeout,
|
||||
proxies=proxies,
|
||||
)
|
||||
response_data = page_content.text
|
||||
# logger.debug(response_data)
|
||||
@@ -1225,7 +1255,9 @@ class Ohli24QueueEntity(FfmpegQueueEntity):
|
||||
# iframe_url = "https://ohli24.org/"
|
||||
iframe_src = f'{P.ModelSetting.get("ohli24_url")}{iframe_url}'
|
||||
|
||||
iframe_html = LogicOhli24.get_html(iframe_src, headers=headers, timeout=600)
|
||||
iframe_html = LogicOhli24.get_html(
|
||||
iframe_src, headers=headers, timeout=600
|
||||
)
|
||||
|
||||
# print(iframe_html)
|
||||
pattern = r"<iframe src=\"(.*?)\" allowfullscreen>"
|
||||
@@ -1238,7 +1270,9 @@ class Ohli24QueueEntity(FfmpegQueueEntity):
|
||||
logger.debug(f"iframe_src:::> {iframe_src}")
|
||||
|
||||
# resp1 = requests.get(iframe_src, headers=headers, timeout=600).text
|
||||
resp1 = LogicOhli24.get_html(iframe_src, headers=headers, timeout=600)
|
||||
resp1 = LogicOhli24.get_html(
|
||||
iframe_src, headers=headers, timeout=600
|
||||
)
|
||||
# logger.info("resp1::>> %s", resp1)
|
||||
soup3 = BeautifulSoup(resp1, "lxml")
|
||||
# packed_pattern = re.compile(r'\\{*(eval.+)*\\}', re.MULTILINE | re.DOTALL)
|
||||
@@ -1260,7 +1294,9 @@ class Ohli24QueueEntity(FfmpegQueueEntity):
|
||||
logger.debug(type(packed_script))
|
||||
unpack_script = jsbeautifier.beautify(str(packed_script))
|
||||
|
||||
p1 = re.compile(r"(\"tracks\".*\])\,\"captions\"", re.MULTILINE | re.DOTALL)
|
||||
p1 = re.compile(
|
||||
r"(\"tracks\".*\])\,\"captions\"", re.MULTILINE | re.DOTALL
|
||||
)
|
||||
m2 = re.search(
|
||||
r"(\"tracks\".*\]).*\"captions\"",
|
||||
unpack_script,
|
||||
@@ -1278,8 +1314,10 @@ class Ohli24QueueEntity(FfmpegQueueEntity):
|
||||
video_hash = iframe_src.split("/")
|
||||
video_hashcode = re.sub(r"index\.php\?data=", "", video_hash[-1])
|
||||
self._vi = video_hashcode
|
||||
|
||||
logger.debug(f"video_hash::> {video_hash}")
|
||||
video_info_url = f"{video_hash[0]}//{video_hash[2]}/player/index.php?data={video_hashcode}&do=getVideo"
|
||||
video_info_url = f"{video_hash[0]}//michealcdn.com/player/index.php?data={video_hashcode}&do=getVideo"
|
||||
# video_info_url = f"{video_hash[0]}//michealcdn.com/player/index.php?data={video_hashcode}&do=getVideo"
|
||||
# print('hash:::', video_hash)
|
||||
logger.debug(f"video_info_url::: {video_info_url}")
|
||||
|
||||
@@ -1328,7 +1366,9 @@ class Ohli24QueueEntity(FfmpegQueueEntity):
|
||||
if "crazypatutu.com" in self.url:
|
||||
self.headers["Referer"] = iframe_src
|
||||
|
||||
match = re.compile(r'NAME="(?P<quality>.*?)"').search(stream_info[0])
|
||||
match = re.compile(r'NAME="(?P<quality>.*?)"').search(
|
||||
stream_info[0]
|
||||
)
|
||||
self.quality = "720P"
|
||||
if match is not None:
|
||||
self.quality = match.group("quality")
|
||||
@@ -1344,7 +1384,10 @@ class Ohli24QueueEntity(FfmpegQueueEntity):
|
||||
|
||||
if match:
|
||||
self.content_title = match.group("title").strip()
|
||||
if "season" in match.groupdict() and match.group("season") is not None:
|
||||
if (
|
||||
"season" in match.groupdict()
|
||||
and match.group("season") is not None
|
||||
):
|
||||
self.season = int(match.group("season"))
|
||||
|
||||
# epi_no = 1
|
||||
@@ -1377,7 +1420,9 @@ class Ohli24QueueEntity(FfmpegQueueEntity):
|
||||
)
|
||||
else:
|
||||
folder_name = self.content_title
|
||||
folder_name = Util.change_text_for_use_filename(folder_name.strip())
|
||||
folder_name = Util.change_text_for_use_filename(
|
||||
folder_name.strip()
|
||||
)
|
||||
self.savepath = os.path.join(self.savepath, folder_name)
|
||||
if P.ModelSetting.get_bool("ohli24_auto_make_season_folder"):
|
||||
self.savepath = os.path.join(
|
||||
@@ -1407,7 +1452,9 @@ class Ohli24QueueEntity(FfmpegQueueEntity):
|
||||
|
||||
|
||||
class ModelOhli24Item(db.Model):
|
||||
__tablename__ = "{package_name}_ohli24_item".format(package_name=P.package_name)
|
||||
__tablename__ = "{package_name}_ohli24_item".format(
|
||||
package_name=P.package_name
|
||||
)
|
||||
__table_args__ = {"mysql_collate": "utf8_general_ci"}
|
||||
__bind_key__ = P.package_name
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
@@ -1492,20 +1539,26 @@ class ModelOhli24Item(db.Model):
|
||||
conditions = []
|
||||
for tt in tmp:
|
||||
if tt != "":
|
||||
conditions.append(cls.filename.like("%" + tt.strip() + "%"))
|
||||
conditions.append(
|
||||
cls.filename.like("%" + tt.strip() + "%")
|
||||
)
|
||||
query = query.filter(or_(*conditions))
|
||||
elif search.find(",") != -1:
|
||||
tmp = search.split(",")
|
||||
for tt in tmp:
|
||||
if tt != "":
|
||||
query = query.filter(cls.filename.like("%" + tt.strip() + "%"))
|
||||
query = query.filter(
|
||||
cls.filename.like("%" + tt.strip() + "%")
|
||||
)
|
||||
else:
|
||||
query = query.filter(cls.filename.like("%" + search + "%"))
|
||||
if option == "completed":
|
||||
query = query.filter(cls.status == "completed")
|
||||
|
||||
query = (
|
||||
query.order_by(desc(cls.id)) if order == "desc" else query.order_by(cls.id)
|
||||
query.order_by(desc(cls.id))
|
||||
if order == "desc"
|
||||
else query.order_by(cls.id)
|
||||
)
|
||||
return query
|
||||
|
||||
|
||||
Reference in New Issue
Block a user