|
25 | 25 | if not typing.TYPE_CHECKING: |
26 | 26 | unshuffle = get_image_order = None |
27 | 27 |
|
| 28 | +locale_cookie_regex = re.compile(r"(?<=x-lz-locale=)([^;]*)(?=;|$)") |
| 29 | + |
28 | 30 |
|
29 | 31 | def _load_unshuffler(): |
30 | 32 | global unshuffle, get_image_order |
@@ -208,7 +210,14 @@ async def fetch_episode_information(self, *, reload: bool = False) -> None: |
208 | 210 | else: |
209 | 211 | break |
210 | 212 | else: |
211 | | - raise WebtoonIdError.from_webtoon_id(self.webtoon_id, LezhinComicsScraper) |
| 213 | + # locale__summary__xxL_0 |
| 214 | + if any("locale__summary" in p.attrs.sget("class") for p in res.match("p")): |
| 215 | + webtoon_locale = self.LOCALES[self.language_code] |
| 216 | + matched = self.cookie and locale_cookie_regex.search(self.cookie) |
| 217 | + cookie_locale = f' ({matched[0].replace("_", "-")})' if matched else "" |
| 218 | + raise AuthenticationError(f"Locale of the cookie{cookie_locale} is unmatched with webtoon's locale ({webtoon_locale}). Try change the locale and get cookie again.") |
| 219 | + else: |
| 220 | + raise WebtoonIdError.from_webtoon_id(self.webtoon_id, LezhinComicsScraper) |
212 | 221 |
|
213 | 222 | selector = "body > div.lzCntnr > div > div > ul > li > a" # cspell: ignore Cntnr |
214 | 223 | episode_dates: list[str] = [] |
@@ -356,6 +365,8 @@ def _set_cookie(self, value: str) -> None: |
356 | 365 | # _LZ_AT에서 직접 bearer를 추출함 |
357 | 366 | if bearer is not None: |
358 | 367 | self.bearer = f"Bearer {bearer}" |
| 368 | + # _LZ_FS에 locale이 저장되어 있기 때문에 이렇게 바꿔도 작동하지 않음. |
| 369 | + # value = locale_cookie_regex.sub(self.LOCALES[self.language_code].replace("-", "_"), value) |
359 | 370 | super()._set_cookie(value) |
360 | 371 |
|
361 | 372 | @classmethod |
|
0 commit comments