mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-07-01 16:09:28 +02:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
14b3c82248 | |||
4577e9df9a | |||
de157ccb7f | |||
126bbe8d49 | |||
8546b9e759 | |||
6ff9751c30 | |||
f316c3243b |
@ -5,9 +5,8 @@ language: python
|
||||
python:
|
||||
- 2.7
|
||||
- 2.6
|
||||
- 3.3
|
||||
- 3.4
|
||||
- 3.5.2
|
||||
- 3.6
|
||||
- 3.7
|
||||
|
||||
install:
|
||||
- python setup.py install
|
||||
@ -15,3 +14,4 @@ install:
|
||||
script:
|
||||
- NHENTAI=https://nhentai.net nhentai --search umaru
|
||||
- NHENTAI=https://nhentai.net nhentai --id=152503,146134 -t 10 --output=/tmp/
|
||||
- NHENTAI=https://nhentai.net nhentai -l nhentai_test:nhentai --output=/tmp/
|
||||
|
@ -1,3 +1,3 @@
|
||||
__version__ = '0.2.12'
|
||||
__version__ = '0.2.14'
|
||||
__author__ = 'RicterZ'
|
||||
__email__ = 'ricterzheng@gmail.com'
|
||||
|
@ -27,7 +27,7 @@ def login_parser(username, password):
|
||||
|
||||
s.get(constant.LOGIN_URL)
|
||||
content = s.get(constant.LOGIN_URL).content
|
||||
html = BeautifulSoup(content, 'html.parser').encode("ascii")
|
||||
html = BeautifulSoup(content, 'html.parser')
|
||||
csrf_token_elem = html.find('input', attrs={'name': 'csrfmiddlewaretoken'})
|
||||
|
||||
if not csrf_token_elem:
|
||||
@ -44,14 +44,22 @@ def login_parser(username, password):
|
||||
logger.error('Login failed, please check your username and password')
|
||||
exit(1)
|
||||
|
||||
html = BeautifulSoup(s.get(constant.FAV_URL).content, 'html.parser').encode("ascii")
|
||||
html = BeautifulSoup(s.get(constant.FAV_URL).content, 'html.parser')
|
||||
count = html.find('span', attrs={'class': 'count'})
|
||||
if not count:
|
||||
logger.error('Cannot get count of your favorites, maybe login failed.')
|
||||
|
||||
count = int(count.text.strip('(').strip(')'))
|
||||
pages = count / 25
|
||||
pages += 1 if count % (25 * pages) else 0
|
||||
if count == 0:
|
||||
logger.warning('No favorites found')
|
||||
return []
|
||||
pages = int(count / 25)
|
||||
|
||||
if pages:
|
||||
pages += 1 if count % (25 * pages) else 0
|
||||
else:
|
||||
pages = 1
|
||||
|
||||
logger.info('Your have %d favorites in %d pages.' % (count, pages))
|
||||
|
||||
if os.getenv('DEBUG'):
|
||||
@ -68,7 +76,7 @@ def login_parser(username, password):
|
||||
for page in range(1, pages+1):
|
||||
try:
|
||||
logger.info('Getting doujinshi id of page %d' % page)
|
||||
resp = s.get(constant.FAV_URL + '?page=%d' % page).content
|
||||
resp = s.get(constant.FAV_URL + '?page=%d' % page).text
|
||||
ids = doujinshi_id.findall(resp)
|
||||
requests_ = threadpool.makeRequests(doujinshi_parser, ids, _callback)
|
||||
[thread_pool.putRequest(req) for req in requests_]
|
||||
|
@ -2,4 +2,4 @@ requests>=2.5.0
|
||||
BeautifulSoup4>=4.0.0
|
||||
threadpool>=1.2.7
|
||||
tabulate>=0.7.5
|
||||
future>=0.15.2
|
||||
future>=0.15.2threadpool==1.3.2
|
||||
|
Reference in New Issue
Block a user