@taki9/omdb
v4.1.4
Published
OMDb API for my userscripts
Downloads
1
Readme
@ifelix18/omdb
OMDb API for userscripts
Usage
Setup and initialization
Include it in your script in the Metadata Block via @require
specifying the version, also specifying the required API to be granted (GM.getValue
, GM.setValue
, GM.xmlHttpRequest
) via @grant
, and the domain which can be allowed to be retrieved by GM.xmlHttpRequest
via @connect
, like this:
// ...
// @require https://cdn.jsdelivr.net/npm/@ifelix18/[email protected]/lib/index.min.js
// @grant GM.getValue
// @grant GM.setValue
// @grant GM.xmlHttpRequest
// @connect omdbapi.com
// ...
Next, initialize the library:
const omdb = new OMDb({
api_key: '<your_api_key>', // <string> - OMDb API Key [required]
api_url: 'https://www.omdbapi.com', // <string> - OMDb API URL
debug: false, // <boolean> - Debug
cache: { // Cache options
active: false, // <boolean> - Cache status
time_to_live: 3600 // <number> - Time to Live cache, in seconds
}
})
API requests
Search by ID
Returns infos related to a specific IMDb ID.
| Parameter | Required | Type | Description | | --------- | -------- | ------- | ------------------------------------------ | | id | Yes | string | IMDb ID | | type | No | string | Type of result (movie, series, or episode) | | year | No | number | Year of release | | plot | No | string | Type of plot (short or full) | | tomatoes | No | boolean | Include Rotten Tomatoes data |
omdb.id({
id: 'tt0088763'
}).then((data) => {
console.log(data) // <object> - Response from API request
}).catch((error) => console.error(error))
Search by Title
Returns infos related to the first result with a specific title.
| Parameter | Required | Type | Description | | --------- | -------- | ------- | ------------------------------------------ | | title | Yes | string | Item title | | type | No | string | Type of result (movie, series, or episode) | | year | No | number | Year of release | | plot | No | string | Type of plot (short or full) | | tomatoes | No | boolean | Include Rotten Tomatoes data |
omdb.title({
title: 'Back to the Future'
}).then((data) => {
console.log(data) // <object> - Response from API request
}).catch((error) => console.error(error))
Search by Search
Returns all results of a specific search.
| Parameter | Required | Type | Description | | --------- | -------- | ------ | ------------------------------------------ | | title | Yes | string | Item title | | type | No | string | Type of result (movie, series, or episode) | | year | No | number | Year of release | | page | No | number | Results page (1-100) |
omdb.search({
search: 'Back to the Future'
}).then((data) => {
console.log(data) // <object> - Response from API request
}).catch((error) => console.error(error))
Credits
This product uses the OMDb API but is not endorsed or certified by OMDb.