doujinshi['subtitle'] = subtitle.text if subtitle else ''
doujinshi_cover = html.find('div', attrs={'id': 'cover'})
- img_id = re.search('/galleries/([\d]+)/cover\.(jpg|png)$', doujinshi_cover.a.img.attrs['data-src'])
+ img_id = re.search('/galleries/([\d]+)/cover\.(jpg|png|gif)$', doujinshi_cover.a.img.attrs['data-src'])
ext = []
for i in html.find_all('div', attrs={'class': 'thumb-container'}):
# gain information of the doujinshi
information_fields = doujinshi_info.find_all('div', attrs={'class': 'field-name'})
- needed_fields = ['Characters', 'Artists', 'Languages', 'Tags']
+ needed_fields = ['Characters', 'Artists', 'Languages', 'Tags', 'Parodies', 'Groups', 'Categories']
for field in information_fields:
field_name = field.contents[0].strip().strip(':')
if field_name in needed_fields:
field.find_all('a', attrs={'class': 'tag'})]
doujinshi[field_name.lower()] = ', '.join(data)
+ time_field = doujinshi_info.find('time')
+ if time_field.has_attr('datetime'):
+ doujinshi['date'] = time_field['datetime']
return doujinshi
tabulate(tabular_data=doujinshi_list, headers=headers, tablefmt='rst'))
-def tag_parser(tag_name, sorting='date', max_page=1):
+def tag_parser(tag_name, sorting='date', max_page=1, index=0):
result = []
tag_name = tag_name.lower()
- tag_name = tag_name.replace(' ', '-')
-
+ if ',' in tag_name:
+ tag_name = [i.strip().replace(' ', '-') for i in tag_name.split(',')]
+ else:
+ tag_name = tag_name.strip().replace(' ', '-')
if sorting == 'date':
sorting = ''
for p in range(1, max_page + 1):
- logger.debug('Fetching page {0} for doujinshi with tag \'{1}\''.format(p, tag_name))
- response = request('get', url='%s/%s/%s?page=%d' % (constant.TAG_URL, tag_name, sorting, p)).content
+ if isinstance(tag_name, str):
+ logger.debug('Fetching page {0} for doujinshi with tag \'{1}\''.format(p, tag_name))
+ response = request('get', url='%s/%s/%s?page=%d' % (constant.TAG_URL[index], tag_name, sorting, p)).content
+ result += _get_title_and_id(response)
+ else:
+ for i in tag_name:
+ logger.debug('Fetching page {0} for doujinshi with tag \'{1}\''.format(p, i))
+ response = request('get',
+ url='%s/%s/%s?page=%d' % (constant.TAG_URL[index], i, sorting, p)).content
+ result += _get_title_and_id(response)
- result += _get_title_and_id(response)
if not result:
logger.error('Cannot find doujinshi id of tag \'{0}\''.format(tag_name))
return
doujinshi['name'] = response['title']['english']
doujinshi['subtitle'] = response['title']['japanese']
doujinshi['img_id'] = response['media_id']
- doujinshi['ext'] = ''.join(map(lambda s: s['t'], response['images']['pages']))
+ doujinshi['ext'] = ''.join([i['t'] for i in response['images']['pages']])
doujinshi['pages'] = len(response['images']['pages'])
# gain information of the doujinshi
- needed_fields = ['character', 'artist', 'language', 'tag']
+ needed_fields = ['character', 'artist', 'language', 'tag', 'parody', 'group', 'category']
for tag in response['tags']:
tag_type = tag['type']
if tag_type in needed_fields: