mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-19 18:31:24 +02:00
parse dojinshi ids
This commit is contained in:
parent
ae5e32512e
commit
d62d43d204
@ -1,8 +1,10 @@
|
|||||||
#coding: utf-8
|
#coding: utf-8
|
||||||
import sys
|
import sys
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
from itertools import ifilter
|
||||||
from logger import logger
|
from logger import logger
|
||||||
|
|
||||||
|
|
||||||
def banner():
|
def banner():
|
||||||
print ''' _ _ _ _
|
print ''' _ _ _ _
|
||||||
_ __ | | | | ___ _ __ | |_ __ _(_)
|
_ __ | | | | ___ _ __ | |_ __ _(_)
|
||||||
@ -17,9 +19,10 @@ def cmd_parser():
|
|||||||
parser.add_option('--search', type='string', dest='keyword', action='store', help='keyword searched')
|
parser.add_option('--search', type='string', dest='keyword', action='store', help='keyword searched')
|
||||||
parser.add_option('--download', dest='is_download', action='store_true', help='download dojinshi or not')
|
parser.add_option('--download', dest='is_download', action='store_true', help='download dojinshi or not')
|
||||||
parser.add_option('--id', type='int', dest='id', action='store', help='dojinshi id of nhentai')
|
parser.add_option('--id', type='int', dest='id', action='store', help='dojinshi id of nhentai')
|
||||||
|
parser.add_option('--ids', type='str', dest='ids', action='store', help='dojinshi id set, e.g. 1,2,3')
|
||||||
parser.add_option('--path', type='string', dest='saved_path', action='store', default='',
|
parser.add_option('--path', type='string', dest='saved_path', action='store', default='',
|
||||||
help='path which save the dojinshi downloaded')
|
help='path which save the dojinshi')
|
||||||
parser.add_option('--threads', type='int', dest='threads', action='store', default=1,
|
parser.add_option('--threads', '-t', type='int', dest='threads', action='store', default=1,
|
||||||
help='thread count of download dojinshi')
|
help='thread count of download dojinshi')
|
||||||
args, _ = parser.parse_args()
|
args, _ = parser.parse_args()
|
||||||
|
|
||||||
@ -29,11 +32,16 @@ def cmd_parser():
|
|||||||
logger.critical('Maximum number of used threads is 10')
|
logger.critical('Maximum number of used threads is 10')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if args.is_download and not args.id:
|
if args.ids:
|
||||||
logger.critical('Dojinshi id is required for downloading')
|
_ = map(lambda id: id.strip(), args.ids.split(','))
|
||||||
|
args.ids = set(map(int, ifilter(lambda id: id.isdigit(), _)))
|
||||||
|
|
||||||
|
if args.is_download and not args.id and not args.ids:
|
||||||
|
logger.critical('Dojinshi id/ids is required for downloading')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if args.keyword:
|
if args.keyword:
|
||||||
logger.critical(u'并没有做这个功能_(:3」∠)_')
|
logger.critical(u'并没有做这个功能_(:3」∠)_')
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
@ -5,6 +5,7 @@ from bs4 import BeautifulSoup
|
|||||||
from constant import DETAIL_URL
|
from constant import DETAIL_URL
|
||||||
from hentai.logger import logger
|
from hentai.logger import logger
|
||||||
|
|
||||||
|
|
||||||
def dojinshi_parser(id):
|
def dojinshi_parser(id):
|
||||||
logger.debug('Fetching dojinshi information')
|
logger.debug('Fetching dojinshi information')
|
||||||
if not isinstance(id, (int, )) or (isinstance(id, (str, )) and not id.isdigit()):
|
if not isinstance(id, (int, )) or (isinstance(id, (str, )) and not id.isdigit()):
|
||||||
@ -47,5 +48,9 @@ def dojinshi_parser(id):
|
|||||||
return dojinshi
|
return dojinshi
|
||||||
|
|
||||||
|
|
||||||
|
def search_parser(data):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print dojinshi_parser(32271)
|
print dojinshi_parser(32271)
|
Loading…
x
Reference in New Issue
Block a user