- for row in response['result']:
- title = row['title']['english']
- title = title[:85] + '..' if len(title) > 85 else title
- result.append({'id': row['id'], 'title': title})
+ doujinshi['img_id'] = img_id.group(1)
+ doujinshi['ext'] = ext
+
+ for _ in doujinshi_info.find_all('div', class_='tag-container field-name'):
+ if re.search('Pages:', _.text):
+ pages = _.find('span', class_='name').string
+ doujinshi['pages'] = int(pages)
+
+ # gain information of the doujinshi
+ information_fields = doujinshi_info.find_all('div', attrs={'class': 'field-name'})
+ 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:
+ data = [sub_field.find('span', attrs={'class': 'name'}).contents[0].strip() for sub_field in
+ 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
+
+
+def old_search_parser(keyword, sorting='date', page=1):
+ logger.debug('Searching doujinshis of keyword {0}'.format(keyword))
+ response = request('get', url=constant.SEARCH_URL, params={'q': keyword, 'page': page, 'sort': sorting}).content