tubezero 1.0.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 ADDED
@@ -0,0 +1,121 @@
1
+ # PolyForm Small Business License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/small-business/1.0.0>
4
+
5
+ ## Acceptance
6
+
7
+ In order to get any license under these terms, you must agree
8
+ to them as both strict obligations and conditions to all
9
+ your licenses.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a copyright license for the
14
+ software to do everything you might do with the software
15
+ that would otherwise infringe the licensor's copyright
16
+ in it for any permitted purpose. However, you may
17
+ only distribute the software according to [Distribution
18
+ License](#distribution-license) and make changes or new works
19
+ based on the software according to [Changes and New Works
20
+ License](#changes-and-new-works-license).
21
+
22
+ ## Distribution License
23
+
24
+ The licensor grants you an additional copyright license
25
+ to distribute copies of the software. Your license
26
+ to distribute covers distributing the software with
27
+ changes and new works permitted by [Changes and New Works
28
+ License](#changes-and-new-works-license).
29
+
30
+ ## Notices
31
+
32
+ You must ensure that anyone who gets a copy of any part of
33
+ the software from you also gets a copy of these terms or the
34
+ URL for them above, as well as copies of any plain-text lines
35
+ beginning with `Required Notice:` that the licensor provided
36
+ with the software. For example:
37
+
38
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
39
+
40
+ ## Changes and New Works License
41
+
42
+ The licensor grants you an additional copyright license to
43
+ make changes and new works based on the software for any
44
+ permitted purpose.
45
+
46
+ ## Patent License
47
+
48
+ The licensor grants you a patent license for the software that
49
+ covers patent claims the licensor can license, or becomes able
50
+ to license, that you would infringe by using the software.
51
+
52
+ ## Fair Use
53
+
54
+ You may have "fair use" rights for the software under the
55
+ law. These terms do not limit them.
56
+
57
+ ## Small Business
58
+
59
+ Use of the software for the benefit of your company is use for
60
+ a permitted purpose if your company has fewer than 100 total
61
+ individuals working as employees and independent contractors,
62
+ and less than 1,000,000 USD (2019) total revenue in the prior
63
+ tax year. Adjust this revenue threshold for inflation according
64
+ to the United States Bureau of Labor Statistics' consumer price
65
+ index for all urban consumers, U.S. city average, for all items,
66
+ not seasonally adjusted, with 1982–1984=100 reference base.
67
+
68
+ ## No Other Rights
69
+
70
+ These terms do not allow you to sublicense or transfer any of
71
+ your licenses to anyone else, or prevent the licensor from
72
+ granting licenses to anyone else. These terms do not imply
73
+ any other licenses.
74
+
75
+ ## Patent Defense
76
+
77
+ If you make any written claim that the software infringes or
78
+ contributes to infringement of any patent, your patent license
79
+ for the software granted under these terms ends immediately. If
80
+ your company makes such a claim, your patent license ends
81
+ immediately for work on behalf of your company.
82
+
83
+ ## Violations
84
+
85
+ The first time you are notified in writing that you have
86
+ violated any of these terms, or done anything with the software
87
+ not covered by your licenses, your licenses can nonetheless
88
+ continue if you come into full compliance with these terms,
89
+ and take practical steps to correct past violations, within
90
+ 32 days of receiving notice. Otherwise, all your licenses
91
+ end immediately.
92
+
93
+ ## No Liability
94
+
95
+ ***As far as the law allows, the software comes as is, without
96
+ any warranty or condition, and the licensor will not be liable
97
+ to you for any damages arising out of these terms or the use
98
+ or nature of the software, under any kind of legal claim.***
99
+
100
+ ## Definitions
101
+
102
+ The **licensor** is the individual or entity offering these
103
+ terms, and the **software** is the software the licensor makes
104
+ available under these terms.
105
+
106
+ **You** refers to the individual or entity agreeing to these
107
+ terms.
108
+
109
+ **Your company** is any legal entity, sole proprietorship,
110
+ or other kind of organization that you work for, plus all
111
+ organizations that have control over, are under the control of,
112
+ or are under common control with that organization. **Control**
113
+ means ownership of substantially all the assets of an entity,
114
+ or the power to direct its management and policies by vote,
115
+ contract, or otherwise. Control can be direct or indirect.
116
+
117
+ **Your licenses** are all the licenses granted to you for the
118
+ software under these terms.
119
+
120
+ **Use** means anything you do with the software requiring one
121
+ of your licenses.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # TubeZero
2
+
3
+ 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
+
5
+ ---
6
+
7
+ ## ⚖️ Comparison with Other Libraries
8
+
9
+ To ensure complete transparency, here is a comparison between **TubeZero** and the other main InnerTube libraries available on GitHub:
10
+
11
+ | Feature/Property | **TubeZero** (This Project) | **LuanRT/YouTube.js** (youtubei.js) | **SuspiciousLookingOwl/youtubei** |
12
+ | :--- | :--- | :--- | :--- |
13
+ | **Architecture** | Lite, pure fetch client, zero external dependencies | Full-featured monolithic SDK mapping almost all renderers | Object-oriented TypeScript query client |
14
+ | **Optimization** | Client-side & Web-Extension optimized | Heavy backend/server-side oriented | Node.js oriented with class-based queries |
15
+ | **Pros & Use Cases** | Extremely lightweight, fast, no compilation required. Native extraction of `SAPISID` and `SAPISIDHASH` via Web Crypto API for authenticated requests. | Complete coverage of features (deciphering video download signatures, live chat, dedicated interfaces for Music/Studio/Kids). | Class-based abstractions, clean TypeScript interface for querying videos, channels, and playlists. |
16
+ | **Limitations** | Lacks video download deciphering, full catalog of renderer schemas, and dedicated YT Music/Studio/Kids interfaces. | Large bundle size, complex codebase, requires polyfills/build tools to run in client/extension frontends. | Requires compilation, coupled with Node.js dependencies, not designed for direct client-side integration. |
17
+
18
+ ---
19
+
20
+ ## ⚠️ Important Note on CORS and Cookies
21
+
22
+ When this library is executed in a standard browser environment (e.g., on a standard website like `myapp.com`), requests to `youtube.com/youtubei` will be blocked due to browser **CORS** policies.
23
+
24
+ ### Recommended Execution Environments:
25
+ 1. **Browser Extensions:** Optimal. By granting host permissions for `https://*.youtube.com/*` in `manifest.json`, the extension bypasses CORS and can read session cookies directly to compute the `SAPISIDHASH` for authenticated requests.
26
+ 2. **Desktop & Mobile Applications (Electron, Tauri, React Native):** By controlling HTTP headers and disabling CORS, these applications can run the library natively.
27
+ 3. **Server-side Environments (Node.js) with a CORS Proxy:** Requests can be routed through a reverse proxy that removes header restrictions.
28
+
29
+ ---
30
+
31
+ ## 📦 Installation (Package Structure)
32
+
33
+ To prepare the package for local usage or NPM publishing:
34
+
35
+ ```bash
36
+ # Initialize the package if exported into a dedicated folder
37
+ npm init -y
38
+ ```
39
+
40
+ Add `"type": "module"` in your `package.json` to enable loading of ES modules.
41
+
42
+ ---
43
+
44
+ ## 💻 Usage Examples
45
+
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
+
49
+ ```javascript
50
+ import { scrapeTasteData } from './index.js';
51
+
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
+
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);
61
+ ```
62
+
63
+ ### 2. Fetching Video Comments
64
+ Retrieve comments for a specific video with automatic pagination.
65
+
66
+ ```javascript
67
+ import { fetchCommentsFromYouTube } from './index.js';
68
+
69
+ const videoId = "dQw4w9WgXcQ";
70
+ const maxComments = 100;
71
+
72
+ const comments = await fetchCommentsFromYouTube(videoId, maxComments);
73
+ comments.forEach(c => {
74
+ console.log(`[${c.author}] (${c.likeCount} likes): ${c.text}`);
75
+ });
76
+ ```
77
+
78
+ ### 3. Fetching Subtitles (Transcripts)
79
+ Download and parse video transcripts in the desired language with automatic fallbacks.
80
+
81
+ ```javascript
82
+ import { fetchSubtitlesFromYouTube } from './index.js';
83
+
84
+ const videoId = "dQw4w9WgXcQ";
85
+ const transcript = await fetchSubtitlesFromYouTube(videoId, "en"); // Searches for English, falls back to automatic captions or first available track
86
+
87
+ transcript.forEach(segment => {
88
+ console.log(`[${segment.start}s - ${segment.duration}s]: ${segment.text}`);
89
+ });
90
+ ```
91
+
92
+ ---
93
+
94
+ ## 🛡️ Legal Disclaimer
95
+
96
+ *This tool is intended solely for educational, research, and study purposes regarding third-party web architectures. It is not associated, affiliated, sponsored, or endorsed by Google LLC or YouTube. The user assumes full civil and administrative liability arising from the use of these functions and any potential violation of YouTube's Terms of Service. The authors are not responsible for IP blocks, account bans, or other actions taken by YouTube as a result of using this library.*