diff --git a/nhentai/constant.py b/nhentai/constant.py index 9307887..585250b 100644 --- a/nhentai/constant.py +++ b/nhentai/constant.py @@ -35,6 +35,11 @@ FAV_URL = f'{BASE_URL}/favorites/' IMAGE_URL = f'{urlparse(BASE_URL).scheme}://i.{urlparse(BASE_URL).hostname}/galleries' +IMAGE_URL_MIRRORS = [ + f'{urlparse(BASE_URL).scheme}://i3.{urlparse(BASE_URL).hostname}' + f'{urlparse(BASE_URL).scheme}://i5.{urlparse(BASE_URL).hostname}' + f'{urlparse(BASE_URL).scheme}://i7.{urlparse(BASE_URL).hostname}' +] NHENTAI_HOME = get_nhentai_home() NHENTAI_HISTORY = os.path.join(NHENTAI_HOME, 'history.sqlite3') diff --git a/nhentai/downloader.py b/nhentai/downloader.py index b852352..227a0f0 100644 --- a/nhentai/downloader.py +++ b/nhentai/downloader.py @@ -67,10 +67,14 @@ class Downloader(Singleton): try: response = request('get', url, stream=True, timeout=self.timeout, proxies=proxy) if response.status_code != 200: - raise NHentaiImageNotExistException - - except NHentaiImageNotExistException as e: - raise e + path = urlparse(url).path + for mirror in constant.IMAGE_URL_MIRRORS: + print(f'{mirror}{path}') + mirror_url = f'{mirror}{path}' + response = request('get', mirror_url, stream=True, + timeout=self.timeout, proxies=proxy) + if response.status_code == 200: + break except Exception as e: i += 1 diff --git a/nhentai/parser.py b/nhentai/parser.py index e1e24ff..65d92cd 100644 --- a/nhentai/parser.py +++ b/nhentai/parser.py @@ -135,7 +135,7 @@ def doujinshi_parser(id_, counter=0): logger.warning(f'Error: {e}, ignored') return None - print(response) + # print(response) html = BeautifulSoup(response, 'html.parser') doujinshi_info = html.find('div', attrs={'id': 'info'})