42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
from data.kakao_cookie import CLIENT_ID
|
|
|
|
class KakaoRequest:
|
|
def __init__(self, timestamp, nonce):
|
|
self.client_id = CLIENT_ID
|
|
self.timestamp = timestamp
|
|
self.nonce = nonce
|
|
self.app_id = f"KP.{self.client_id}.{self.timestamp + 1}"
|
|
|
|
def get_episode_headers(self, ant):
|
|
return {
|
|
"Accept": "application/json, text/plain, */*",
|
|
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
"Accept-Language": "ko",
|
|
"Cache-Control": "no-cache",
|
|
"Cookie": f"theme=dark; _kp_collector={self.app_id}; atn={ant}",
|
|
"Dnt": "1",
|
|
"Origin": "https://webtoon.kakao.com/",
|
|
"Pragma": "no-cache",
|
|
"Referer": "https://webtoon.kakao.com/",
|
|
"Sec-Ch-Ua": '"Not A(Brand";v="99", "Microsoft Edge";v="121", "Chromium";v="121"',
|
|
"Sec-Ch-Ua-Mobile": "?0",
|
|
"Sec-Ch-Ua-Platform": '"Windows"',
|
|
"Sec-Fetch-Dest": "script",
|
|
"Sec-Fetch-Mode": "no-cors",
|
|
"Sec-Fetch-Site": "cross-site",
|
|
"Sec-Gpc": "1",
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
|
|
}
|
|
|
|
def get_post_headers(self, ant):
|
|
return self.get_episode_headers(ant) | {"Content-Type": "application/json;charset=UTF-8"}
|
|
|
|
def get_payload(self, episode_id):
|
|
return {
|
|
"id": episode_id,
|
|
"type": "AES_CBC_WEBP",
|
|
"nonce": self.nonce,
|
|
"timestamp": str(self.timestamp),
|
|
"download": False,
|
|
"webAppId": self.app_id,
|
|
} |