offcourse 1.0.0 → 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/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/inspect.js +1 -1
- package/dist/cli/commands/inspect.js.map +1 -1
- package/dist/cli/commands/sync.d.ts +1 -2
- package/dist/cli/commands/sync.d.ts.map +1 -1
- package/dist/cli/commands/sync.js +13 -14
- package/dist/cli/commands/sync.js.map +1 -1
- package/dist/cli/commands/syncHighLevel.d.ts +1 -2
- package/dist/cli/commands/syncHighLevel.d.ts.map +1 -1
- package/dist/cli/commands/syncHighLevel.js +4 -8
- package/dist/cli/commands/syncHighLevel.js.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/config/configManager.d.ts.map +1 -1
- package/dist/config/configManager.js +4 -0
- package/dist/config/configManager.js.map +1 -1
- package/dist/downloader/hlsDownloader.d.ts.map +1 -1
- package/dist/downloader/hlsDownloader.js +23 -14
- package/dist/downloader/hlsDownloader.js.map +1 -1
- package/dist/downloader/hlsValidator.d.ts.map +1 -1
- package/dist/downloader/hlsValidator.js +6 -2
- package/dist/downloader/hlsValidator.js.map +1 -1
- package/dist/downloader/index.d.ts +3 -0
- package/dist/downloader/index.d.ts.map +1 -1
- package/dist/downloader/index.js +3 -0
- package/dist/downloader/index.js.map +1 -1
- package/dist/downloader/loomDownloader.d.ts.map +1 -1
- package/dist/downloader/loomDownloader.js +23 -20
- package/dist/downloader/loomDownloader.js.map +1 -1
- package/dist/downloader/queue.d.ts +4 -4
- package/dist/downloader/queue.d.ts.map +1 -1
- package/dist/downloader/queue.js.map +1 -1
- package/dist/downloader/vimeoDownloader.d.ts.map +1 -1
- package/dist/downloader/vimeoDownloader.js +7 -3
- package/dist/downloader/vimeoDownloader.js.map +1 -1
- package/dist/scraper/extractor.d.ts +4 -0
- package/dist/scraper/extractor.d.ts.map +1 -1
- package/dist/scraper/extractor.js +79 -79
- package/dist/scraper/extractor.js.map +1 -1
- package/dist/scraper/highlevel/extractor.d.ts +11 -19
- package/dist/scraper/highlevel/extractor.d.ts.map +1 -1
- package/dist/scraper/highlevel/extractor.js +72 -85
- package/dist/scraper/highlevel/extractor.js.map +1 -1
- package/dist/scraper/highlevel/navigator.d.ts +3 -10
- package/dist/scraper/highlevel/navigator.d.ts.map +1 -1
- package/dist/scraper/highlevel/navigator.js +140 -127
- package/dist/scraper/highlevel/navigator.js.map +1 -1
- package/dist/scraper/highlevel/schemas.d.ts +188 -0
- package/dist/scraper/highlevel/schemas.d.ts.map +1 -0
- package/dist/scraper/highlevel/schemas.js +139 -0
- package/dist/scraper/highlevel/schemas.js.map +1 -0
- package/dist/scraper/navigator.d.ts +14 -11
- package/dist/scraper/navigator.d.ts.map +1 -1
- package/dist/scraper/navigator.js +61 -104
- package/dist/scraper/navigator.js.map +1 -1
- package/dist/scraper/schemas.d.ts +57 -0
- package/dist/scraper/schemas.d.ts.map +1 -0
- package/dist/scraper/schemas.js +135 -0
- package/dist/scraper/schemas.js.map +1 -0
- package/dist/scraper/videoInterceptor.d.ts +4 -0
- package/dist/scraper/videoInterceptor.d.ts.map +1 -1
- package/dist/scraper/videoInterceptor.js +66 -51
- package/dist/scraper/videoInterceptor.js.map +1 -1
- package/dist/shared/auth.d.ts +9 -9
- package/dist/shared/auth.d.ts.map +1 -1
- package/dist/shared/auth.js +24 -38
- package/dist/shared/auth.js.map +1 -1
- package/dist/shared/firebase.d.ts +60 -0
- package/dist/shared/firebase.d.ts.map +1 -0
- package/dist/shared/firebase.js +102 -0
- package/dist/shared/firebase.js.map +1 -0
- package/dist/shared/fs.d.ts.map +1 -1
- package/dist/shared/fs.js +4 -0
- package/dist/shared/fs.js.map +1 -1
- package/dist/shared/index.d.ts +3 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +3 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/slug.d.ts +11 -0
- package/dist/shared/slug.d.ts.map +1 -0
- package/{src/shared/slug.ts → dist/shared/slug.js} +10 -11
- package/dist/shared/slug.js.map +1 -0
- package/dist/shared/url.d.ts +43 -0
- package/dist/shared/url.d.ts.map +1 -0
- package/{src/shared/url.ts → dist/shared/url.js} +12 -15
- package/dist/shared/url.js.map +1 -0
- package/dist/state/database.d.ts +1 -0
- package/dist/state/database.d.ts.map +1 -1
- package/dist/state/database.js +3 -0
- package/dist/state/database.js.map +1 -1
- package/dist/storage/fileSystem.d.ts +17 -17
- package/dist/storage/fileSystem.d.ts.map +1 -1
- package/dist/storage/fileSystem.js +39 -31
- package/dist/storage/fileSystem.js.map +1 -1
- package/package.json +5 -2
- package/.github/workflows/ci.yml +0 -50
- package/.husky/commit-msg +0 -2
- package/.husky/pre-commit +0 -1
- package/.husky/pre-push +0 -3
- package/.prettierrc +0 -8
- package/.release-it.json +0 -23
- package/ARCHITECTURE.md +0 -233
- package/CHANGELOG.md +0 -78
- package/commitlint.config.js +0 -4
- package/dist/ai/openRouter.d.ts +0 -47
- package/dist/ai/openRouter.d.ts.map +0 -1
- package/dist/ai/openRouter.js +0 -116
- package/dist/ai/openRouter.js.map +0 -1
- package/dist/ai/transcriptPolisher.d.ts +0 -24
- package/dist/ai/transcriptPolisher.d.ts.map +0 -1
- package/dist/ai/transcriptPolisher.js +0 -89
- package/dist/ai/transcriptPolisher.js.map +0 -1
- package/dist/cli/commands/enrich.d.ts +0 -14
- package/dist/cli/commands/enrich.d.ts.map +0 -1
- package/dist/cli/commands/enrich.js +0 -271
- package/dist/cli/commands/enrich.js.map +0 -1
- package/dist/cli/commands/syncGhl.d.ts +0 -20
- package/dist/cli/commands/syncGhl.d.ts.map +0 -1
- package/dist/cli/commands/syncGhl.js +0 -483
- package/dist/cli/commands/syncGhl.js.map +0 -1
- package/dist/cli/commands/syncHighLevel.test.d.ts +0 -2
- package/dist/cli/commands/syncHighLevel.test.d.ts.map +0 -1
- package/dist/cli/commands/syncHighLevel.test.js +0 -102
- package/dist/cli/commands/syncHighLevel.test.js.map +0 -1
- package/dist/config/paths.test.d.ts +0 -2
- package/dist/config/paths.test.d.ts.map +0 -1
- package/dist/config/paths.test.js +0 -70
- package/dist/config/paths.test.js.map +0 -1
- package/dist/config/schema.test.d.ts +0 -2
- package/dist/config/schema.test.d.ts.map +0 -1
- package/dist/config/schema.test.js +0 -151
- package/dist/config/schema.test.js.map +0 -1
- package/dist/downloader/hlsDownloader.test.d.ts +0 -2
- package/dist/downloader/hlsDownloader.test.d.ts.map +0 -1
- package/dist/downloader/hlsDownloader.test.js +0 -116
- package/dist/downloader/hlsDownloader.test.js.map +0 -1
- package/dist/downloader/loomDownloader.test.d.ts +0 -2
- package/dist/downloader/loomDownloader.test.d.ts.map +0 -1
- package/dist/downloader/loomDownloader.test.js +0 -36
- package/dist/downloader/loomDownloader.test.js.map +0 -1
- package/dist/downloader/queue.test.d.ts +0 -2
- package/dist/downloader/queue.test.d.ts.map +0 -1
- package/dist/downloader/queue.test.js +0 -158
- package/dist/downloader/queue.test.js.map +0 -1
- package/dist/downloader/videoDownloader.d.ts +0 -32
- package/dist/downloader/videoDownloader.d.ts.map +0 -1
- package/dist/downloader/videoDownloader.js +0 -173
- package/dist/downloader/videoDownloader.js.map +0 -1
- package/dist/downloader/vimeoDownloader.test.d.ts +0 -2
- package/dist/downloader/vimeoDownloader.test.d.ts.map +0 -1
- package/dist/downloader/vimeoDownloader.test.js +0 -51
- package/dist/downloader/vimeoDownloader.test.js.map +0 -1
- package/dist/scraper/auth.d.ts +0 -29
- package/dist/scraper/auth.d.ts.map +0 -1
- package/dist/scraper/auth.js +0 -115
- package/dist/scraper/auth.js.map +0 -1
- package/dist/scraper/extractor.test.d.ts +0 -2
- package/dist/scraper/extractor.test.d.ts.map +0 -1
- package/dist/scraper/extractor.test.js +0 -65
- package/dist/scraper/extractor.test.js.map +0 -1
- package/dist/scraper/ghl/auth.d.ts +0 -25
- package/dist/scraper/ghl/auth.d.ts.map +0 -1
- package/dist/scraper/ghl/auth.js +0 -187
- package/dist/scraper/ghl/auth.js.map +0 -1
- package/dist/scraper/ghl/extractor.d.ts +0 -96
- package/dist/scraper/ghl/extractor.d.ts.map +0 -1
- package/dist/scraper/ghl/extractor.js +0 -345
- package/dist/scraper/ghl/extractor.js.map +0 -1
- package/dist/scraper/ghl/index.d.ts +0 -4
- package/dist/scraper/ghl/index.d.ts.map +0 -1
- package/dist/scraper/ghl/index.js +0 -4
- package/dist/scraper/ghl/index.js.map +0 -1
- package/dist/scraper/ghl/navigator.d.ts +0 -93
- package/dist/scraper/ghl/navigator.d.ts.map +0 -1
- package/dist/scraper/ghl/navigator.js +0 -447
- package/dist/scraper/ghl/navigator.js.map +0 -1
- package/dist/scraper/highlevel/auth.d.ts +0 -25
- package/dist/scraper/highlevel/auth.d.ts.map +0 -1
- package/dist/scraper/highlevel/auth.js +0 -189
- package/dist/scraper/highlevel/auth.js.map +0 -1
- package/dist/scraper/highlevel/extractor.test.d.ts +0 -2
- package/dist/scraper/highlevel/extractor.test.d.ts.map +0 -1
- package/dist/scraper/highlevel/extractor.test.js +0 -101
- package/dist/scraper/highlevel/extractor.test.js.map +0 -1
- package/dist/scraper/highlevel/navigator.test.d.ts +0 -2
- package/dist/scraper/highlevel/navigator.test.d.ts.map +0 -1
- package/dist/scraper/highlevel/navigator.test.js +0 -78
- package/dist/scraper/highlevel/navigator.test.js.map +0 -1
- package/dist/scraper/navigator.test.d.ts +0 -2
- package/dist/scraper/navigator.test.d.ts.map +0 -1
- package/dist/scraper/navigator.test.js +0 -63
- package/dist/scraper/navigator.test.js.map +0 -1
- package/dist/scraper/skoolApi.d.ts +0 -17
- package/dist/scraper/skoolApi.d.ts.map +0 -1
- package/dist/scraper/skoolApi.js +0 -72
- package/dist/scraper/skoolApi.js.map +0 -1
- package/dist/state/database.test.d.ts +0 -2
- package/dist/state/database.test.d.ts.map +0 -1
- package/dist/state/database.test.js +0 -34
- package/dist/state/database.test.js.map +0 -1
- package/dist/transcription/whisperService.d.ts +0 -27
- package/dist/transcription/whisperService.d.ts.map +0 -1
- package/dist/transcription/whisperService.js +0 -102
- package/dist/transcription/whisperService.js.map +0 -1
- package/eslint.config.js +0 -55
- package/src/__fixtures__/highlevel-post-response.json +0 -68
- package/src/__fixtures__/hls-master-playlist.m3u8 +0 -24
- package/src/cli/commands/__snapshots__/syncHighLevel.test.ts.snap +0 -38
- package/src/cli/commands/config.ts +0 -74
- package/src/cli/commands/inspect.ts +0 -441
- package/src/cli/commands/login.ts +0 -68
- package/src/cli/commands/status.ts +0 -147
- package/src/cli/commands/sync.ts +0 -1235
- package/src/cli/commands/syncHighLevel.test.ts +0 -144
- package/src/cli/commands/syncHighLevel.ts +0 -639
- package/src/cli/index.ts +0 -121
- package/src/config/configManager.ts +0 -75
- package/src/config/paths.test.ts +0 -83
- package/src/config/paths.ts +0 -36
- package/src/config/schema.test.ts +0 -173
- package/src/config/schema.ts +0 -65
- package/src/downloader/hlsDownloader.test.ts +0 -148
- package/src/downloader/hlsDownloader.ts +0 -327
- package/src/downloader/hlsValidator.ts +0 -196
- package/src/downloader/index.ts +0 -122
- package/src/downloader/loomDownloader.test.ts +0 -43
- package/src/downloader/loomDownloader.ts +0 -742
- package/src/downloader/queue.test.ts +0 -199
- package/src/downloader/queue.ts +0 -118
- package/src/downloader/vimeoDownloader.test.ts +0 -62
- package/src/downloader/vimeoDownloader.ts +0 -722
- package/src/scraper/extractor.test.ts +0 -124
- package/src/scraper/extractor.ts +0 -757
- package/src/scraper/highlevel/__snapshots__/extractor.test.ts.snap +0 -41
- package/src/scraper/highlevel/extractor.test.ts +0 -134
- package/src/scraper/highlevel/extractor.ts +0 -537
- package/src/scraper/highlevel/index.ts +0 -2
- package/src/scraper/highlevel/navigator.test.ts +0 -110
- package/src/scraper/highlevel/navigator.ts +0 -668
- package/src/scraper/highlevel/schemas.ts +0 -183
- package/src/scraper/navigator.test.ts +0 -122
- package/src/scraper/navigator.ts +0 -355
- package/src/scraper/schemas.ts +0 -177
- package/src/scraper/videoInterceptor.ts +0 -435
- package/src/shared/auth.test.ts +0 -58
- package/src/shared/auth.ts +0 -251
- package/src/shared/firebase.ts +0 -151
- package/src/shared/fs.ts +0 -80
- package/src/shared/http.ts +0 -34
- package/src/shared/index.ts +0 -6
- package/src/shared/url.test.ts +0 -122
- package/src/state/database.test.ts +0 -49
- package/src/state/database.ts +0 -919
- package/src/state/index.ts +0 -14
- package/src/storage/fileSystem.test.ts +0 -64
- package/src/storage/fileSystem.ts +0 -175
- package/tsconfig.json +0 -28
- package/vitest.config.ts +0 -29
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { expandPath, getSessionPath, getSyncStatePath, APP_DIR } from "./paths.js";
|
|
5
|
-
describe("expandPath", () => {
|
|
6
|
-
it("expands ~ to home directory", () => {
|
|
7
|
-
const result = expandPath("~/Downloads/offcourse");
|
|
8
|
-
expect(result).toBe(join(homedir(), "Downloads/offcourse"));
|
|
9
|
-
});
|
|
10
|
-
it("expands ~/nested/path correctly", () => {
|
|
11
|
-
const result = expandPath("~/foo/bar/baz");
|
|
12
|
-
expect(result).toBe(join(homedir(), "foo/bar/baz"));
|
|
13
|
-
});
|
|
14
|
-
it("returns absolute paths unchanged", () => {
|
|
15
|
-
const result = expandPath("/usr/local/bin");
|
|
16
|
-
expect(result).toBe("/usr/local/bin");
|
|
17
|
-
});
|
|
18
|
-
it("returns relative paths unchanged", () => {
|
|
19
|
-
const result = expandPath("relative/path");
|
|
20
|
-
expect(result).toBe("relative/path");
|
|
21
|
-
});
|
|
22
|
-
it("handles just ~ correctly", () => {
|
|
23
|
-
// untildify expands ~ to home directory
|
|
24
|
-
const result = expandPath("~");
|
|
25
|
-
expect(result).toBe(homedir());
|
|
26
|
-
});
|
|
27
|
-
it("handles empty string", () => {
|
|
28
|
-
const result = expandPath("");
|
|
29
|
-
expect(result).toBe("");
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
describe("getSessionPath", () => {
|
|
33
|
-
it("generates correct session path for simple domain", () => {
|
|
34
|
-
const result = getSessionPath("example.com");
|
|
35
|
-
expect(result).toMatch(/\.offcourse\/sessions\/example\.com\.json$/);
|
|
36
|
-
});
|
|
37
|
-
it("sanitizes domains with special characters", () => {
|
|
38
|
-
const result = getSessionPath("sub.domain.com");
|
|
39
|
-
expect(result).toMatch(/sub\.domain\.com\.json$/);
|
|
40
|
-
});
|
|
41
|
-
it("replaces invalid filesystem characters with underscores", () => {
|
|
42
|
-
const result = getSessionPath("example.com/path?query");
|
|
43
|
-
expect(result).toMatch(/example\.com_path_query\.json$/);
|
|
44
|
-
});
|
|
45
|
-
it("handles domains with ports", () => {
|
|
46
|
-
const result = getSessionPath("localhost:3000");
|
|
47
|
-
expect(result).toMatch(/localhost_3000\.json$/);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
describe("getSyncStatePath", () => {
|
|
51
|
-
it("generates correct sync state path for simple slug", () => {
|
|
52
|
-
const result = getSyncStatePath("my-course");
|
|
53
|
-
expect(result).toMatch(/\.offcourse\/sync-state\/my-course\.json$/);
|
|
54
|
-
});
|
|
55
|
-
it("sanitizes slugs with special characters", () => {
|
|
56
|
-
const result = getSyncStatePath("Course Name: Special!");
|
|
57
|
-
expect(result).toMatch(/Course_Name__Special_\.json$/);
|
|
58
|
-
});
|
|
59
|
-
it("handles slugs with only valid characters", () => {
|
|
60
|
-
const result = getSyncStatePath("valid-slug-123");
|
|
61
|
-
expect(result).toMatch(/valid-slug-123\.json$/);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
describe("APP_DIR", () => {
|
|
65
|
-
it("is defined and contains offcourse", () => {
|
|
66
|
-
expect(APP_DIR).toBeDefined();
|
|
67
|
-
expect(APP_DIR).toContain("offcourse");
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
//# sourceMappingURL=paths.test.js.map
|
|
@@ -1 +0,0 @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CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,MAAM,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAC7C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,2CAA2C,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACjD,MAAM,MAAM,GAAG,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;QACzD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,MAAM,MAAM,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;QAClD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9B,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.test.d.ts","sourceRoot":"","sources":["../../src/config/schema.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { configSchema, courseSyncStateSchema, sessionInfoSchema } from "./schema.js";
|
|
3
|
-
describe("configSchema", () => {
|
|
4
|
-
it("parses empty object with defaults", () => {
|
|
5
|
-
const result = configSchema.parse({});
|
|
6
|
-
expect(result).toEqual({
|
|
7
|
-
outputDir: "~/Downloads/offcourse",
|
|
8
|
-
videoQuality: "highest",
|
|
9
|
-
concurrency: 2,
|
|
10
|
-
retryAttempts: 3,
|
|
11
|
-
headless: true,
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
it("accepts valid config values", () => {
|
|
15
|
-
const input = {
|
|
16
|
-
outputDir: "/custom/path",
|
|
17
|
-
videoQuality: "720p",
|
|
18
|
-
concurrency: 4,
|
|
19
|
-
retryAttempts: 5,
|
|
20
|
-
headless: false,
|
|
21
|
-
};
|
|
22
|
-
const result = configSchema.parse(input);
|
|
23
|
-
expect(result).toEqual(input);
|
|
24
|
-
});
|
|
25
|
-
it("rejects invalid video quality", () => {
|
|
26
|
-
expect(() => configSchema.parse({ videoQuality: "4k" })).toThrow();
|
|
27
|
-
});
|
|
28
|
-
it("rejects concurrency outside valid range", () => {
|
|
29
|
-
expect(() => configSchema.parse({ concurrency: 0 })).toThrow();
|
|
30
|
-
expect(() => configSchema.parse({ concurrency: 6 })).toThrow();
|
|
31
|
-
});
|
|
32
|
-
it("rejects retry attempts outside valid range", () => {
|
|
33
|
-
expect(() => configSchema.parse({ retryAttempts: -1 })).toThrow();
|
|
34
|
-
expect(() => configSchema.parse({ retryAttempts: 11 })).toThrow();
|
|
35
|
-
});
|
|
36
|
-
it("accepts all valid video quality values", () => {
|
|
37
|
-
const qualities = ["highest", "lowest", "1080p", "720p", "480p"];
|
|
38
|
-
for (const quality of qualities) {
|
|
39
|
-
const result = configSchema.parse({ videoQuality: quality });
|
|
40
|
-
expect(result.videoQuality).toBe(quality);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
describe("courseSyncStateSchema", () => {
|
|
45
|
-
it("validates minimal course sync state", () => {
|
|
46
|
-
const input = {
|
|
47
|
-
url: "https://example.com/course",
|
|
48
|
-
name: "My Course",
|
|
49
|
-
modules: [],
|
|
50
|
-
};
|
|
51
|
-
const result = courseSyncStateSchema.parse(input);
|
|
52
|
-
expect(result.url).toBe(input.url);
|
|
53
|
-
expect(result.name).toBe(input.name);
|
|
54
|
-
expect(result.modules).toEqual([]);
|
|
55
|
-
});
|
|
56
|
-
it("validates complete course sync state", () => {
|
|
57
|
-
const input = {
|
|
58
|
-
url: "https://example.com/course",
|
|
59
|
-
name: "My Course",
|
|
60
|
-
lastSyncedAt: "2024-01-15T10:30:00.000Z",
|
|
61
|
-
modules: [
|
|
62
|
-
{
|
|
63
|
-
name: "Module 1",
|
|
64
|
-
slug: "abc12345",
|
|
65
|
-
lessons: [
|
|
66
|
-
{
|
|
67
|
-
name: "Lesson 1",
|
|
68
|
-
slug: "def67890",
|
|
69
|
-
url: "https://example.com/lesson/1",
|
|
70
|
-
isCompleted: true,
|
|
71
|
-
videoDownloaded: true,
|
|
72
|
-
contentSaved: true,
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
};
|
|
78
|
-
const result = courseSyncStateSchema.parse(input);
|
|
79
|
-
expect(result).toEqual(input);
|
|
80
|
-
});
|
|
81
|
-
it("applies default values for lesson flags", () => {
|
|
82
|
-
const input = {
|
|
83
|
-
url: "https://example.com/course",
|
|
84
|
-
name: "My Course",
|
|
85
|
-
modules: [
|
|
86
|
-
{
|
|
87
|
-
name: "Module 1",
|
|
88
|
-
slug: "abc12345",
|
|
89
|
-
lessons: [
|
|
90
|
-
{
|
|
91
|
-
name: "Lesson 1",
|
|
92
|
-
slug: "def67890",
|
|
93
|
-
url: "https://example.com/lesson/1",
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
};
|
|
99
|
-
const result = courseSyncStateSchema.parse(input);
|
|
100
|
-
const lesson = result.modules[0]?.lessons[0];
|
|
101
|
-
expect(lesson?.isCompleted).toBe(false);
|
|
102
|
-
expect(lesson?.videoDownloaded).toBe(false);
|
|
103
|
-
expect(lesson?.contentSaved).toBe(false);
|
|
104
|
-
});
|
|
105
|
-
it("rejects invalid URL", () => {
|
|
106
|
-
expect(() => courseSyncStateSchema.parse({
|
|
107
|
-
url: "not-a-url",
|
|
108
|
-
name: "Course",
|
|
109
|
-
modules: [],
|
|
110
|
-
})).toThrow();
|
|
111
|
-
});
|
|
112
|
-
it("rejects invalid datetime format", () => {
|
|
113
|
-
expect(() => courseSyncStateSchema.parse({
|
|
114
|
-
url: "https://example.com/course",
|
|
115
|
-
name: "Course",
|
|
116
|
-
lastSyncedAt: "invalid-date",
|
|
117
|
-
modules: [],
|
|
118
|
-
})).toThrow();
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
describe("sessionInfoSchema", () => {
|
|
122
|
-
it("validates complete session info", () => {
|
|
123
|
-
const input = {
|
|
124
|
-
domain: "example.com",
|
|
125
|
-
createdAt: "2024-01-15T10:30:00.000Z",
|
|
126
|
-
expiresAt: "2024-02-15T10:30:00.000Z",
|
|
127
|
-
};
|
|
128
|
-
const result = sessionInfoSchema.parse(input);
|
|
129
|
-
expect(result).toEqual(input);
|
|
130
|
-
});
|
|
131
|
-
it("accepts session without expiry", () => {
|
|
132
|
-
const input = {
|
|
133
|
-
domain: "example.com",
|
|
134
|
-
createdAt: "2024-01-15T10:30:00.000Z",
|
|
135
|
-
};
|
|
136
|
-
const result = sessionInfoSchema.parse(input);
|
|
137
|
-
expect(result.expiresAt).toBeUndefined();
|
|
138
|
-
});
|
|
139
|
-
it("rejects invalid createdAt datetime", () => {
|
|
140
|
-
expect(() => sessionInfoSchema.parse({
|
|
141
|
-
domain: "example.com",
|
|
142
|
-
createdAt: "not-a-date",
|
|
143
|
-
})).toThrow();
|
|
144
|
-
});
|
|
145
|
-
it("requires domain field", () => {
|
|
146
|
-
expect(() => sessionInfoSchema.parse({
|
|
147
|
-
createdAt: "2024-01-15T10:30:00.000Z",
|
|
148
|
-
})).toThrow();
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
//# sourceMappingURL=schema.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.test.js","sourceRoot":"","sources":["../../src/config/schema.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErF,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACtC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,SAAS,EAAE,uBAAuB;YAClC,YAAY,EAAE,SAAS;YACvB,WAAW,EAAE,CAAC;YACd,aAAa,EAAE,CAAC;YAChB,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,KAAK,GAAG;YACZ,SAAS,EAAE,cAAc;YACzB,YAAY,EAAE,MAAe;YAC7B,WAAW,EAAE,CAAC;YACd,aAAa,EAAE,CAAC;YAChB,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACvC,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACrE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC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,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACxC,MAAM,KAAK,GAAG;YACZ,MAAM,EAAE,aAAa;YACrB,SAAS,EAAE,0BAA0B;SACtC,CAAC;QACF,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,aAAa,EAAE,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,CAAC,GAAG,EAAE,CACV,iBAAiB,CAAC,KAAK,CAAC;YACtB,MAAM,EAAE,aAAa;YACrB,SAAS,EAAE,YAAY;SACxB,CAAC,CACH,CAAC,OAAO,EAAE,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,MAAM,CAAC,GAAG,EAAE,CACV,iBAAiB,CAAC,KAAK,CAAC;YACtB,SAAS,EAAE,0BAA0B;SACtC,CAAC,CACH,CAAC,OAAO,EAAE,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hlsDownloader.test.d.ts","sourceRoot":"","sources":["../../src/downloader/hlsDownloader.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { parseHLSPlaylist, parseHighLevelVideoUrl } from "./hlsDownloader.js";
|
|
3
|
-
describe("parseHLSPlaylist", () => {
|
|
4
|
-
const baseUrl = "https://cdn.example.com/video/";
|
|
5
|
-
it("parses master playlist with multiple qualities", () => {
|
|
6
|
-
const content = `#EXTM3U
|
|
7
|
-
#EXT-X-VERSION:3
|
|
8
|
-
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360
|
|
9
|
-
360p.m3u8
|
|
10
|
-
#EXT-X-STREAM-INF:BANDWIDTH=1400000,RESOLUTION=854x480
|
|
11
|
-
480p.m3u8
|
|
12
|
-
#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1280x720
|
|
13
|
-
720p.m3u8
|
|
14
|
-
#EXT-X-STREAM-INF:BANDWIDTH=5000000,RESOLUTION=1920x1080
|
|
15
|
-
1080p.m3u8`;
|
|
16
|
-
const result = parseHLSPlaylist(content, baseUrl);
|
|
17
|
-
expect(result).toHaveLength(4);
|
|
18
|
-
// Should be sorted by bandwidth (highest first)
|
|
19
|
-
expect(result[0].label).toBe("1080p");
|
|
20
|
-
expect(result[0].bandwidth).toBe(5000000);
|
|
21
|
-
expect(result[0].height).toBe(1080);
|
|
22
|
-
expect(result[0].width).toBe(1920);
|
|
23
|
-
expect(result[0].url).toBe("https://cdn.example.com/video/1080p.m3u8");
|
|
24
|
-
expect(result[3].label).toBe("360p");
|
|
25
|
-
expect(result[3].bandwidth).toBe(800000);
|
|
26
|
-
});
|
|
27
|
-
it("handles absolute URLs in playlist", () => {
|
|
28
|
-
const content = `#EXTM3U
|
|
29
|
-
#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=1280x720
|
|
30
|
-
https://other-cdn.com/video/720p.m3u8`;
|
|
31
|
-
const result = parseHLSPlaylist(content, baseUrl);
|
|
32
|
-
expect(result).toHaveLength(1);
|
|
33
|
-
expect(result[0].url).toBe("https://other-cdn.com/video/720p.m3u8");
|
|
34
|
-
});
|
|
35
|
-
it("handles playlist without resolution", () => {
|
|
36
|
-
const content = `#EXTM3U
|
|
37
|
-
#EXT-X-STREAM-INF:BANDWIDTH=500000
|
|
38
|
-
audio.m3u8`;
|
|
39
|
-
const result = parseHLSPlaylist(content, baseUrl);
|
|
40
|
-
expect(result).toHaveLength(1);
|
|
41
|
-
expect(result[0].label).toBe("500k");
|
|
42
|
-
expect(result[0].height).toBeUndefined();
|
|
43
|
-
expect(result[0].width).toBeUndefined();
|
|
44
|
-
});
|
|
45
|
-
it("handles empty playlist", () => {
|
|
46
|
-
const content = `#EXTM3U
|
|
47
|
-
#EXT-X-VERSION:3`;
|
|
48
|
-
const result = parseHLSPlaylist(content, baseUrl);
|
|
49
|
-
expect(result).toHaveLength(0);
|
|
50
|
-
});
|
|
51
|
-
it("ignores comments and metadata", () => {
|
|
52
|
-
const content = `#EXTM3U
|
|
53
|
-
#EXT-X-VERSION:3
|
|
54
|
-
# This is a comment
|
|
55
|
-
#EXT-X-INDEPENDENT-SEGMENTS
|
|
56
|
-
#EXT-X-STREAM-INF:BANDWIDTH=1000000,RESOLUTION=1280x720
|
|
57
|
-
720p.m3u8`;
|
|
58
|
-
const result = parseHLSPlaylist(content, baseUrl);
|
|
59
|
-
expect(result).toHaveLength(1);
|
|
60
|
-
});
|
|
61
|
-
it("handles real-world Vimeo-style playlist", () => {
|
|
62
|
-
const content = `#EXTM3U
|
|
63
|
-
#EXT-X-VERSION:4
|
|
64
|
-
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=246064,BANDWIDTH=326400,CODECS="avc1.4D401E,mp4a.40.2",RESOLUTION=426x240,FRAME-RATE=24.000
|
|
65
|
-
https://vod.example.com/exp=123/~hmac=abc/240p/prog_index.m3u8
|
|
66
|
-
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=602416,BANDWIDTH=796800,CODECS="avc1.4D401F,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=24.000
|
|
67
|
-
https://vod.example.com/exp=123/~hmac=abc/360p/prog_index.m3u8
|
|
68
|
-
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=1270416,BANDWIDTH=1680000,CODECS="avc1.4D401F,mp4a.40.2",RESOLUTION=854x480,FRAME-RATE=24.000
|
|
69
|
-
https://vod.example.com/exp=123/~hmac=abc/480p/prog_index.m3u8`;
|
|
70
|
-
const result = parseHLSPlaylist(content, baseUrl);
|
|
71
|
-
expect(result).toHaveLength(3);
|
|
72
|
-
expect(result[0].height).toBe(480);
|
|
73
|
-
expect(result[1].height).toBe(360);
|
|
74
|
-
expect(result[2].height).toBe(240);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
describe("parseHighLevelVideoUrl", () => {
|
|
78
|
-
it("parses standard HighLevel HLS URL", () => {
|
|
79
|
-
const url = "https://backend.leadconnectorhq.com/hls/v2/memberships/ABC123/videos/video-id-456/master.m3u8";
|
|
80
|
-
const result = parseHighLevelVideoUrl(url);
|
|
81
|
-
expect(result).toEqual({
|
|
82
|
-
locationId: "ABC123",
|
|
83
|
-
videoId: "video-id-456",
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
it("parses URL with token", () => {
|
|
87
|
-
const url = "https://backend.leadconnectorhq.com/hls/v2/memberships/LOC123/videos/VID456/master.m3u8?token=secret-token";
|
|
88
|
-
const result = parseHighLevelVideoUrl(url);
|
|
89
|
-
expect(result).toEqual({
|
|
90
|
-
locationId: "LOC123",
|
|
91
|
-
videoId: "VID456",
|
|
92
|
-
token: "secret-token",
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
it("handles complex video IDs", () => {
|
|
96
|
-
const url = "https://cdn.example.com/hls/memberships/location-abc/videos/cts-184162b5f0747fcd,1080p/master.m3u8";
|
|
97
|
-
const result = parseHighLevelVideoUrl(url);
|
|
98
|
-
expect(result).toEqual({
|
|
99
|
-
locationId: "location-abc",
|
|
100
|
-
videoId: "cts-184162b5f0747fcd",
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
it("returns null for non-HighLevel URLs", () => {
|
|
104
|
-
expect(parseHighLevelVideoUrl("https://vimeo.com/123456")).toBeNull();
|
|
105
|
-
expect(parseHighLevelVideoUrl("https://youtube.com/watch?v=abc")).toBeNull();
|
|
106
|
-
});
|
|
107
|
-
it("returns null for invalid URLs", () => {
|
|
108
|
-
expect(parseHighLevelVideoUrl("not-a-url")).toBeNull();
|
|
109
|
-
expect(parseHighLevelVideoUrl("")).toBeNull();
|
|
110
|
-
});
|
|
111
|
-
it("returns null for missing video path", () => {
|
|
112
|
-
const url = "https://backend.leadconnectorhq.com/hls/v2/other/path";
|
|
113
|
-
expect(parseHighLevelVideoUrl(url)).toBeNull();
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
//# sourceMappingURL=hlsDownloader.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hlsDownloader.test.js","sourceRoot":"","sources":["../../src/downloader/hlsDownloader.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE9E,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,MAAM,OAAO,GAAG,gCAAgC,CAAC;IAEjD,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,OAAO,GAAG;;;;;;;;;WAST,CAAC;QAER,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAElD,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC/B,gDAAgD;QAChD,MAAM,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3C,MAAM,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,MAAM,CAAC,MAAM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C7C,MAAM,GAAG,GAAG,uDAAuD,CAAC;QACpE,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loomDownloader.test.d.ts","sourceRoot":"","sources":["../../src/downloader/loomDownloader.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { extractLoomId } from "./loomDownloader.js";
|
|
3
|
-
describe("extractLoomId", () => {
|
|
4
|
-
it("extracts ID from embed URL", () => {
|
|
5
|
-
const url = "https://www.loom.com/embed/a1b2c3d4e5f6";
|
|
6
|
-
expect(extractLoomId(url)).toBe("a1b2c3d4e5f6");
|
|
7
|
-
});
|
|
8
|
-
it("extracts ID from share URL", () => {
|
|
9
|
-
const url = "https://www.loom.com/share/abcdef123456";
|
|
10
|
-
expect(extractLoomId(url)).toBe("abcdef123456");
|
|
11
|
-
});
|
|
12
|
-
it("extracts ID from URL with query params", () => {
|
|
13
|
-
const url = "https://www.loom.com/embed/abc123?autoplay=1&t=10";
|
|
14
|
-
expect(extractLoomId(url)).toBe("abc123");
|
|
15
|
-
});
|
|
16
|
-
it("handles URL without www", () => {
|
|
17
|
-
const url = "https://loom.com/embed/abc123def456";
|
|
18
|
-
expect(extractLoomId(url)).toBe("abc123def456");
|
|
19
|
-
});
|
|
20
|
-
it("returns null for invalid URL", () => {
|
|
21
|
-
expect(extractLoomId("https://youtube.com/watch?v=123")).toBeNull();
|
|
22
|
-
expect(extractLoomId("not-a-url")).toBeNull();
|
|
23
|
-
});
|
|
24
|
-
it("returns null for Loom homepage", () => {
|
|
25
|
-
expect(extractLoomId("https://loom.com")).toBeNull();
|
|
26
|
-
});
|
|
27
|
-
it("returns null for empty string", () => {
|
|
28
|
-
expect(extractLoomId("")).toBeNull();
|
|
29
|
-
});
|
|
30
|
-
it("handles very long IDs", () => {
|
|
31
|
-
const longId = "a".repeat(32);
|
|
32
|
-
const url = `https://loom.com/embed/${longId}`;
|
|
33
|
-
expect(extractLoomId(url)).toBe(longId);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=loomDownloader.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loomDownloader.test.js","sourceRoot":"","sources":["../../src/downloader/loomDownloader.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,GAAG,GAAG,yCAAyC,CAAC;QACtD,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,GAAG,GAAG,yCAAyC,CAAC;QACtD,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,MAAM,GAAG,GAAG,mDAAmD,CAAC;QAChE,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,GAAG,GAAG,qCAAqC,CAAC;QAClD,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC,MAAM,CAAC,aAAa,CAAC,iCAAiC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QACpE,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACxC,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACvC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC9B,MAAM,GAAG,GAAG,0BAA0B,MAAM,EAAE,CAAC;QAC/C,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queue.test.d.ts","sourceRoot":"","sources":["../../src/downloader/queue.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { AsyncQueue } from "./queue.js";
|
|
3
|
-
describe("AsyncQueue", () => {
|
|
4
|
-
it("processes items in order", async () => {
|
|
5
|
-
const processed = [];
|
|
6
|
-
const queue = new AsyncQueue({
|
|
7
|
-
concurrency: 1,
|
|
8
|
-
maxRetries: 0,
|
|
9
|
-
});
|
|
10
|
-
queue.add("1", "first");
|
|
11
|
-
queue.add("2", "second");
|
|
12
|
-
queue.add("3", "third");
|
|
13
|
-
await queue.process(async (item) => {
|
|
14
|
-
processed.push(item);
|
|
15
|
-
});
|
|
16
|
-
expect(processed).toEqual(["first", "second", "third"]);
|
|
17
|
-
});
|
|
18
|
-
it("tracks completed and failed counts", async () => {
|
|
19
|
-
const queue = new AsyncQueue({
|
|
20
|
-
concurrency: 1,
|
|
21
|
-
maxRetries: 0,
|
|
22
|
-
});
|
|
23
|
-
queue.add("1", "success");
|
|
24
|
-
queue.add("2", "fail");
|
|
25
|
-
queue.add("3", "success");
|
|
26
|
-
const result = await queue.process(async (item) => {
|
|
27
|
-
if (item === "fail") {
|
|
28
|
-
throw new Error("Intentional failure");
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
expect(result.completed).toBe(2);
|
|
32
|
-
expect(result.failed).toBe(1);
|
|
33
|
-
expect(result.errors).toHaveLength(1);
|
|
34
|
-
expect(result.errors[0]?.id).toBe("2");
|
|
35
|
-
});
|
|
36
|
-
it("retries failed items up to maxRetries", async () => {
|
|
37
|
-
let attempts = 0;
|
|
38
|
-
const queue = new AsyncQueue({
|
|
39
|
-
concurrency: 1,
|
|
40
|
-
maxRetries: 3,
|
|
41
|
-
});
|
|
42
|
-
queue.add("1", "retry-test");
|
|
43
|
-
await queue.process(async () => {
|
|
44
|
-
attempts++;
|
|
45
|
-
if (attempts < 3) {
|
|
46
|
-
throw new Error("Not yet");
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
expect(attempts).toBe(3);
|
|
50
|
-
});
|
|
51
|
-
it("adds multiple items with addAll", async () => {
|
|
52
|
-
const queue = new AsyncQueue({
|
|
53
|
-
concurrency: 1,
|
|
54
|
-
maxRetries: 0,
|
|
55
|
-
});
|
|
56
|
-
queue.addAll([
|
|
57
|
-
{ id: "a", data: 1 },
|
|
58
|
-
{ id: "b", data: 2 },
|
|
59
|
-
{ id: "c", data: 3 },
|
|
60
|
-
]);
|
|
61
|
-
const sum = { value: 0 };
|
|
62
|
-
await queue.process(async (item) => {
|
|
63
|
-
sum.value += item;
|
|
64
|
-
});
|
|
65
|
-
expect(sum.value).toBe(6);
|
|
66
|
-
});
|
|
67
|
-
it("reports progress during processing", async () => {
|
|
68
|
-
const progressCalls = [];
|
|
69
|
-
const queue = new AsyncQueue({
|
|
70
|
-
concurrency: 1,
|
|
71
|
-
maxRetries: 0,
|
|
72
|
-
onProgress: (completed, total) => {
|
|
73
|
-
progressCalls.push({ completed, total });
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
queue.add("1", "a");
|
|
77
|
-
queue.add("2", "b");
|
|
78
|
-
queue.add("3", "c");
|
|
79
|
-
await queue.process(async () => {
|
|
80
|
-
// no-op
|
|
81
|
-
});
|
|
82
|
-
expect(progressCalls.length).toBeGreaterThan(0);
|
|
83
|
-
// Last call should have all completed
|
|
84
|
-
const lastCall = progressCalls.at(-1);
|
|
85
|
-
expect(lastCall?.completed).toBe(3);
|
|
86
|
-
expect(lastCall?.total).toBe(3);
|
|
87
|
-
});
|
|
88
|
-
it("returns correct status", async () => {
|
|
89
|
-
const queue = new AsyncQueue({
|
|
90
|
-
concurrency: 1,
|
|
91
|
-
maxRetries: 0,
|
|
92
|
-
});
|
|
93
|
-
queue.add("1", "a");
|
|
94
|
-
queue.add("2", "b");
|
|
95
|
-
const beforeStatus = queue.getStatus();
|
|
96
|
-
expect(beforeStatus.pending).toBe(2);
|
|
97
|
-
expect(beforeStatus.completed).toBe(0);
|
|
98
|
-
await queue.process(async () => { });
|
|
99
|
-
const afterStatus = queue.getStatus();
|
|
100
|
-
expect(afterStatus.pending).toBe(0);
|
|
101
|
-
expect(afterStatus.completed).toBe(2);
|
|
102
|
-
});
|
|
103
|
-
it("handles concurrent processing", async () => {
|
|
104
|
-
const processing = new Set();
|
|
105
|
-
let maxConcurrent = 0;
|
|
106
|
-
const queue = new AsyncQueue({
|
|
107
|
-
concurrency: 2,
|
|
108
|
-
maxRetries: 0,
|
|
109
|
-
});
|
|
110
|
-
queue.addAll([
|
|
111
|
-
{ id: "1", data: "a" },
|
|
112
|
-
{ id: "2", data: "b" },
|
|
113
|
-
{ id: "3", data: "c" },
|
|
114
|
-
{ id: "4", data: "d" },
|
|
115
|
-
]);
|
|
116
|
-
await queue.process(async (_item, id) => {
|
|
117
|
-
processing.add(id);
|
|
118
|
-
maxConcurrent = Math.max(maxConcurrent, processing.size);
|
|
119
|
-
// Simulate async work
|
|
120
|
-
await new Promise((r) => setTimeout(r, 10));
|
|
121
|
-
processing.delete(id);
|
|
122
|
-
});
|
|
123
|
-
expect(maxConcurrent).toBeLessThanOrEqual(2);
|
|
124
|
-
});
|
|
125
|
-
it("handles empty queue", async () => {
|
|
126
|
-
const queue = new AsyncQueue({
|
|
127
|
-
concurrency: 1,
|
|
128
|
-
maxRetries: 0,
|
|
129
|
-
});
|
|
130
|
-
const result = await queue.process(async () => { });
|
|
131
|
-
expect(result.completed).toBe(0);
|
|
132
|
-
expect(result.failed).toBe(0);
|
|
133
|
-
expect(result.errors).toEqual([]);
|
|
134
|
-
});
|
|
135
|
-
it("captures error messages correctly", async () => {
|
|
136
|
-
const queue = new AsyncQueue({
|
|
137
|
-
concurrency: 1,
|
|
138
|
-
maxRetries: 0,
|
|
139
|
-
});
|
|
140
|
-
queue.add("1", "test");
|
|
141
|
-
const result = await queue.process(async () => {
|
|
142
|
-
throw new Error("Specific error message");
|
|
143
|
-
});
|
|
144
|
-
expect(result.errors[0]?.error).toBe("Specific error message");
|
|
145
|
-
});
|
|
146
|
-
it("handles non-Error throws", async () => {
|
|
147
|
-
const queue = new AsyncQueue({
|
|
148
|
-
concurrency: 1,
|
|
149
|
-
maxRetries: 0,
|
|
150
|
-
});
|
|
151
|
-
queue.add("1", "test");
|
|
152
|
-
const result = await queue.process(async () => {
|
|
153
|
-
throw "String error";
|
|
154
|
-
});
|
|
155
|
-
expect(result.errors[0]?.error).toBe("String error");
|
|
156
|
-
});
|
|
157
|
-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;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { VideoQuality } from "../config/schema.js";
|
|
2
|
-
export interface DownloadResult {
|
|
3
|
-
success: boolean;
|
|
4
|
-
filePath: string | null;
|
|
5
|
-
error: string | null;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Checks if yt-dlp is available on the system.
|
|
9
|
-
*/
|
|
10
|
-
export declare function isYtDlpAvailable(): Promise<boolean>;
|
|
11
|
-
/**
|
|
12
|
-
* Normalizes various video URLs to formats yt-dlp can handle.
|
|
13
|
-
*/
|
|
14
|
-
export declare function normalizeVideoUrl(embedUrl: string, videoType: "loom" | "vimeo" | "youtube" | "wistia" | "native" | "unknown" | null): string;
|
|
15
|
-
/**
|
|
16
|
-
* Downloads a video using yt-dlp.
|
|
17
|
-
*/
|
|
18
|
-
export declare function downloadVideo(url: string, outputPath: string, options?: {
|
|
19
|
-
quality?: VideoQuality;
|
|
20
|
-
videoType?: "loom" | "vimeo" | "youtube" | "wistia" | "native" | "unknown" | null;
|
|
21
|
-
cookies?: string;
|
|
22
|
-
onProgress?: (percent: number) => void;
|
|
23
|
-
}): Promise<DownloadResult>;
|
|
24
|
-
/**
|
|
25
|
-
* Gets video info without downloading.
|
|
26
|
-
*/
|
|
27
|
-
export declare function getVideoInfo(url: string, videoType: "loom" | "vimeo" | "youtube" | "wistia" | "native" | "unknown" | null): Promise<{
|
|
28
|
-
title: string;
|
|
29
|
-
duration: number;
|
|
30
|
-
formats: string[];
|
|
31
|
-
} | null>;
|
|
32
|
-
//# sourceMappingURL=videoDownloader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"videoDownloader.d.ts","sourceRoot":"","sources":["../../src/downloader/videoDownloader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CA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