Skip to content

Commit

Permalink
Regenerate the client library according to the new specs
Browse files Browse the repository at this point in the history
  • Loading branch information
the-maestro-bot committed Apr 27, 2024
1 parent d010279 commit 4725d34
Show file tree
Hide file tree
Showing 12 changed files with 258 additions and 48 deletions.
101 changes: 99 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
49 changes: 49 additions & 0 deletions docs/assets/highlight.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@
--dark-hl-5: #9CDCFE;
--light-hl-6: #0000FF;
--dark-hl-6: #CE9178;
--light-hl-7: #AF00DB;
--dark-hl-7: #C586C0;
--light-hl-8: #0000FF;
--dark-hl-8: #569CD6;
--light-hl-9: #A31515;
--dark-hl-9: #CE9178;
--light-hl-10: #0070C1;
--dark-hl-10: #4FC1FF;
--light-hl-11: #795E26;
--dark-hl-11: #DCDCAA;
--light-hl-12: #008000;
--dark-hl-12: #6A9955;
--light-hl-13: #EE0000;
--dark-hl-13: #D7BA7D;
--light-code-background: #FFFFFF;
--dark-code-background: #1E1E1E;
}
Expand All @@ -25,6 +39,13 @@
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--hl-10: var(--light-hl-10);
--hl-11: var(--light-hl-11);
--hl-12: var(--light-hl-12);
--hl-13: var(--light-hl-13);
--code-background: var(--light-code-background);
} }

Expand All @@ -36,6 +57,13 @@
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--hl-10: var(--dark-hl-10);
--hl-11: var(--dark-hl-11);
--hl-12: var(--dark-hl-12);
--hl-13: var(--dark-hl-13);
--code-background: var(--dark-code-background);
} }

Expand All @@ -47,6 +75,13 @@
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--hl-10: var(--light-hl-10);
--hl-11: var(--light-hl-11);
--hl-12: var(--light-hl-12);
--hl-13: var(--light-hl-13);
--code-background: var(--light-code-background);
}

Expand All @@ -58,6 +93,13 @@
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--hl-10: var(--dark-hl-10);
--hl-11: var(--dark-hl-11);
--hl-12: var(--dark-hl-12);
--hl-13: var(--dark-hl-13);
--code-background: var(--dark-code-background);
}

Expand All @@ -68,4 +110,11 @@
.hl-4 { color: var(--hl-4); }
.hl-5 { color: var(--hl-5); }
.hl-6 { color: var(--hl-6); }
.hl-7 { color: var(--hl-7); }
.hl-8 { color: var(--hl-8); }
.hl-9 { color: var(--hl-9); }
.hl-10 { color: var(--hl-10); }
.hl-11 { color: var(--hl-11); }
.hl-12 { color: var(--hl-12); }
.hl-13 { color: var(--hl-13); }
pre, code { background: var(--code-background); }
16 changes: 14 additions & 2 deletions docs/index.html

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions examples/netflix-popular-action-movies/README.md
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
```
25 changes: 25 additions & 0 deletions examples/netflix-popular-action-movies/index.js
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);
}
});
});
25 changes: 25 additions & 0 deletions examples/netflix-popular-action-movies/index.ts
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);
}
});
});
19 changes: 19 additions & 0 deletions examples/netflix-popular-action-movies/package.json
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"
}
11 changes: 11 additions & 0 deletions examples/netflix-popular-action-movies/tsconfig.json
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
}
}
40 changes: 0 additions & 40 deletions examples/the-godfather/package-lock.json

This file was deleted.

2 changes: 1 addition & 1 deletion examples/the-godfather/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"typescript": "^5.4.5"
},
"dependencies": {
"streaming-availability": "^4.0.1"
"streaming-availability": "4.x"
},
"type": "module"
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@
"test": "ts-node test/test.ts"
},
"typings": "./dist/index.d.ts",
"version": "v4.0.2"
"version": "v4.0.3"
}

0 comments on commit 4725d34

Please sign in to comment.