-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regenerate the client library according to the new specs
- Loading branch information
1 parent
d010279
commit 4725d34
Showing
12 changed files
with
258 additions
and
48 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 |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
This client can be used in both JavaScript and TypeScript projects; | ||
and both in browser and Node environment. | ||
|
||
|
||
Since using this client in browser would expose your API key to the public, | ||
it is more secure to use it in server-side applications. | ||
Using it in browser is only recommended for personal projects and | ||
|
@@ -75,12 +74,110 @@ npm i streaming-availability | |
### Via Script Tag from CDN | ||
|
||
```html | ||
<script src="https://cdn.jsdelivr.net/gh/movieofthenight/[email protected].2/bundle.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/gh/movieofthenight/[email protected].3/bundle.min.js"></script> | ||
``` | ||
|
||
This script creates a global variable at `window.streamingAvailability` | ||
where you can access to the module. | ||
|
||
## Usage | ||
|
||
### Node | ||
|
||
```ts | ||
import * as streamingAvailability from "streaming-availability"; | ||
|
||
const RAPID_API_KEY = "<YOUR_RAPID_API_KEY>"; | ||
|
||
const client = new streamingAvailability.Client(new streamingAvailability.Configuration({ | ||
apiKey: RAPID_API_KEY | ||
})); | ||
|
||
// Start using the client | ||
``` | ||
|
||
### Script Tag | ||
|
||
```html | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Example</title> | ||
</head> | ||
<body style="white-space: pre-line"> | ||
<script src="https://cdn.jsdelivr.net/gh/movieofthenight/[email protected]/bundle.min.js"></script> | ||
<script type="module"> | ||
const RAPID_API_KEY = "<YOUR_RAPID_API_KEY>"; | ||
const client = new streamingAvailability.Client(new streamingAvailability.Configuration({ | ||
apiKey: RAPID_API_KEY | ||
})); | ||
// Start using the client | ||
</script> | ||
</body> | ||
</html> | ||
``` | ||
|
||
## Examples | ||
|
||
### Get The Godfather's Streaming Availability Info | ||
|
||
```ts | ||
import * as streamingAvailability from "streaming-availability"; | ||
|
||
const RAPID_API_KEY = "<YOUR_RAPID_API_KEY>"; | ||
|
||
const client = new streamingAvailability.Client(new streamingAvailability.Configuration({ | ||
apiKey: RAPID_API_KEY | ||
})); | ||
|
||
let show = await client.showsApi.getShow( | ||
{id: "tt0068646", country: "us"} | ||
); | ||
|
||
console.log(show.title); | ||
console.log(show.overview); | ||
show.streamingOptions["us"].forEach((streamingOption) => { | ||
console.log(streamingOption.link); | ||
}); | ||
``` | ||
|
||
#### Via Script Tag | ||
|
||
```html | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>The Godfather</title> | ||
</head> | ||
<body style="white-space: pre-line"> | ||
<script src="https://cdn.jsdelivr.net/gh/movieofthenight/[email protected]/bundle.min.js"></script> | ||
<script type="module"> | ||
const RAPID_API_KEY = "<YOUR_RAPID_API_KEY>"; | ||
const client = new streamingAvailability.Client(new streamingAvailability.Configuration({ | ||
apiKey: RAPID_API_KEY | ||
})); | ||
let show = await client.showsApi.getShow( | ||
{id: "tt0068646", country: "us"} | ||
); | ||
document.body.textContent = show.title + "\r\n"; | ||
document.body.textContent += show.overview + "\r\n"; | ||
show.streamingOptions["us"].forEach((streamingOption) => { | ||
document.body.textContent += streamingOption.link + "\r\n"; | ||
}); | ||
</script> | ||
</body> | ||
</html> | ||
``` | ||
|
||
> Checkout [examples](https://github.com/movieofthenight/ts-streaming-availability/blob/main/examples) | ||
folder for the rest of the examples. | ||
|
||
## Terms & Conditions and Attribution | ||
|
||
While the client libraries have MIT licenses, | ||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,12 @@ | ||
# Netflix Popular Action Movies | ||
|
||
This example shows how to get the most popular action movies from Netflix. | ||
|
||
## How to Run | ||
|
||
Update `RAPID_API_KEY` constant with your own API key. Then: | ||
|
||
```shell | ||
npm install | ||
npm start | ||
``` |
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,25 @@ | ||
import * as streamingAvailability from "streaming-availability"; | ||
|
||
const RAPID_API_KEY = "<YOUR_RAPID_API_KEY>"; | ||
|
||
const client = new streamingAvailability.Client(new streamingAvailability.Configuration({ | ||
apiKey: RAPID_API_KEY | ||
})); | ||
|
||
let searchResult = await client.showsApi.searchShowsByFilters(({ | ||
country: "us", | ||
catalogs: ["netflix"], | ||
genres: ["action"], | ||
showType: streamingAvailability.ShowType.Movie, | ||
orderBy: "popularity_1year", | ||
})) | ||
|
||
searchResult.shows.forEach((show) => { | ||
console.log(show.title); | ||
console.log(show.overview); | ||
show.streamingOptions["us"].forEach((streamingOption) => { | ||
if(streamingOption.service.id === "netflix") { | ||
console.log(streamingOption.link); | ||
} | ||
}); | ||
}); |
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,25 @@ | ||
import * as streamingAvailability from "streaming-availability"; | ||
|
||
const RAPID_API_KEY = "<YOUR_RAPID_API_KEY>"; | ||
|
||
const client = new streamingAvailability.Client(new streamingAvailability.Configuration({ | ||
apiKey: RAPID_API_KEY | ||
})); | ||
|
||
let searchResult = await client.showsApi.searchShowsByFilters(({ | ||
country: "us", | ||
catalogs: ["netflix"], | ||
genres: ["action"], | ||
showType: streamingAvailability.ShowType.Movie, | ||
orderBy: "popularity_1year", | ||
})) | ||
|
||
searchResult.shows.forEach((show) => { | ||
console.log(show.title); | ||
console.log(show.overview); | ||
show.streamingOptions["us"].forEach((streamingOption) => { | ||
if(streamingOption.service.id === "netflix") { | ||
console.log(streamingOption.link); | ||
} | ||
}); | ||
}); |
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,19 @@ | ||
{ | ||
"name": "netflix-popular-action-movies", | ||
"version": "1.0.0", | ||
"description": "Get the most popular action movies on Netflix", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "tsc && node index.js" | ||
}, | ||
"keywords": [], | ||
"author": "Movie of the Night", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"typescript": "^5.4.5" | ||
}, | ||
"dependencies": { | ||
"streaming-availability": "4.x" | ||
}, | ||
"type": "module" | ||
} |
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,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2022", | ||
"module": "node16", | ||
"moduleResolution": "node16", | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"skipLibCheck": true | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -45,5 +45,5 @@ | |
"test": "ts-node test/test.ts" | ||
}, | ||
"typings": "./dist/index.d.ts", | ||
"version": "v4.0.2" | ||
"version": "v4.0.3" | ||
} |