Skip to content

Filtering Plugin and Library Directories

jurialmunkey edited this page Dec 6, 2023 · 8 revisions

Content Path Filter

🔖 v1.1.20+
SkinVariables provides a way to apply advanced filtering to plugin and library directories

Syntax

plugin://script.skinvariables/?info=get_filter_dir&library=video
&filter_key=KEY&filter_value=VALUE&filter_operator=OPERATOR
&exclude_key=KEY&exclude_value=VALUE&exclude_operator=OPERATOR
&&PROTOCOL://DIRECTORY/URL

❗ The plugin://URI examples in this wiki are split onto multiple lines for readability. When used in skin content tags, the URI should be written on a single line.

Path to Filter

Supply the path to be filtered at the end of the URL with a double-ampersand &&.

💡 Get all items in videodb://movies/titles that have Action in ListItem.Genre

plugin://script.skinvariables/?info=get_filter_dir&library=video
&filter_key=genre&filter_value=Action
&&videodb://movies/titles/

Combining Paths

Additional paths can be supplied with additional double-ampersands. The extra paths will be combined into one list. Use the optional &no_label_dupes=True param to avoid having multiple items with the same label being added.

💡 Get all Action movies from library plus first page from TMDbHelper popular movies

plugin://script.skinvariables/?info=get_filter_dir&library=video&no_label_dupes=True
&filter_key=genre&filter_value=Action
&&videodb://movies/titles/
&&plugin://plugin.video.themoviedb.helper/?info=popular&tmdb_type=movie

Library Param

Use the &library=video param to specify whether content target is video or music so that the correct infolabels and properties are retrieved.

DBType Param

Some library dbtypes (e.g. "season" and "set") are returned as "unknown" by JSONRPC's Files.GetDirectory method. The unknown dbtype is converted by default to "video".

The incorrect dbtype might affect the viewtypes available and how content behaves, so, to counteract this issue, the &dbtype=season param can be used to specify a different fallback dbtype for unknown types.

Exclusion and Filter Parameters

Param Description
filter_key=KEY&filter_value=VALUE Only include items where the specified key matches the specified value.
exclude_key=KEY&exclude_value=VALUE Exclude all items that have the specified key that matches the specified value.

Filter Examples

Examples Description
filter_key=genre&filter_value=Action / Adventure Checking for multiple values is possible by using a /. For instance, this filter will include items that have Action or Adventure as a genre
exclude_key=year&exclude_value=2000&exclude_operator=lt By default the standard comparison uses the IN operator to check if the specified VALUE is IN the KEY. The operator can be changed to any standard python operator. For instance, this exclusion will exclude items where the year is LESS THAN (lt) 2000.

Additional Filters

Additional filters can be supplied by naming the filter with a double underscore __

filter_key__one=genre&filter_value__one=Action&filter_key__two=studio&filter_value__two=HBO

Sorting Parameters

Param Description
sort_by=year&sort_how=desc Sort items according to the value of the specified key. By default will be sorted in ascending order. Specify the sort_how=desc param to reverse sort order.

Filter as a file

SkinVariables allows saving your filter params to a JSON formatted file which can be read later. For example, save your params in skin/extras/filters/myfilter.json and retrieve using the content path:

plugin://script.skinvariables/?info=get_params_file&&special://skin/extras/filters/myfilter.json

Example: Combine movies and tvshows from library, filter by items with the genre Action and sort by title.

{
    "info": "get_filter_dir",
    "library": "video",
    "paths": [
        "library://video/movies/titles.xml/",
        "library://video/tvshows/titles.xml/"
    ],
    "sort_by": "title",
    "sort_how": "",
    "filter_key": "genre",
    "filter_value": "Action"
}

Restrictions

Some details are not currently available for performance reasons. In particular, cast members are not retrieved.