Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d35f3b8
Showing
6 changed files
with
13,481 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.coda.json | ||
node_modules | ||
.coda-pack.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type * as coda from "@codahq/packs-sdk"; | ||
|
||
// Config | ||
|
||
export async function getMovie(context: coda.ExecutionContext, query: string) { | ||
const url = | ||
"https://imdb8.p.rapidapi.com/title/find?q=" + encodeURIComponent(query); | ||
const response = await context.fetcher.fetch({ | ||
method: "GET", | ||
headers: { | ||
"x-rapidapi-host": "imdb8.p.rapidapi.com", | ||
}, | ||
url: url, | ||
}); | ||
const movie = response.body.results[0]; | ||
return { | ||
// grab the ID (tt0109830) out of the API's id response (/title/tt0109830/) | ||
IMDBId: movie.id.replace("/title/", "").replace("/", ""), | ||
Title: movie.title, | ||
Year: movie.year, | ||
Runtime: movie.runningTimeInMinutes + " minutes", | ||
Poster: movie.image.url, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as coda from "@codahq/packs-sdk"; | ||
import * as helpers from "./helpers"; | ||
import * as schemas from "./schemas"; | ||
|
||
export const pack = coda.newPack({ version: "0.1.0" }); | ||
|
||
/* -------------------------------------------------------------------------- */ | ||
/* API */ | ||
/* -------------------------------------------------------------------------- */ | ||
|
||
pack.addNetworkDomain("rapidapi.com"); | ||
pack.setUserAuthentication({ | ||
type: coda.AuthenticationType.CustomHeaderToken, | ||
headerName: "x-rapidapi-key", | ||
instructionsUrl: "https://coda.io/@nickhe/imdb-pack", | ||
}); | ||
|
||
/* -------------------------------------------------------------------------- */ | ||
/* Column Formats */ | ||
/* -------------------------------------------------------------------------- */ | ||
|
||
pack.addColumnFormat({ | ||
name: "IMDB Movie", | ||
instructions: "Shows movie details from IMDB", | ||
formulaName: "IMDBMovie", | ||
formulaNamespace: "Deprecated", | ||
}); | ||
|
||
/* -------------------------------------------------------------------------- */ | ||
/* Formulas */ | ||
/* -------------------------------------------------------------------------- */ | ||
|
||
pack.addFormula({ | ||
name: "IMDBMovie", | ||
description: "Search for a movie title and get details about it from IMDB", | ||
parameters: [ | ||
coda.makeParameter({ | ||
type: coda.ParameterType.String, | ||
name: "query", | ||
description: "Search IMDB (try movie name, or movie name and year)", | ||
}), | ||
], | ||
|
||
resultType: coda.ValueType.Object, | ||
schema: schemas.MovieSchema, | ||
|
||
execute: async function ([query], context) { | ||
return helpers.getMovie(context, query); | ||
}, | ||
}); |
Oops, something went wrong.