@crawlora-org/youtube 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -4
- package/package.json +1 -1
- package/src/index.js +2 -2
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @crawlora-org/youtube
|
|
2
2
|
|
|
3
3
|
JavaScript and TypeScript client for Crawlora's hosted YouTube API.
|
|
4
|
-
It calls Crawlora
|
|
4
|
+
It calls [Crawlora](https://crawlora.net); it does not run a browser or scrape YouTube locally. A Crawlora account and `CRAWLORA_API_KEY` are required, and API use is billed under your Crawlora account. Crawlora is independent from and not endorsed by YouTube or its owners.
|
|
5
5
|
|
|
6
6
|
## Install
|
|
7
7
|
|
|
@@ -9,14 +9,31 @@ It calls Crawlora's service; it does not run a browser or scrape YouTube locally
|
|
|
9
9
|
npm install @crawlora-org/youtube
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
+
## Get an API key
|
|
13
|
+
|
|
14
|
+
Create an account at [crawlora.net](https://crawlora.net/signup), then open the [Crawlora console](https://crawlora.net/app) for API-key setup. Set your key in the shell before running the client:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
export CRAWLORA_API_KEY="your-crawlora-api-key"
|
|
18
|
+
```
|
|
19
|
+
|
|
12
20
|
## Use
|
|
13
21
|
|
|
22
|
+
Save this example as `example.mjs`, then run `node example.mjs` after installing the package and setting your API key.
|
|
23
|
+
|
|
14
24
|
```js
|
|
25
|
+
import process from "node:process";
|
|
15
26
|
import { YouTubeClient } from "@crawlora-org/youtube";
|
|
16
27
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
const apiKey = process.env.CRAWLORA_API_KEY;
|
|
29
|
+
if (!apiKey) throw new Error("Set CRAWLORA_API_KEY before running this example.");
|
|
30
|
+
const client = new YouTubeClient({ apiKey });
|
|
31
|
+
const result1 = await client.search({ q: "science explainers", type: "video" });
|
|
32
|
+
console.log(result1);
|
|
33
|
+
const result2 = await client.video({ id: "dQw4w9WgXcQ" });
|
|
34
|
+
console.log(result2);
|
|
35
|
+
const result3 = await client.transcript({ id: "dQw4w9WgXcQ", format: "text" });
|
|
36
|
+
console.log(result3);
|
|
20
37
|
```
|
|
21
38
|
|
|
22
39
|
The client also exports `Client` as an alias for `YouTubeClient`. Operation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlora-org/youtube",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Typed JavaScript client for the Crawlora YouTube API",
|
|
5
5
|
"homepage": "https://github.com/Crawlora-org/crawlora-youtube#readme",
|
|
6
6
|
"bugs": { "url": "https://github.com/Crawlora-org/crawlora-youtube/issues" },
|
package/src/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
|
|
10
10
|
export class YouTubeClient extends CrawloraClient {
|
|
11
11
|
constructor(options = {}) {
|
|
12
|
-
super({ ...options, userAgent: options.userAgent ?? "crawlora-youtube-js/0.1.
|
|
12
|
+
super({ ...options, userAgent: options.userAgent ?? "crawlora-youtube-js/0.1.4" });
|
|
13
13
|
this["captions"] = (...args) => this.request("youtube-captions", ...args);
|
|
14
14
|
this["channelPlaylists"] = (...args) => this.request("youtube-channel-playlists", ...args);
|
|
15
15
|
this["channelSearch"] = (...args) => this.request("youtube-channel-search", ...args);
|
|
@@ -36,5 +36,5 @@ export {
|
|
|
36
36
|
CrawloraServerError
|
|
37
37
|
};
|
|
38
38
|
export { groups, operations, operationCount, OperationIds } from "./operations.js";
|
|
39
|
-
export const VERSION = "0.1.
|
|
39
|
+
export const VERSION = "0.1.4";
|
|
40
40
|
export default YouTubeClient;
|