Skip to content

Commit

Permalink
Merge pull request #373 from nicojust/fix-favorite-metadata-output
Browse files Browse the repository at this point in the history
fix favorite_counts output in metadata
  • Loading branch information
RicterZ authored Jan 15, 2025
2 parents a166898 + ce25051 commit e7ff5da
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion nhentai/doujinshi.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, name=None, pretty_name=None, id=None, favorite_counts=0, img_
['Groups', self.info.groups],
['Languages', self.info.languages],
['Tags', self.info.tags],
['Favorite Counts', self.info.favorite_counts],
['Favorite Counts', self.favorite_counts],
['URL', self.url],
['Pages', self.pages],
]
Expand Down
6 changes: 2 additions & 4 deletions nhentai/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,12 @@ def doujinshi_parser(id_, counter=0):
title = doujinshi_info.find('h1').text
pretty_name = doujinshi_info.find('h1').find('span', attrs={'class': 'pretty'}).text
subtitle = doujinshi_info.find('h2')
favorite_counts = str(doujinshi_info.find('span', class_='nobold').find('span', class_='count'))
if favorite_counts is None:
favorite_counts = '0'
favorite_counts = doujinshi_info.find('span', class_='nobold').find('span', class_='count')

doujinshi['name'] = title
doujinshi['pretty_name'] = pretty_name
doujinshi['subtitle'] = subtitle.text if subtitle else ''
doujinshi['favorite_counts'] = favorite_counts.strip()
doujinshi['favorite_counts'] = int(favorite_counts.text.strip()) if favorite_counts else 0

doujinshi_cover = html.find('div', attrs={'id': 'cover'})
# img_id = re.search('/galleries/([0-9]+)/cover.(jpg|png|gif|webp)$',
Expand Down
2 changes: 1 addition & 1 deletion nhentai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def generate_metadata_file(output_dir, doujinshi_obj):

fields = ['TITLE', 'ORIGINAL TITLE', 'AUTHOR', 'ARTIST', 'GROUPS', 'CIRCLE', 'SCANLATOR',
'TRANSLATOR', 'PUBLISHER', 'DESCRIPTION', 'STATUS', 'CHAPTERS', 'PAGES',
'TAGS', 'TYPE', 'LANGUAGE', 'RELEASED', 'READING DIRECTION', 'CHARACTERS',
'TAGS', 'FAVORITE COUNTS', 'TYPE', 'LANGUAGE', 'RELEASED', 'READING DIRECTION', 'CHARACTERS',
'SERIES', 'PARODY', 'URL']

temp_dict = CaseInsensitiveDict(dict(doujinshi_obj.table))
Expand Down

0 comments on commit e7ff5da

Please sign in to comment.