Compare commits

...

7 Commits

Author SHA1 Message Date
14b3c82248 remove \r 2018-08-11 09:28:39 +08:00
4577e9df9a fix 2018-08-11 09:24:16 +08:00
de157ccb7f Merge branch 'master' of github.com:RicterZ/nhentai 2018-08-11 09:19:31 +08:00
126bbe8d49 add a test 2018-08-11 09:18:00 +08:00
8546b9e759 fix bug #24 2018-08-11 09:17:05 +08:00
6ff9751c30 fix 2018-07-01 12:50:37 +08:00
f316c3243b 0.2.12 2018-04-19 17:29:23 +08:00
9 changed files with 244 additions and 236 deletions

View File

@ -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/

View File

@ -1,3 +1,3 @@
__version__ = '0.2.12'
__version__ = '0.2.14'
__author__ = 'RicterZ'
__email__ = 'ricterzheng@gmail.com'

View File

@ -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
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_]

View File

@ -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