extract-youtube 1.0.1
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/CHANGELOG.md +1 -0
- package/README.md +510 -0
- package/__tests__/api.test.ts +163 -0
- package/__tests__/basic-usage.ts +298 -0
- package/__tests__/formatters.test.ts +239 -0
- package/__tests__/integration.test.ts +283 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/jest.config.js +17 -0
- package/package.json +71 -0
- package/src/cli.ts +197 -0
- package/src/errors.ts +364 -0
- package/src/fetchers/transcript-list-fetcher.ts +252 -0
- package/src/fetchers/youtube-data-extractor.ts +151 -0
- package/src/formatters.ts +163 -0
- package/src/http/fetch-http-client.ts +102 -0
- package/src/index.ts +77 -0
- package/src/models/fetched-transcript.ts +110 -0
- package/src/models/index.ts +7 -0
- package/src/models/transcript-list.ts +252 -0
- package/src/models/transcript.ts +187 -0
- package/src/parsers/transcript-parser.ts +135 -0
- package/src/proxies.ts +222 -0
- package/src/types.ts +119 -0
- package/src/utils/http-error-handler.ts +32 -0
- package/src/youtube-transcript-api.ts +254 -0
- package/tsconfig.json +20 -0
- package/vite.config.ts +64 -0
package/vite.config.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
|
|
5
|
+
// Read package.json for external dependencies
|
|
6
|
+
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'));
|
|
7
|
+
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
build: {
|
|
10
|
+
lib: {
|
|
11
|
+
entry: resolve(__dirname, 'src/index.ts'),
|
|
12
|
+
name: 'YouTubeTranscriptApi',
|
|
13
|
+
formats: ['es', 'cjs'],
|
|
14
|
+
fileName: (format) => `index.${format === 'es' ? 'mjs' : 'cjs'}`,
|
|
15
|
+
},
|
|
16
|
+
rollupOptions: {
|
|
17
|
+
// Externalize dependencies to avoid bundling them
|
|
18
|
+
external: [
|
|
19
|
+
...Object.keys(pkg.dependencies || {}),
|
|
20
|
+
'node:http',
|
|
21
|
+
'node:https',
|
|
22
|
+
'node:url',
|
|
23
|
+
'node:stream',
|
|
24
|
+
'node:buffer',
|
|
25
|
+
'node:util',
|
|
26
|
+
],
|
|
27
|
+
output: {
|
|
28
|
+
// Preserve module structure for better tree-shaking
|
|
29
|
+
preserveModules: false,
|
|
30
|
+
exports: 'named',
|
|
31
|
+
// Provide global names for UMD/IIFE builds
|
|
32
|
+
globals: {
|
|
33
|
+
'node-fetch': 'fetch',
|
|
34
|
+
'fast-xml-parser': 'XMLParser',
|
|
35
|
+
'html-entities': 'htmlEntities',
|
|
36
|
+
'https-proxy-agent': 'HttpsProxyAgent',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
minify: 'terser',
|
|
41
|
+
terserOptions: {
|
|
42
|
+
compress: {
|
|
43
|
+
drop_console: false,
|
|
44
|
+
drop_debugger: true,
|
|
45
|
+
pure_funcs: ['console.debug'],
|
|
46
|
+
},
|
|
47
|
+
mangle: {
|
|
48
|
+
safari10: true,
|
|
49
|
+
},
|
|
50
|
+
format: {
|
|
51
|
+
comments: false,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
// Generate source maps for debugging
|
|
55
|
+
sourcemap: true,
|
|
56
|
+
// Target modern environments
|
|
57
|
+
target: 'es2020',
|
|
58
|
+
// Emit declaration files
|
|
59
|
+
emitAssets: true,
|
|
60
|
+
},
|
|
61
|
+
resolve: {
|
|
62
|
+
extensions: ['.ts', '.js'],
|
|
63
|
+
},
|
|
64
|
+
});
|