Merge pull request #138 from RicterZ/revert-134-master

Revert "Fix fatal error and keep index of id which from file"
This commit is contained in:
Ricter Zheng 2020-06-26 12:47:25 +08:00 committed by GitHub
commit db80408024
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 16 deletions

View File

@ -186,10 +186,8 @@ def cmd_parser():
if args.file: if args.file:
with open(args.file, 'r') as f: with open(args.file, 'r') as f:
_ = [int(i.strip()) for i in f.readlines() if i.strip().isdigit()] _ = [i.strip() for i in f.readlines()]
# args.id = list(set(int(i) for i in _ if i.isdigit())) args.id = set(int(i) for i in _ if i.isdigit())
args.id = list(set(_))
args.id.sort(key=_.index)
if (args.is_download or args.is_show) and not args.id and not args.keyword and \ if (args.is_download or args.is_show) and not args.id and not args.keyword and \
not args.tag and not args.artist and not args.character and \ not args.tag and not args.artist and not args.character and \
@ -206,8 +204,8 @@ def cmd_parser():
if args.threads <= 0: if args.threads <= 0:
args.threads = 1 args.threads = 1
# elif args.threads > 15: elif args.threads > 15:
# logger.critical('Maximum number of used threads is 15') logger.critical('Maximum number of used threads is 15')
# exit(1) exit(1)
return args return args

View File

@ -178,21 +178,21 @@ def doujinshi_parser(id_):
doujinshi['img_id'] = img_id.group(1) doujinshi['img_id'] = img_id.group(1)
doujinshi['ext'] = ext doujinshi['ext'] = ext
# pages = 0 pages = 0
# for _ in doujinshi_info.find_all('div', class_=''): for _ in doujinshi_info.find_all('div', class_=''):
# pages = re.search('([\d]+) pages', _.text) pages = re.search('([\d]+) pages', _.text)
# if pages: if pages:
# pages = pages.group(1) pages = pages.group(1)
# break break
# doujinshi['pages'] = int(pages) doujinshi['pages'] = int(pages)
doujinshi['pages'] = len(ext)
# gain information of the doujinshi # gain information of the doujinshi
information_fields = doujinshi_info.find_all('div', attrs={'class': 'field-name'}) information_fields = doujinshi_info.find_all('div', attrs={'class': 'field-name'})
needed_fields = ['Characters', 'Artists', 'Languages', 'Tags', 'Parodies', 'Groups', 'Categories'] needed_fields = ['Characters', 'Artists', 'Languages', 'Tags', 'Parodies', 'Groups', 'Categories']
for field in information_fields: for field in information_fields:
field_name = field.contents[0].strip().strip(':') field_name = field.contents[0].strip().strip(':')
if field_name in needed_fields: if field_name in needed_fields:
data = [sub_field.contents[0].text.strip() for sub_field in data = [sub_field.contents[0].strip() for sub_field in
field.find_all('a', attrs={'class': 'tag'})] field.find_all('a', attrs={'class': 'tag'})]
doujinshi[field_name.lower()] = ', '.join(data) doujinshi[field_name.lower()] = ', '.join(data)