tubezero 1.0.0 → 1.1.0
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/LICENSE +661 -121
- package/README.md +32 -26
- package/dist/index.cjs +1802 -675
- package/dist/index.d.cts +412 -132
- package/dist/index.d.ts +412 -132
- package/dist/index.js +1778 -673
- package/package.json +74 -54
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# TubeZero
|
|
2
2
|
|
|
3
|
+
📖 **[Full API Documentation & Snippets](https://7Mik.github.io/TubeZero/)**
|
|
4
|
+
|
|
3
5
|
A modular collection of JavaScript functions designed to scrape and reverse-engineer data from YouTube using its private internal API (**InnerTube**). This library is built to be ultra-lightweight, free of heavy external dependencies, and optimized for client-side environments (such as browser extensions or desktop applications).
|
|
4
6
|
|
|
5
7
|
---
|
|
@@ -43,50 +45,54 @@ Add `"type": "module"` in your `package.json` to enable loading of ES modules.
|
|
|
43
45
|
|
|
44
46
|
## 💻 Usage Examples
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
The primary way to interact with TubeZero is through the `Client` class. For a full list of examples, check out the **[Documentation](https://7Mik.github.io/TubeZero/)**.
|
|
49
|
+
|
|
50
|
+
### 1. Initialization and Searching
|
|
51
|
+
Search for videos, playlists, or channels.
|
|
48
52
|
|
|
49
53
|
```javascript
|
|
50
|
-
import {
|
|
54
|
+
import { Client } from 'tubezero';
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
const userFeeds = await scrapeTasteData(null, [
|
|
54
|
-
{ url: "https://www.youtube.com/playlist?list=PLtbcYJeD7QZ34kS_L8H-lV7J8xT6rU0k_" } // Optional custom playlist
|
|
55
|
-
]);
|
|
56
|
+
const youtube = new Client();
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
console.log(
|
|
59
|
-
console.log("Watch Later:", userFeeds.wlEntries);
|
|
60
|
-
console.log("Custom Playlists:", userFeeds.customPlaylistsData);
|
|
58
|
+
const results = await youtube.search("Rick Astley", { type: "video" });
|
|
59
|
+
console.log(results.items[0].title); // "Rick Astley - Never Gonna Give You Up"
|
|
61
60
|
```
|
|
62
61
|
|
|
63
|
-
### 2. Fetching Video Comments
|
|
64
|
-
Retrieve comments for a
|
|
62
|
+
### 2. Fetching a Video and its Comments
|
|
63
|
+
Retrieve full metadata, streaming data, and comments for a video.
|
|
65
64
|
|
|
66
65
|
```javascript
|
|
67
|
-
import {
|
|
66
|
+
import { Client } from 'tubezero';
|
|
67
|
+
|
|
68
|
+
const youtube = new Client();
|
|
69
|
+
const video = await youtube.getVideo("dQw4w9WgXcQ");
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
console.log(`Title: ${video.title}`);
|
|
72
|
+
console.log(`Views: ${video.viewCount}`);
|
|
71
73
|
|
|
72
|
-
|
|
74
|
+
// Load the first page of comments
|
|
75
|
+
const comments = await video.comments.next();
|
|
73
76
|
comments.forEach(c => {
|
|
74
|
-
console.log(`[${c.author}]
|
|
77
|
+
console.log(`[${c.author.name}]: ${c.content}`);
|
|
75
78
|
});
|
|
76
79
|
```
|
|
77
80
|
|
|
78
|
-
### 3. Fetching
|
|
79
|
-
|
|
81
|
+
### 3. Fetching a Playlist
|
|
82
|
+
Retrieve a playlist and paginate through its videos.
|
|
80
83
|
|
|
81
84
|
```javascript
|
|
82
|
-
import {
|
|
85
|
+
import { Client } from 'tubezero';
|
|
83
86
|
|
|
84
|
-
const
|
|
85
|
-
const
|
|
87
|
+
const youtube = new Client();
|
|
88
|
+
const playlist = await youtube.getPlaylist("PLtbcYJeD7QZ34kS_L8H-lV7J8xT6rU0k_");
|
|
86
89
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
// Load all pages
|
|
91
|
+
while (playlist.videos.hasMore) {
|
|
92
|
+
await playlist.videos.next();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
console.log(`Total videos loaded: ${playlist.videos.items.length}`);
|
|
90
96
|
```
|
|
91
97
|
|
|
92
98
|
---
|