Compare commits
2 Commits
62c790b687
...
02a7d33f35
| Author | SHA1 | Date | |
|---|---|---|---|
| 02a7d33f35 | |||
| 270ea09336 |
Binary file not shown.
142
logic_anilife.py
142
logic_anilife.py
@@ -77,6 +77,8 @@ class LogicAniLife(LogicModuleBase):
|
||||
current_data = None
|
||||
referer = None
|
||||
origin_url = None
|
||||
episode_url = None
|
||||
cookies = None
|
||||
|
||||
session = requests.Session()
|
||||
headers = {
|
||||
@@ -84,6 +86,7 @@ class LogicAniLife(LogicModuleBase):
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
||||
"Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7",
|
||||
"Referer": "",
|
||||
"Cookie": "SPSI=ef307b8c976fac3363cdf420c9ca40a9; SPSE=+PhK0/uGUBMCZIgXplNjzqW3K2kXLybiElDTtOOiboHiBXO7Tp/9roMW7FplGZuGCUo3i4Fwx5VIUG57Zj6VVw==; anilife_csrf=b1eb92529839d7486169cd91e4e60cd2; UTGv2=h45f897818578a5664b31004b95a9992d273; _ga=GA1.1.281412913.1662803695; _ga_56VYJJ7FTM=GS1.1.1662803695.1.0.1662803707.0.0.0; DCST=pE9; DSR=w2XdPUpwLWDqkLpWXfs/5TiO4mtNv5O3hqNhEr7GP1kFoRBBzbFRpR+xsJd9A+E29M+we7qIvJxQmHQTjDNLuQ==; DCSS=696763EB4EA5A67C4E39CFA510FE36F19B0912C; DGCC=RgP; spcsrf=8a6b943005d711258f2f145a8404d873; sp_lit=F9PWLXyxvZbOyk3eVmtTlg==; PRLST=wW; adOtr=70fbCc39867"
|
||||
# "Cookie": ""
|
||||
# "Cookie": "_ga=GA1.1.578607927.1660813724; __gads=ID=10abb8b98b6828ae-2281c943a9d500fd:T=1660813741:RT=1660813741:S=ALNI_MYU_iB2lBgSrEQUBwhKpNsToaqQ8A; SL_G_WPT_TO=ko; SL_GWPT_Show_Hide_tmp=1; SL_wptGlobTipTmp=1; SPSI=944c237cdd8606d80e5e330a0f332d03; SPSE=itZcXMDuso0ktWnDkV2G0HVwWEctCgDjrcFMlEQ5C745wqvp1pEEddrsAsjPUBjl6/8+9Njpq1IG3wt/tVag7w==; sbtsck=jav9aILa6Ofn0dEQr5DhDq5rpbd1JUoNgKwxBpZrqYd+CM=; anilife_csrf=54ee9d15c87864ee5e2538a63d894ad6; UTGv2=h46b326af644f4ac5d0eb1502881136b3750; DCST=pE9; __gpi=UID=000008ba227e99e0:T=1660813741:RT=1661170429:S=ALNI_MaJHIVJIGpQ5nTE9lvypKQxJnn10A; DSR=GWyTLTvSMF/lQD77ojQkGyl+7JvTudkSwV1GKeNVUcWEBa/msln9zzsBj7lj+89ywSRBM34Ol73AKf+KHZ9bZA==; DCSS=9D44115EC4CE12CADB88A005DC65A3CD74A211E; DGCC=zdV; spcsrf=fba136251afc6b5283109fc920322c70; sp_lit=kw0Xkp66eQ7bV0f0tNClhg==; PRLST=gt; adOtr=2C4H9c4d78d; _ga_56VYJJ7FTM=GS1.1.1661168661.18.1.1661173389.0.0.0",
|
||||
}
|
||||
@@ -129,58 +132,34 @@ class LogicAniLife(LogicModuleBase):
|
||||
logger.error(traceback.format_exc())
|
||||
return data
|
||||
|
||||
# @staticmethod
|
||||
# def get_html(url, cached=False):
|
||||
#
|
||||
# try:
|
||||
# print("cloudflare protection bypass ==================")
|
||||
# return LogicLinkkfYommi.get_html_cloudflare(url)
|
||||
# # return LogicLinkkfYommi.get_html_playwright(url)
|
||||
# #
|
||||
# # if (
|
||||
# # socket.gethostbyname(socket.gethostname()) == "192.168.0.32"
|
||||
# # or socket.gethostbyname(socket.gethostname()) == "127.0.0.1"
|
||||
# # ):
|
||||
# # print("dev================")
|
||||
# # # print("test")
|
||||
# # # import undetected_chromedriver as uc
|
||||
# # #
|
||||
# # # driver = uc.Chrome(use_subprocess=True)
|
||||
# # # driver.get(url)
|
||||
# #
|
||||
# # return LogicLinkkfYommi.get_html_cloudflare(url)
|
||||
#
|
||||
# if LogicLinkkfYommi.session is None:
|
||||
# if cached:
|
||||
# logger.debug("cached===========++++++++++++")
|
||||
#
|
||||
# LogicLinkkfYommi.session = CachedSession(
|
||||
# os.path.join(cache_path, "linkkf_cache"),
|
||||
# backend="sqlite",
|
||||
# expire_after=300,
|
||||
# cache_control=True,
|
||||
# )
|
||||
# # print(f"{cache_path}")
|
||||
# # print(f"cache_path:: {LogicLinkkfYommi.session.cache}")
|
||||
# else:
|
||||
# LogicLinkkfYommi.session = requests.Session()
|
||||
#
|
||||
# LogicLinkkfYommi.referer = "https://linkkf.app"
|
||||
#
|
||||
# LogicLinkkfYommi.headers["referer"] = LogicLinkkfYommi.referer
|
||||
#
|
||||
# # logger.debug(
|
||||
# # f"get_html()::LogicLinkkfYommi.referer = {LogicLinkkfYommi.referer}"
|
||||
# # )
|
||||
# page = LogicLinkkfYommi.session.get(url, headers=LogicLinkkfYommi.headers)
|
||||
# # logger.info(f"page: {page}")
|
||||
#
|
||||
# return page.content.decode("utf8", errors="replace")
|
||||
# # return page.text
|
||||
# # return page.content
|
||||
# except Exception as e:
|
||||
# logger.error("Exception:%s", e)
|
||||
# logger.error(traceback.format_exc())
|
||||
@staticmethod
|
||||
def get_html_requests(url, referer=None, stream=False, timeout=5):
|
||||
data = ""
|
||||
try:
|
||||
print("get_html_requests ==================")
|
||||
|
||||
# cj = browser_cookie3.chrome(domain_name="anilife.live")
|
||||
referer = "https://anilife.live/"
|
||||
|
||||
if LogicAniLife.session is None:
|
||||
LogicAniLife.session = requests.session()
|
||||
|
||||
# logger.debug('get_html :%s', url)
|
||||
LogicAniLife.headers["Referer"] = "" if referer is None else referer
|
||||
LogicAniLife.headers[
|
||||
"Cookie"
|
||||
] = "_ga=GA1.1.578607927.1660813724; __gads=ID=10abb8b98b6828ae-2281c943a9d500fd:T=1660813741:RT=1660813741:S=ALNI_MYU_iB2lBgSrEQUBwhKpNsToaqQ8A; sbtsck=javuwDzcOJqUyweM1OQeNGzHbjoHp7Cgw44XnPdM738c3E=; SPSI=e48379959d54a6a62cc7abdcafdb2761; SPSE=h5HfMGLJzLqzNafMD3YaOvHSC9xfh77CcWdKvexp/z5N5OsTkIiYSCudQhFffEfk/0pcOTVf0DpeV0RoNopzig==; anilife_csrf=b93b9f25a12a51cf185805ec4de7cf9d; UTGv2=h46b326af644f4ac5d0eb1502881136b3750; __gpi=UID=000008ba227e99e0:T=1660813741:RT=1660912282:S=ALNI_MaJHIVJIGpQ5nTE9lvypKQxJnn10A; DSR=SXPX8ELcRgh6N/9rNgjpQoNfaX2DRceeKYR0/ul7qTI9gApWQpZxr8jgymf/r0HsUT551vtOv2CMWpIn0Hd26A==; DCSS=89508000A76BBD939F6DDACE5BD9EB902D2212A; DGCC=Wdm; adOtr=7L4Xe58995d; spcsrf=6554fa003bf6a46dd9b7417acfacc20a; _ga_56VYJJ7FTM=GS1.1.1660912281.10.1.1660912576.0.0.0; PRLST=EO"
|
||||
|
||||
LogicAniLife.headers["Referer"] = referer
|
||||
|
||||
page_content = LogicAniLife.session.get(
|
||||
url, headers=headers, timeout=timeout, allow_redirects=True
|
||||
)
|
||||
data = page_content.text
|
||||
except Exception as e:
|
||||
logger.error("Exception:%s", e)
|
||||
logger.error(traceback.format_exc())
|
||||
return data
|
||||
|
||||
@staticmethod
|
||||
async def get_html_playwright(
|
||||
@@ -231,12 +210,14 @@ class LogicAniLife(LogicModuleBase):
|
||||
LogicAniLife.headers["Referer"] = "https://anilife.live/detail/id/471"
|
||||
# print(LogicAniLife.headers)
|
||||
|
||||
LogicAniLife.headers["Referer"] = LogicAniLife.episode_url
|
||||
|
||||
if referer is not None:
|
||||
LogicAniLife.headers["Referer"] = referer
|
||||
|
||||
print(LogicAniLife.headers)
|
||||
|
||||
logger.debug(f"LogicAniLife.headers::: {LogicAniLife.headers}")
|
||||
context = await browser.new_context(extra_http_headers=LogicAniLife.headers)
|
||||
await context.add_cookies(LogicAniLife.cookies)
|
||||
|
||||
# LogicAniLife.headers["Cookie"] = cookie_value
|
||||
|
||||
@@ -256,13 +237,13 @@ class LogicAniLife(LogicModuleBase):
|
||||
page.on("request", set_cookie)
|
||||
|
||||
print(f'Referer:: {LogicAniLife.headers["Referer"]}')
|
||||
await page.set_extra_http_headers(LogicAniLife.headers)
|
||||
# await page.set_extra_http_headers(LogicAniLife.headers)
|
||||
|
||||
await page.goto(
|
||||
url, wait_until="load", referer=LogicAniLife.headers["Referer"]
|
||||
)
|
||||
# page.wait_for_timeout(10000)
|
||||
await asyncio.sleep(3.5)
|
||||
await asyncio.sleep(2.9)
|
||||
|
||||
# await page.reload()
|
||||
|
||||
@@ -307,8 +288,8 @@ class LogicAniLife(LogicModuleBase):
|
||||
# from playwright_stealth import stealth_sync
|
||||
|
||||
with sync_playwright() as p:
|
||||
# browser = p.chromium.launch(headless=headless)
|
||||
browser = p.webkit.launch(headless=headless)
|
||||
browser = p.chromium.launch(headless=headless)
|
||||
# browser = p.webkit.launch(headless=headless)
|
||||
# context = browser.new_context(
|
||||
# user_agent=ua,
|
||||
# )
|
||||
@@ -320,6 +301,8 @@ class LogicAniLife(LogicModuleBase):
|
||||
|
||||
context = browser.new_context(extra_http_headers=LogicAniLife.headers)
|
||||
|
||||
context.add_cookies(LogicAniLife.cookies)
|
||||
|
||||
# LogicAniLife.headers["Cookie"] = cookie_value
|
||||
|
||||
# context.set_extra_http_headers(LogicAniLife.headers)
|
||||
@@ -359,7 +342,7 @@ class LogicAniLife(LogicModuleBase):
|
||||
}"""
|
||||
)
|
||||
|
||||
print(vod_url)
|
||||
logger.debug(f"vod_url:: {vod_url}")
|
||||
|
||||
print(f"run at {time.time() - start} sec")
|
||||
|
||||
@@ -370,9 +353,18 @@ class LogicAniLife(LogicModuleBase):
|
||||
html_content = LogicAniLife.get_html_playwright(
|
||||
vod_url, False, referer="https://anilife.live"
|
||||
)
|
||||
|
||||
# html_content = LogicAniLife.get_html(
|
||||
# vod_url, referer="https://anilife.live"
|
||||
# )
|
||||
# html_content = LogicAniLife.get_html_requests(
|
||||
# vod_url, referer="https://anilife.live"
|
||||
# )
|
||||
|
||||
print(f"html_content:: {html_content}")
|
||||
output_json = html_to_json.convert(html_content)
|
||||
print(output_json)
|
||||
resolution = output_json["html"][0]["body"][0]["_value"]
|
||||
logger.debug(f"output_json:: {resolution}")
|
||||
|
||||
return vod_url
|
||||
|
||||
@@ -381,6 +373,7 @@ class LogicAniLife(LogicModuleBase):
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium import webdriver
|
||||
from selenium_stealth import stealth
|
||||
from webdriver_manager.chrome import ChromeDriverManager
|
||||
import time
|
||||
|
||||
options = webdriver.ChromeOptions()
|
||||
@@ -392,7 +385,10 @@ class LogicAniLife(LogicModuleBase):
|
||||
options.add_experimental_option("useAutomationExtension", False)
|
||||
# 크롬드라이버 경로
|
||||
driver_path = "./bin/Darwin/chromedriver"
|
||||
driver = webdriver.Chrome(executable_path=driver_path, chrome_options=options)
|
||||
# driver = webdriver.Chrome(executable_path=driver_path, chrome_options=options)
|
||||
driver = webdriver.Chrome(
|
||||
ChromeDriverManager().install(), chrome_options=options
|
||||
)
|
||||
stealth(
|
||||
driver,
|
||||
languages=["en-US", "en"],
|
||||
@@ -403,7 +399,20 @@ class LogicAniLife(LogicModuleBase):
|
||||
fix_hairline=True,
|
||||
)
|
||||
driver.get(url)
|
||||
|
||||
driver.refresh()
|
||||
logger.debug(f"current_url:: {driver.current_url}")
|
||||
# logger.debug(f"current_cookie:: {driver.get_cookies()}")
|
||||
cookies_list = driver.get_cookies()
|
||||
|
||||
cookies_dict = {}
|
||||
for cookie in cookies_list:
|
||||
cookies_dict[cookie["name"]] = cookie["value"]
|
||||
|
||||
logger.debug(cookies_dict)
|
||||
LogicAniLife.cookies = cookies_list
|
||||
# LogicAniLife.headers["Cookie"] = driver.get_cookies()
|
||||
LogicAniLife.episode_url = driver.current_url
|
||||
time.sleep(1)
|
||||
elem = driver.find_element(By.XPATH, "//*")
|
||||
source_code = elem.get_attribute("outerHTML")
|
||||
@@ -691,6 +700,7 @@ class LogicAniLife(LogicModuleBase):
|
||||
"va": link,
|
||||
"_vi": _vi,
|
||||
"content_code": code,
|
||||
"ep_url": url,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -894,11 +904,13 @@ class AniLifeQueueEntity(FfmpegQueueEntity):
|
||||
"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}")
|
||||
|
||||
referer = "https://anilife.live/g/l?id=13fd4d28-ff18-4764-9968-7e7ea7347c51"
|
||||
referer = LogicAniLife.episode_url
|
||||
|
||||
# text = requests.get(url, headers=headers).text
|
||||
# text = LogicAniLife.get_html_seleniumwire(url, referer=referer, wired=True)
|
||||
@@ -906,6 +918,9 @@ class AniLifeQueueEntity(FfmpegQueueEntity):
|
||||
referer_url = (
|
||||
"https://anilife.live/g/l?id=d4be1e0e-301b-403b-be1b-cf19f3ccfd23"
|
||||
)
|
||||
referer_url = LogicAniLife.episode_url
|
||||
|
||||
logger.debug(f"LogicAniLife.episode_url:: {LogicAniLife.episode_url}")
|
||||
text = asyncio.run(
|
||||
LogicAniLife.get_html_playwright(
|
||||
url,
|
||||
@@ -925,14 +940,15 @@ class AniLifeQueueEntity(FfmpegQueueEntity):
|
||||
regex = r"(?P<jawcloud_url>http?s:\/\/.*=jawcloud)"
|
||||
match = re.compile(regex).search(text)
|
||||
|
||||
jawcloud_url = None
|
||||
print(match)
|
||||
if match:
|
||||
jawcloud_url = match.group("jawcloud_url")
|
||||
|
||||
print(jawcloud_url)
|
||||
print(f"jawcloud_url:: {jawcloud_url}")
|
||||
|
||||
vod_1080p_url = LogicAniLife.get_vod_url(jawcloud_url)
|
||||
print(vod_1080p_url)
|
||||
print(f"vod_1080p_url:: {vod_1080p_url}")
|
||||
except Exception as e:
|
||||
P.logger.error("Exception:%s", e)
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
@@ -76,6 +76,7 @@ class LogicOhli24(LogicModuleBase):
|
||||
"ohli24_uncompleted_auto_enqueue": "False",
|
||||
"ohli24_image_url_prefix_series": "https://www.jetcloud.cc/series/",
|
||||
"ohli24_image_url_prefix_episode": "https://www.jetcloud-list.cc/thumbnail/",
|
||||
"ohli24_discord_notify": "True",
|
||||
}
|
||||
current_headers = None
|
||||
current_data = None
|
||||
@@ -323,7 +324,7 @@ class LogicOhli24(LogicModuleBase):
|
||||
|
||||
url = f'{P.ModelSetting.get("ohli24_url")}/bbs/board.php?bo_table=ing&sca={week[today.weekday()]}'
|
||||
|
||||
print(url)
|
||||
# print(url)
|
||||
|
||||
if "all" in content_code_list:
|
||||
ret_data = LogicOhli24.get_auto_anime_info(self, url=url)
|
||||
@@ -467,6 +468,8 @@ class LogicOhli24(LogicModuleBase):
|
||||
"상영시간": "_show_time",
|
||||
"상영일": "_release_date",
|
||||
"개봉년도": "_release_year",
|
||||
"개봉일": "_opening_date",
|
||||
"런타임": "_run_time",
|
||||
}
|
||||
|
||||
list_body_li = tree.xpath('//ul[@class="list-body"]/li')
|
||||
|
||||
Reference in New Issue
Block a user