-
Notifications
You must be signed in to change notification settings - Fork 2
04. ⚖️Filter →
The filters allow you to distil the results down to the items you actually require. This is done through groups of individual filters that are run sequentially.
A filter instance is the named group of single filter layers that can be used on the API results.
The Filter ID is used to identify the Filter group to run on the scraper tab. The scraper tab is automatically populated via all of the Filter ID's created on this page.
Here you can select each filter to run and the parameters to pass to the filter. You are able to add as many filter layers as you wish.
Here you can pick from the filter catalog the filters you wish to use. Currently, there are only three.
- None. This does nothing, but can be used as a holder for filter parameters that have been switched off.
- Remove_item_if_regex. This is a powerful filter that allows you to specify a Regex match to remove an item. See below for more details.
- yt_array_front. This filter will trim off any items from the array, leaving only the top X results.
Here you can input any parameters that the filter requires. The parameters are always in an associative array format, but with different keys/values.
This is a READ-ONLY section that will show you a list of name of available filters, their description and any parameters required. Below is that current list:
Does nothing. No Parameters.
This filter allows you to do a REGEX match on any returned field in each returned item from the API. If there is a REGEX match in the field, the item will be removed from the results. This is useful for filtering out results that aren't wanted.
The filter takes two parameters,
-
item_field
which determines the field to perform the REGEX on. This uses the class style arrow hyphen and outer triangle bracket to move down the item object. By using the Search Tab's 'Search Report, you can see how the response will be structured. You can then navigate the structure using the
->` format. -
regex
which is the REGEX string to use to match. Use REGEXR.com to help you out here. The function used is PHP'spreg_match()
, so look into the documentation of that to see how to use the REGEX.
As an example,
['item_field' => 'snippet->title', 'regex' => '/Roblox|GTA/' ]
This will look at the snippet->title value and look for the words Roblox
or GTA
. If any of the items' titles has either of those words, the item will be removed.
This is a simple filter that will return only the first X amount of items. It takes two parameters:
-
length
, which is how many results to return. -
location
. This is the location of theitems
in the returned structure to limit. Uses the hyphen arrow->
format to navigate the structure.
For example:
[ 'length' => '10', 'location' => 'items' ]
Will trim the results down to the first 10.