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