mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-20 02:41:19 +02:00
add cookie check
This commit is contained in:
parent
58b2b644c1
commit
1af195d727
@ -11,7 +11,7 @@ from nhentai.doujinshi import Doujinshi
|
|||||||
from nhentai.downloader import Downloader
|
from nhentai.downloader import Downloader
|
||||||
from nhentai.logger import logger
|
from nhentai.logger import logger
|
||||||
from nhentai.constant import BASE_URL
|
from nhentai.constant import BASE_URL
|
||||||
from nhentai.utils import generate_html, generate_cbz, generate_main_html
|
from nhentai.utils import generate_html, generate_cbz, generate_main_html, check_cookie
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -24,6 +24,9 @@ def main():
|
|||||||
if PROXY != {}:
|
if PROXY != {}:
|
||||||
logger.info('Using proxy: {0}'.format(PROXY))
|
logger.info('Using proxy: {0}'.format(PROXY))
|
||||||
|
|
||||||
|
# check your cookie
|
||||||
|
check_cookie()
|
||||||
|
|
||||||
doujinshi_ids = []
|
doujinshi_ids = []
|
||||||
doujinshi_list = []
|
doujinshi_list = []
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
from __future__ import unicode_literals, print_function
|
from __future__ import unicode_literals, print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
import os
|
import os
|
||||||
import string
|
import string
|
||||||
import zipfile
|
import zipfile
|
||||||
@ -22,6 +23,15 @@ def request(method, url, **kwargs):
|
|||||||
return getattr(session, method)(url, proxies=constant.PROXY, verify=False, **kwargs)
|
return getattr(session, method)(url, proxies=constant.PROXY, verify=False, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def check_cookie():
|
||||||
|
response = request('get', constant.BASE_URL).text
|
||||||
|
username = re.findall('"/users/\d+/(.*?)"', response)
|
||||||
|
if not username:
|
||||||
|
logger.error('Cannot get your username, please check your cookie or use `nhentai --cookie` to set your cookie')
|
||||||
|
else:
|
||||||
|
logger.info('Login successfully! Your username: {}'.format(username[0]))
|
||||||
|
|
||||||
|
|
||||||
class _Singleton(type):
|
class _Singleton(type):
|
||||||
""" A metaclass that creates a Singleton base class when called. """
|
""" A metaclass that creates a Singleton base class when called. """
|
||||||
_instances = {}
|
_instances = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user