Skip to content

04. ⚖️Filter →

The Administrator edited this page May 5, 2020 · 1 revision

The Filter Tab

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.

Filter Instance

A filter instance is the named group of single filter layers that can be used on the API results.

Filter ID

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.

Filter Group Layers

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.

Filter

Here you can pick from the filter catalog the filters you wish to use. Currently, there are only three.

  1. None. This does nothing, but can be used as a holder for filter parameters that have been switched off.
  2. 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.
  3. yt_array_front. This filter will trim off any items from the array, leaving only the top X results.

Filter Parameters

Here you can input any parameters that the filter requires. The parameters are always in an associative array format, but with different keys/values.

Filter Catalog

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:

none

Does nothing. No Parameters.

remove_item_if_regex

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,

  1. 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.

  2. regex which is the REGEX string to use to match. Use REGEXR.com to help you out here. The function used is PHP's preg_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.

yt_array_front

This is a simple filter that will return only the first X amount of items. It takes two parameters:

  1. length, which is how many results to return.
  2. location. This is the location of the items 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.