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/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
- ### 1. Initialization and Fetching Taste Data (History and Likes)
47
- Retrieve the logged-in user's viewing history, liked videos, "Watch Later" list, or custom playlists.
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 { scrapeTasteData } from './index.js';
54
+ import { Client } from 'tubezero';
51
55
 
52
- // When run in a browser extension, SAPISID cookies are read automatically
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
- console.log("History:", userFeeds.historyEntries);
58
- console.log("Likes:", userFeeds.likesEntries);
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 specific video with automatic pagination.
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 { fetchCommentsFromYouTube } from './index.js';
66
+ import { Client } from 'tubezero';
67
+
68
+ const youtube = new Client();
69
+ const video = await youtube.getVideo("dQw4w9WgXcQ");
68
70
 
69
- const videoId = "dQw4w9WgXcQ";
70
- const maxComments = 100;
71
+ console.log(`Title: ${video.title}`);
72
+ console.log(`Views: ${video.viewCount}`);
71
73
 
72
- const comments = await fetchCommentsFromYouTube(videoId, maxComments);
74
+ // Load the first page of comments
75
+ const comments = await video.comments.next();
73
76
  comments.forEach(c => {
74
- console.log(`[${c.author}] (${c.likeCount} likes): ${c.text}`);
77
+ console.log(`[${c.author.name}]: ${c.content}`);
75
78
  });
76
79
  ```
77
80
 
78
- ### 3. Fetching Subtitles (Transcripts)
79
- Download and parse video transcripts in the desired language with automatic fallbacks.
81
+ ### 3. Fetching a Playlist
82
+ Retrieve a playlist and paginate through its videos.
80
83
 
81
84
  ```javascript
82
- import { fetchSubtitlesFromYouTube } from './index.js';
85
+ import { Client } from 'tubezero';
83
86
 
84
- const videoId = "dQw4w9WgXcQ";
85
- const transcript = await fetchSubtitlesFromYouTube(videoId, "en"); // Searches for English, falls back to automatic captions or first available track
87
+ const youtube = new Client();
88
+ const playlist = await youtube.getPlaylist("PLtbcYJeD7QZ34kS_L8H-lV7J8xT6rU0k_");
86
89
 
87
- transcript.forEach(segment => {
88
- console.log(`[${segment.start}s - ${segment.duration}s]: ${segment.text}`);
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
  ---