@tacone/prosey 0.2.2 → 0.2.3
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/bin/prosey +113016 -6784
- package/package.json +3 -3
- package/src/config.test.ts +3 -3
- package/src/index.ts +17 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tacone/prosey",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Download YouTube video transcripts from the CLI",
|
|
5
5
|
"module": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -51,14 +51,14 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/bun": "latest",
|
|
53
53
|
"husky": "^9.1.7",
|
|
54
|
-
"lint-staged": "^17.0.7"
|
|
55
|
-
"prettier": "^3.8.4"
|
|
54
|
+
"lint-staged": "^17.0.7"
|
|
56
55
|
},
|
|
57
56
|
"peerDependencies": {
|
|
58
57
|
"typescript": "^5"
|
|
59
58
|
},
|
|
60
59
|
"dependencies": {
|
|
61
60
|
"js-toml": "^1.1.2",
|
|
61
|
+
"prettier": "^3.8.4",
|
|
62
62
|
"youtube-transcript-plus": "^2.0.0"
|
|
63
63
|
}
|
|
64
64
|
}
|
package/src/config.test.ts
CHANGED
|
@@ -54,7 +54,7 @@ describe("loadConfig", () => {
|
|
|
54
54
|
|
|
55
55
|
const content = await readFile(tmpConfig, "utf8");
|
|
56
56
|
expect(content).toContain("[summarize]");
|
|
57
|
-
expect(content).toContain(
|
|
57
|
+
expect(content).toContain("command = ");
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
test("reads existing config file", async () => {
|
|
@@ -63,7 +63,7 @@ describe("loadConfig", () => {
|
|
|
63
63
|
await loadConfig();
|
|
64
64
|
const config = await loadConfig();
|
|
65
65
|
expect(config.summarize?.prompt).toBeString();
|
|
66
|
-
expect(config.summarize?.command).
|
|
66
|
+
expect(config.summarize?.command).toBeString();
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
test("handles invalid TOML gracefully", async () => {
|
|
@@ -93,6 +93,6 @@ describe("resetConfig", () => {
|
|
|
93
93
|
|
|
94
94
|
const content = await readFile(tmpConfig, "utf8");
|
|
95
95
|
expect(content).toContain("[summarize]");
|
|
96
|
-
expect(content).toContain(
|
|
96
|
+
expect(content).toContain("command = ");
|
|
97
97
|
});
|
|
98
98
|
});
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { summarize } from "./summarize";
|
|
|
10
10
|
import { cacheDir, readCache, writeCache, extractVideoId } from "./cache";
|
|
11
11
|
import { enableDebug, debug } from "./debug";
|
|
12
12
|
import pkg from "../package.json";
|
|
13
|
+
import prettier from "prettier";
|
|
13
14
|
|
|
14
15
|
const NAME = "prosey";
|
|
15
16
|
const VERSION = pkg.version;
|
|
@@ -42,6 +43,7 @@ Options:
|
|
|
42
43
|
--no-decode-entities Preserve HTML entities (decoded by default).
|
|
43
44
|
--reset-config Reset config file to defaults and exit.
|
|
44
45
|
--no-cache Skip cache and overwrite cache files.
|
|
46
|
+
--no-format Skip prettier formatting.
|
|
45
47
|
--debug Print debug information to stderr.
|
|
46
48
|
--help Show this help message.
|
|
47
49
|
--version Show version.
|
|
@@ -120,6 +122,14 @@ function printLanguages(languages: CaptionTrackInfo[]): void {
|
|
|
120
122
|
console.log(`Available transcripts (${languages.length}):\n${rows.join("\n")}`);
|
|
121
123
|
}
|
|
122
124
|
|
|
125
|
+
async function formatMd(text: string): Promise<string> {
|
|
126
|
+
try {
|
|
127
|
+
return await prettier.format(text, { parser: "markdown" });
|
|
128
|
+
} catch {
|
|
129
|
+
return text;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
123
133
|
const args = process.argv.slice(2);
|
|
124
134
|
|
|
125
135
|
if (args.length === 0 || args.includes("--help")) {
|
|
@@ -156,6 +166,7 @@ let outputJson = false;
|
|
|
156
166
|
let noDecode = false;
|
|
157
167
|
let showDetails = true;
|
|
158
168
|
let noCache = false;
|
|
169
|
+
let noFormat = false;
|
|
159
170
|
let debugMode = false;
|
|
160
171
|
|
|
161
172
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -187,6 +198,8 @@ for (let i = 0; i < args.length; i++) {
|
|
|
187
198
|
showDetails = false;
|
|
188
199
|
} else if (arg === "--no-cache") {
|
|
189
200
|
noCache = true;
|
|
201
|
+
} else if (arg === "--no-format") {
|
|
202
|
+
noFormat = true;
|
|
190
203
|
} else if (arg === "--debug") {
|
|
191
204
|
debugMode = true;
|
|
192
205
|
} else if (arg === "--no-decode-entities") {
|
|
@@ -280,10 +293,12 @@ try {
|
|
|
280
293
|
debug("Cache written: summary.md");
|
|
281
294
|
}
|
|
282
295
|
|
|
296
|
+
const formatted = noFormat ? summary : await formatMd(summary);
|
|
297
|
+
|
|
283
298
|
if (outputPath) {
|
|
284
|
-
await writeFile(outputPath,
|
|
299
|
+
await writeFile(outputPath, formatted, "utf8");
|
|
285
300
|
} else {
|
|
286
|
-
console.log(
|
|
301
|
+
console.log(formatted);
|
|
287
302
|
}
|
|
288
303
|
process.exit(0);
|
|
289
304
|
} else if (listOnly) {
|