mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 06:04:15 +00:00
Add support for 'group' and 'having' keys in smart filters (#1286)
* Add support for 'group' and 'having' keys in SmartFilterMixin - fixes #1285 * Add `group` and `having` fields to `additionalFields` list in `FilteringType` class - This should allow passing the parsed filters back into `search()`. Co-Authored-By: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> --------- Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
This commit is contained in:
parent
556b4b3da4
commit
4924320715
2 changed files with 11 additions and 3 deletions
|
@ -2727,7 +2727,9 @@ class FilteringType(PlexObject):
|
|||
('id', 'integer', 'Rating Key'),
|
||||
('index', 'integer', f'{self.type.capitalize()} Number'),
|
||||
('lastRatedAt', 'date', f'{self.type.capitalize()} Last Rated'),
|
||||
('updatedAt', 'date', 'Date Updated')
|
||||
('updatedAt', 'date', 'Date Updated'),
|
||||
('group', 'string', 'SQL Group By Statement'),
|
||||
('having', 'string', 'SQL Having Clause')
|
||||
]
|
||||
|
||||
if self.type == 'movie':
|
||||
|
@ -2778,11 +2780,14 @@ class FilteringType(PlexObject):
|
|||
|
||||
manualFields = []
|
||||
for field, fieldType, fieldTitle in additionalFields:
|
||||
if field not in {'group', 'having'}:
|
||||
field = f"{prefix}{field}"
|
||||
fieldXML = (
|
||||
f'<Field key="{prefix}{field}" '
|
||||
f'<Field key="{field}" '
|
||||
f'title="{fieldTitle}" '
|
||||
f'type="{fieldType}"/>'
|
||||
)
|
||||
|
||||
manualFields.append(self._manuallyLoadXML(fieldXML, FilteringField))
|
||||
|
||||
return manualFields
|
||||
|
|
|
@ -116,11 +116,14 @@ class SmartFilterMixin:
|
|||
filtersDict = {}
|
||||
special_keys = {"type", "sort"}
|
||||
integer_keys = {"includeGuids", "limit"}
|
||||
reserved_keys = special_keys | integer_keys
|
||||
as_is_keys = {"group", "having"}
|
||||
reserved_keys = special_keys | integer_keys | as_is_keys
|
||||
while feed:
|
||||
key, value = feed.popleft()
|
||||
if key in integer_keys:
|
||||
filtersDict[key] = int(value)
|
||||
elif key in as_is_keys:
|
||||
filtersDict[key] = value
|
||||
elif key == "type":
|
||||
filtersDict["libtype"] = utils.reverseSearchType(value)
|
||||
elif key == "sort":
|
||||
|
|
Loading…
Reference in a new issue