Skip to content

Commit

Permalink
Fixes for add_category/genre_when_multi_category settings. #884
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmXinu committed Sep 20, 2022
1 parent d11d4c5 commit 3fffd22
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions fanficfare/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,14 +1079,16 @@ def getList(self,listname,
## there's more than one category value. Does not work
## consistently well if you try to include_in_ chain genre
## back into category--breaks with fandoms sites like AO3
if listname == 'genre' and self.getConfig('add_genre_when_multi_category') and len(self.getList('category',
removeallentities=False,
# to avoid inf loops if genre/cat substs
includelist=includelist+[listname],
doreplacements=False,
skip_cache=True,
seen_list=seen_list
)) > 1:
if( listname == 'genre' and self.getConfig('add_genre_when_multi_category')
and len(self.getList('category',
removeallentities=False,
# to avoid inf loops if genre/cat substs
includelist=includelist+[listname],
doreplacements=False,
skip_cache=True,
seen_list=seen_list
)) > 1
and self.getConfig('add_genre_when_multi_category') not in retlist ):
retlist.append(self.getConfig('add_genre_when_multi_category'))

if retlist:
Expand All @@ -1111,15 +1113,24 @@ def getList(self,listname,
# remove dups and sort.
retlist = sorted(list(set(retlist)))

## Add value of add_genre_when_multi_category to
## category if there's more than one category
## value (before this, obviously). Applied
## *after* doReplacements. For normalization
## crusaders who want Crossover as a category
## instead of genre. Moved after dedup'ing so
## consolidated category values don't count.
if listname == 'category' and self.getConfig('add_category_when_multi_category') and len(retlist) > 1:
retlist.append(self.getConfig('add_category_when_multi_category'))
## Add value of add_genre_when_multi_category to
## category if there's more than one category
## value (before this, obviously). Applied
## *after* doReplacements. For normalization
## crusaders who want Crossover as a category
## instead of genre. Moved after dedup'ing so
## consolidated category values don't count.
if( listname == 'category'
and self.getConfig('add_category_when_multi_category')
and len(retlist) > 1
and self.getConfig('add_category_when_multi_category') not in retlist ):
retlist.append(self.getConfig('add_category_when_multi_category'))
## same sort as above, but has to be after due to
## changing list. unique filter not needed: 'not
## in retlist' check
if not (listname in ('author','authorUrl','authorId') or self.getConfig('keep_in_order_'+listname)):
retlist = sorted(list(set(retlist)))

else:
retlist = []

Expand Down

0 comments on commit 3fffd22

Please sign in to comment.