Skip to content

Commit

Permalink
Bugfix for listing filters with stash v0.23.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbokster committed Nov 5, 2023
1 parent dd56b6d commit 6c33b93
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
14 changes: 7 additions & 7 deletions resources/lib/criterion_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
def parse(criterions):
filter = {}

for json_criterion in criterions:
criterion = json.loads(json_criterion)

type = criterion['type']
if type in ('sceneIsMissing', 'imageIsMissing', 'performerIsMissing', 'galleryIsMissing', 'tagIsMissing', 'studioIsMissing', 'studioIsMissing'):
for criterion in criterions:
if criterion in ('sceneIsMissing', 'imageIsMissing', 'performerIsMissing', 'galleryIsMissing', 'tagIsMissing', 'studioIsMissing', 'studioIsMissing'):
filter['is_missing'] = criterion['value']
else:
filter[type] = parse_criterion(criterion)
filter[criterion] = parse_criterion(criterions[criterion])

return filter

Expand All @@ -23,7 +20,10 @@ def parse_criterion(criterion):

value = criterion.get('value', '')
if isinstance(value, dict) and 'depth' in value:
filter['value'] = list(map(lambda v: v['id'], value['items']))
if(value['items'] is None):
filter['value'] = list(map(lambda v: v['id'], value['excluded']))
else:
filter['value'] = list(map(lambda v: v['id'], value['items']))
filter['depth'] = value['depth']
elif isinstance(value, dict) and not value.keys() - ['value', 'value2']:
filter.update(value)
Expand Down
9 changes: 5 additions & 4 deletions resources/lib/listing/listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@ def _set_title(self, title: str):
def _create_item_from_filter(self, filter: dict, override_title=None) -> [(xbmcgui.ListItem, str)]:
title = override_title if override_title is not None else filter['name']
item = xbmcgui.ListItem(label=title)
filter_data = json.loads(filter['filter'])
criterion_json = json.dumps(criterion_parser.parse(filter_data['c']))
find_filter = filter['find_filter']
object_filter = filter['object_filter']
criterion_json = json.dumps(criterion_parser.parse(object_filter))

url = utils.get_url(list=self._type,
title=title,
criterion=criterion_json,
sort_field=filter_data.get('sortby'),
sort_dir=filter_data.get('sortdir')
sort_field=find_filter.get('sort'),
sort_dir=find_filter.get('direction')
)
return item, url
22 changes: 18 additions & 4 deletions resources/lib/stash_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,15 @@ def find_saved_filters(self, mode):
query = """
query findSavedFilters($mode: FilterMode!) {
findSavedFilters(mode: $mode) {
name
filter
name,
object_filter,
find_filter {
q
page
per_page
sort
direction
}
}
}
"""
Expand All @@ -352,8 +359,15 @@ def find_default_filter(self, mode):
query = """
query findDefaultFilter($mode: FilterMode!) {
findDefaultFilter(mode: $mode) {
name
filter
name,
object_filter,
find_filter {
q
page
per_page
sort
direction
}
}
}
"""
Expand Down

0 comments on commit 6c33b93

Please sign in to comment.