@aitofy/youtube 0.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 ADDED
@@ -0,0 +1,28 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aitofy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ DISCLAIMER: This software accesses YouTube's internal APIs which may violate
26
+ YouTube's Terms of Service. This software is provided for educational and
27
+ personal use only. The authors are not responsible for any misuse or
28
+ consequences arising from the use of this software. Use at your own risk.
package/README.md ADDED
@@ -0,0 +1,278 @@
1
+ # @aitofy/youtube
2
+
3
+ > đŸŽŦ Free YouTube utilities for Node.js - Get transcripts, channel videos, video info without API key
4
+
5
+ [![npm version](https://badge.fury.io/js/@aitofy%2Fyoutube.svg)](https://www.npmjs.com/package/@aitofy/youtube)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ---
9
+
10
+ ## âš ī¸ Disclaimer
11
+
12
+ This package accesses YouTube's internal APIs for educational and personal use. It may violate YouTube's Terms of Service. **Use at your own risk.** The authors are not responsible for any misuse or consequences.
13
+
14
+ ---
15
+
16
+ ## ✨ Features
17
+
18
+ - 📝 **Get Transcripts** - Fetch video captions/subtitles in multiple formats
19
+ - đŸ“ē **List Channel Videos** - Get all videos from any YouTube channel
20
+ - 🔍 **Search Videos** - Search YouTube programmatically
21
+ - â„šī¸ **Video Info** - Get metadata, views, duration, thumbnails
22
+ - 🤖 **MCP Integration** - Use with Claude, ChatGPT, and other AI assistants
23
+ - đŸšĢ **No API Key Required** - Works out of the box
24
+ - đŸ“Ļ **Zero Config** - Just install and use
25
+
26
+ ---
27
+
28
+ ## đŸ“Ļ Installation
29
+
30
+ ```bash
31
+ npm install @aitofy/youtube
32
+ ```
33
+
34
+ ```bash
35
+ yarn add @aitofy/youtube
36
+ ```
37
+
38
+ ```bash
39
+ pnpm add @aitofy/youtube
40
+ ```
41
+
42
+ ---
43
+
44
+ ## 🚀 Quick Start
45
+
46
+ ### Get Transcript
47
+
48
+ ```typescript
49
+ import { getTranscript, getTranscriptText } from '@aitofy/youtube';
50
+
51
+ // Get transcript as segments
52
+ const segments = await getTranscript('dQw4w9WgXcQ');
53
+ console.log(segments);
54
+ // [
55
+ // { start: 0.24, duration: 2.5, text: 'Never gonna give you up' },
56
+ // { start: 2.74, duration: 2.3, text: 'Never gonna let you down' },
57
+ // ...
58
+ // ]
59
+
60
+ // Get transcript as plain text
61
+ const text = await getTranscriptText('dQw4w9WgXcQ');
62
+ console.log(text);
63
+ // "Never gonna give you up\nNever gonna let you down\n..."
64
+ ```
65
+
66
+ ### Get Channel Videos
67
+
68
+ ```typescript
69
+ import { getChannelVideos } from '@aitofy/youtube';
70
+
71
+ // By channel ID
72
+ const videos = await getChannelVideos('UCsBjURrPoezykLs9EqgamOA');
73
+
74
+ // By handle
75
+ const videos = await getChannelVideos('@Fireship');
76
+
77
+ // With options
78
+ const videos = await getChannelVideos({
79
+ channel: '@Fireship',
80
+ limit: 50,
81
+ sortBy: 'popular', // 'newest' | 'oldest' | 'popular'
82
+ });
83
+
84
+ console.log(videos);
85
+ // [
86
+ // { videoId: 'abc123', title: 'Video Title', viewCount: 12345, ... },
87
+ // ...
88
+ // ]
89
+ ```
90
+
91
+ ### Search Videos
92
+
93
+ ```typescript
94
+ import { searchVideos } from '@aitofy/youtube';
95
+
96
+ const results = await searchVideos('nodejs tutorial');
97
+
98
+ // With options
99
+ const results = await searchVideos({
100
+ query: 'react hooks',
101
+ limit: 20,
102
+ sortBy: 'viewCount', // 'relevance' | 'date' | 'viewCount' | 'rating'
103
+ });
104
+ ```
105
+
106
+ ### Get Video Info
107
+
108
+ ```typescript
109
+ import { getVideoInfo } from '@aitofy/youtube';
110
+
111
+ const info = await getVideoInfo('dQw4w9WgXcQ');
112
+ console.log(info);
113
+ // {
114
+ // videoId: 'dQw4w9WgXcQ',
115
+ // title: 'Rick Astley - Never Gonna Give You Up',
116
+ // duration: '3:33',
117
+ // viewCount: 1500000000,
118
+ // channelTitle: 'Rick Astley',
119
+ // thumbnails: { ... },
120
+ // ...
121
+ // }
122
+ ```
123
+
124
+ ---
125
+
126
+ ## 📖 API Reference
127
+
128
+ ### Transcript Functions
129
+
130
+ | Function | Description |
131
+ |----------|-------------|
132
+ | `getTranscript(videoId, options?)` | Get transcript segments |
133
+ | `getTranscriptText(videoId, options?)` | Get transcript as plain text |
134
+ | `getTranscriptSRT(videoId, options?)` | Get transcript as SRT subtitles |
135
+ | `getTranscriptVTT(videoId, options?)` | Get transcript as WebVTT |
136
+ | `listTranscripts(videoId)` | List available transcript languages |
137
+
138
+ ### Channel Functions
139
+
140
+ | Function | Description |
141
+ |----------|-------------|
142
+ | `getChannelVideos(options)` | Get videos from a channel |
143
+ | `getChannelInfo(channel)` | Get channel metadata |
144
+
145
+ ### Video Functions
146
+
147
+ | Function | Description |
148
+ |----------|-------------|
149
+ | `getVideoInfo(videoId)` | Get detailed video info |
150
+ | `getBasicVideoInfo(videoId)` | Get basic video info (faster) |
151
+ | `searchVideos(query, options?)` | Search YouTube videos |
152
+
153
+ ---
154
+
155
+ ## 🔧 Options
156
+
157
+ ### Transcript Options
158
+
159
+ ```typescript
160
+ interface FetchTranscriptOptions {
161
+ languages?: string[]; // Preferred languages, e.g. ['en', 'vi']
162
+ preferGenerated?: boolean; // Prefer auto-generated over manual
163
+ }
164
+ ```
165
+
166
+ ### Channel Videos Options
167
+
168
+ ```typescript
169
+ interface GetChannelVideosOptions {
170
+ channel: string; // Channel ID, URL, or @handle
171
+ limit?: number; // Max videos (default: 15)
172
+ sortBy?: 'newest' | 'oldest' | 'popular';
173
+ contentType?: 'videos' | 'shorts' | 'streams';
174
+ }
175
+ ```
176
+
177
+ ### Search Options
178
+
179
+ ```typescript
180
+ interface SearchOptions {
181
+ query: string;
182
+ limit?: number;
183
+ sortBy?: 'relevance' | 'date' | 'viewCount' | 'rating';
184
+ }
185
+ ```
186
+
187
+ ---
188
+
189
+ ## đŸŽ¯ Use Cases
190
+
191
+ - 📊 **Content Analysis** - Analyze video transcripts for SEO
192
+ - 🤖 **AI/ML Training** - Collect transcripts for datasets
193
+ - 📱 **App Development** - Build YouTube-related apps
194
+ - 🔍 **Research** - Academic video content analysis
195
+ - â™ŋ **Accessibility** - Generate subtitles for accessibility
196
+
197
+ ---
198
+
199
+ ## 🤖 MCP Integration (Claude, ChatGPT)
200
+
201
+ Use YouTube tools directly in AI assistants via [Model Context Protocol](https://modelcontextprotocol.io/).
202
+
203
+ ### Setup for Claude Desktop
204
+
205
+ 1. Install the package globally:
206
+ ```bash
207
+ npm install -g @aitofy/youtube
208
+ ```
209
+
210
+ 2. Add to Claude's config (`~/Library/Application Support/Claude/claude_desktop_config.json`):
211
+ ```json
212
+ {
213
+ "mcpServers": {
214
+ "youtube": {
215
+ "command": "youtube-mcp"
216
+ }
217
+ }
218
+ }
219
+ ```
220
+
221
+ 3. Restart Claude Desktop
222
+
223
+ ### Available MCP Tools
224
+
225
+ | Tool | Description |
226
+ |------|-------------|
227
+ | `get_youtube_transcript` | Get video transcript with timestamps |
228
+ | `get_youtube_transcript_text` | Get transcript as plain text |
229
+ | `list_youtube_transcripts` | List available languages |
230
+ | `get_youtube_video_info` | Get video metadata |
231
+ | `get_youtube_channel_videos` | List channel videos |
232
+ | `get_youtube_channel_info` | Get channel info |
233
+ | `search_youtube_videos` | Search YouTube |
234
+
235
+ ### Example Usage in Claude
236
+
237
+ ```
238
+ You: Get the transcript for YouTube video dQw4w9WgXcQ
239
+
240
+ Claude: [Uses get_youtube_transcript tool]
241
+ Here's the transcript for "Never Gonna Give You Up"...
242
+ ```
243
+
244
+ ---
245
+
246
+ ## ⚡ Rate Limiting
247
+
248
+ To avoid being blocked by YouTube:
249
+
250
+ ```typescript
251
+ // Add delays between requests
252
+ const sleep = (ms: number) => new Promise(r => setTimeout(r, ms));
253
+
254
+ for (const videoId of videoIds) {
255
+ const transcript = await getTranscript(videoId);
256
+ await sleep(1000); // Wait 1 second between requests
257
+ }
258
+ ```
259
+
260
+ ---
261
+
262
+ ## 🤝 Contributing
263
+
264
+ Contributions are welcome! Please read our contributing guidelines.
265
+
266
+ ---
267
+
268
+ ## 📄 License
269
+
270
+ MIT Š [Aitofy](https://github.com/aitofy)
271
+
272
+ ---
273
+
274
+ ## 🙏 Credits
275
+
276
+ Inspired by:
277
+ - [youtube-transcript-api](https://github.com/jdepoix/youtube-transcript-api) (Python)
278
+ - [youtubei.js](https://github.com/LuanRT/YouTube.js)