This method handles catalog requests, including search.
args
- request object; parameters described below
A promise that resolves to an object containing { metas: [] }
with an array of Meta Preview Object
The resolving object can also include the following cache related properties:
-
{ cacheMaxAge: int }
(in seconds) which sets theCache-Control
header tomax-age=$cacheMaxAge
and overwrites the global cache time set inserveHTTP
options -
{ staleRevalidate: int }
(in seconds) which sets theCache-Control
header tostale-while-revalidate=$staleRevalidate
-
{ staleError: int }
(in seconds) which sets theCache-Control
header tostale-if-error=$staleError
type
- type of the catalog's content; e.g. movie
, series
, channel
, tv
(see Content Types)
id
- string id of the catalog that is requested; these are set in the Manifest Object
extra
- object that holds additional properties; defined below
config
- object with user settings, see Manifest - User Data
If you wish to use these parameters, you'll need to specify them in extra
for the catalog in the addon manifest
search
- set in the extra
object; string to search for in the catalog
genre
- set in the extra
object; a string to filter the feed or search results by genres
skip
- set in the extra
object; used for catalog pagination, refers to the number of items skipped from the beginning of the catalog; the standard page size in Stremio is 100, so the skip
value will be a multiple of 100; if you return less than 100 items, Stremio will consider this to be the end of the catalog
builder.defineCatalogHandler(function(args) {
if (args.type === 'movie' && args.id === 'top') {
// we will only respond with Big Buck Bunny
// to both feed and search requests
const meta = {
id: 'tt1254207',
name: 'Big Buck Bunny',
releaseInfo: '2008',
poster: 'https://image.tmdb.org/t/p/w600_and_h900_bestv2/uVEFQvFMMsg4e6yb03xOfVsDz4o.jpg',
posterShape: 'poster',
banner: 'https://image.tmdb.org/t/p/original/aHLST0g8sOE1ixCxRDgM35SKwwp.jpg',
type: 'movie'
}
if (args.extra && args.extra.search) {
// catalog search request
if (args.extra.search == 'big buck bunny') {
return Promise.resolve({ metas: [meta] })
} else {
return Promise.resolve({ metas: [] })
}
} else {
// catalog feed request
return Promise.resolve({ metas: [meta] })
}
} else {
// otherwise return empty catalog
return Promise.resolve({ metas: [] })
}
})