vidnavigator 2.6.0 → 2.7.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/README.md +12 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/models/AsyncJob.d.ts +5 -1
- package/dist/models/AsyncJob.js +1 -0
- package/dist/models/Extraction.d.ts +14 -0
- package/dist/webhooks.d.ts +6 -0
- package/package.json +1 -1
- package/src/index.ts +7 -1
- package/src/models/AsyncJob.ts +6 -1
- package/src/models/Extraction.ts +16 -0
- package/src/webhooks.ts +2 -0
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ The official JavaScript/TypeScript SDK for the [VidNavigator Developer API](http
|
|
|
28
28
|
|
|
29
29
|
| Platform | Transcript | Transcribe (speech-to-text) | Watch (scenes) | Carousel |
|
|
30
30
|
|----------|:----------:|:---------------------------:|:--------------:|:--------:|
|
|
31
|
-
| YouTube | Yes |
|
|
31
|
+
| YouTube | Yes | Yes | Yes | - |
|
|
32
32
|
| Instagram Reels | - | Yes | Yes | Yes |
|
|
33
33
|
| Instagram Posts | - | Yes | Yes | Yes (`all_videos`) |
|
|
34
34
|
| TikTok | Yes | Yes | Yes | - |
|
|
@@ -175,7 +175,7 @@ if (Array.isArray(watched.transcript)) {
|
|
|
175
175
|
console.log(watched.frames_analyzed); // number of frames that were analyzed
|
|
176
176
|
```
|
|
177
177
|
|
|
178
|
-
The transcript comes from the platform's captions when it has them, and from speech-to-text otherwise. A video without speech is not an error: `transcript` is empty, `transcript_error` says why, and the scenes are returned.
|
|
178
|
+
The transcript comes from the platform's captions when it has them, and from speech-to-text otherwise. A YouTube video without captions is transcribed from its audio, like the others. A video without speech is not an error: `transcript` is empty, `transcript_error` says why, and the scenes are returned.
|
|
179
179
|
|
|
180
180
|
```ts
|
|
181
181
|
const watched = await vn.watch(url);
|
|
@@ -1196,6 +1196,16 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
|
|
|
1196
1196
|
| `TikTokLiveRoomDetail` | A `TikTokLiveRoom` from `getTikTokLiveRoom`: `status` / `isLive`, `ended_at`, `stats.new_followers`, `author.bio`, `share_url`, `chat_enabled`, `subscribers_only`, `products` |
|
|
1197
1197
|
| `TweetStatement` | Structured X/Twitter claim analysis, topics, entities, tone, intent, and source text |
|
|
1198
1198
|
|
|
1199
|
+
## What's new in 2.7.0
|
|
1200
|
+
|
|
1201
|
+
- **Where each value comes from:** extraction results carry `evidence`: for each field of `data` that has a value, the moments of the video it was taken from (`FieldEvidence`: `start` and `end` in seconds, and `in`: `'speech'`, `'picture'` with `include_scenes`, or `'post'` for the post's own text, without times). On `extractVideoData`, `vn.extractVideo`, `extractFileData`, the async job and the `extract_video.completed` webhook event.
|
|
1202
|
+
- **YouTube speech-to-text:** `transcribe` takes YouTube videos, and a YouTube video without captions is transcribed by `watch` and by extraction (`transcribe: true`).
|
|
1203
|
+
|
|
1204
|
+
```ts
|
|
1205
|
+
const { data, evidence } = await vn.extractVideoData({ video_url, schema });
|
|
1206
|
+
for (const moment of evidence?.people ?? []) console.log(moment.in, moment.start, moment.end);
|
|
1207
|
+
```
|
|
1208
|
+
|
|
1199
1209
|
## What's new in 2.6.0
|
|
1200
1210
|
|
|
1201
1211
|
- **Extraction takes a standard JSON Schema**, the only schema format the API accepts now: `{ type: 'object', properties: { ... } }`, with lowercase types. A Zod schema converted with `zod-to-json-schema` can be passed as it is. The former format (`{ field: { type: 'String', ... } }`) is refused with `invalid_schema`. The `ExtractionSchema` and `ExtractionField` types describe the new format.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { VideoInfo, TranscriptOutput, FileInfo, AnalysisResult, VideoSearchResult, FileSearchResult, UsageData, Namespace, NamespaceRef, ExtractionSchema, UsageBlock, CarouselInfo, CarouselVideoResult, TikTokProfileScrapeRequest, TikTokProfileScrapeSubmission, TikTokProfileTask, TikTokSearchRequest, TikTokSearchSubmission, TikTokSearchTask, TikTokLiveSearchRequest, TikTokLiveSearchSubmission, TikTokLiveSearchTask, TikTokLiveRoomRequest, TikTokLiveRoomResult, TweetStatement, WatchResult, WatchTranscriptError, VideoScene, ScenesError, FileScenesStatus, AsyncJob } from './models';
|
|
2
|
+
import { VideoInfo, TranscriptOutput, FileInfo, AnalysisResult, VideoSearchResult, FileSearchResult, UsageData, Namespace, NamespaceRef, ExtractionEvidence, ExtractionSchema, UsageBlock, CarouselInfo, CarouselVideoResult, TikTokProfileScrapeRequest, TikTokProfileScrapeSubmission, TikTokProfileTask, TikTokSearchRequest, TikTokSearchSubmission, TikTokSearchTask, TikTokLiveSearchRequest, TikTokLiveSearchSubmission, TikTokLiveSearchTask, TikTokLiveRoomRequest, TikTokLiveRoomResult, TweetStatement, WatchResult, WatchTranscriptError, VideoScene, ScenesError, FileScenesStatus, AsyncJob } from './models';
|
|
3
3
|
import { Job, JobOperation, PollOptions, RunOptions, SubmitOptions } from './jobs';
|
|
4
4
|
export * from './models';
|
|
5
5
|
export * from './errors';
|
|
@@ -7,7 +7,7 @@ export * from './webhooks';
|
|
|
7
7
|
export { Job } from './jobs';
|
|
8
8
|
export type { TaskStatus, PollableTask, PollOptions, JobOperation, SubmitOptions, RunOptions, JobInfo } from './jobs';
|
|
9
9
|
/** SDK version (keep in sync with package.json) */
|
|
10
|
-
export declare const SDK_VERSION = "2.
|
|
10
|
+
export declare const SDK_VERSION = "2.7.0";
|
|
11
11
|
export interface SDKConfig {
|
|
12
12
|
apiKey: string;
|
|
13
13
|
baseURL?: string;
|
|
@@ -193,6 +193,8 @@ export interface ExtractDataResult {
|
|
|
193
193
|
data: Record<string, unknown>;
|
|
194
194
|
/** When the request had no schema: the schema written from `what_to_extract`, to pass as `schema` next time. */
|
|
195
195
|
schema?: ExtractionSchema;
|
|
196
|
+
/** For each field of `data` that has a value, the moments of the video it comes from. */
|
|
197
|
+
evidence?: ExtractionEvidence;
|
|
196
198
|
video_info?: VideoInfo;
|
|
197
199
|
file_info?: FileInfo;
|
|
198
200
|
/** With `include_scenes: true`: number of frames that were analyzed to produce the scenes. */
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ __exportStar(require("./webhooks"), exports);
|
|
|
31
31
|
var jobs_2 = require("./jobs");
|
|
32
32
|
Object.defineProperty(exports, "Job", { enumerable: true, get: function () { return jobs_2.Job; } });
|
|
33
33
|
/** SDK version (keep in sync with package.json) */
|
|
34
|
-
exports.SDK_VERSION = '2.
|
|
34
|
+
exports.SDK_VERSION = '2.7.0';
|
|
35
35
|
/**
|
|
36
36
|
* A LIVE room usually answers in 1-5 s, up to ~30 s when the API has to open a TikTok page, and two
|
|
37
37
|
* minutes at worst. A shorter configured axios timeout is raised to this for that call only.
|
|
@@ -191,6 +191,7 @@ class VidNavigatorClient {
|
|
|
191
191
|
video_info: task.video_info,
|
|
192
192
|
...pickSceneNotes(task),
|
|
193
193
|
...(task.schema ? { schema: task.schema } : {}),
|
|
194
|
+
...(task.evidence ? { evidence: task.evidence } : {}),
|
|
194
195
|
usage: task.usage,
|
|
195
196
|
}),
|
|
196
197
|
});
|
|
@@ -611,6 +612,7 @@ class VidNavigatorClient {
|
|
|
611
612
|
file_info: body.file_info ? models_1.FileInfo.fromJSON(body.file_info) : undefined,
|
|
612
613
|
...pickSceneNotes(body),
|
|
613
614
|
...(body.schema ? { schema: body.schema } : {}),
|
|
615
|
+
...(body.evidence ? { evidence: body.evidence } : {}),
|
|
614
616
|
usage: body.usage ? models_1.UsageBlock.fromJSON(body.usage) : undefined,
|
|
615
617
|
};
|
|
616
618
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtractionSchema } from './Extraction';
|
|
1
|
+
import type { ExtractionEvidence, ExtractionSchema } from './Extraction';
|
|
2
2
|
import { UsageBlock } from './Usage';
|
|
3
3
|
import { VideoInfo, VideoInfoJSON } from './VideoInfo';
|
|
4
4
|
import { ScenesError, WatchTranscriptError } from './Watch';
|
|
@@ -74,6 +74,8 @@ export interface AsyncJobJSON {
|
|
|
74
74
|
transcript_error?: WatchTranscriptError;
|
|
75
75
|
/** `extract_video` jobs, once completed, when the request had no schema: the schema written from `what_to_extract`. */
|
|
76
76
|
schema?: ExtractionSchema;
|
|
77
|
+
/** `extract_video` jobs, once completed: the moments each value of `result` comes from. */
|
|
78
|
+
evidence?: ExtractionEvidence;
|
|
77
79
|
error?: AsyncJobError | null;
|
|
78
80
|
}
|
|
79
81
|
/**
|
|
@@ -105,6 +107,8 @@ export declare class AsyncJob<TResult> {
|
|
|
105
107
|
transcript_error?: WatchTranscriptError;
|
|
106
108
|
/** `extract_video` jobs, once completed, when the request had no schema: the schema written from `what_to_extract`, to pass as `schema` next time. */
|
|
107
109
|
schema?: ExtractionSchema;
|
|
110
|
+
/** `extract_video` jobs, once completed: the moments each value of `result` comes from. */
|
|
111
|
+
evidence?: ExtractionEvidence;
|
|
108
112
|
error: AsyncJobError | null;
|
|
109
113
|
/** Per-call usage, populated only when polled with `include_usage: true` and `task_status === 'completed'`. */
|
|
110
114
|
usage?: UsageBlock;
|
package/dist/models/AsyncJob.js
CHANGED
|
@@ -32,6 +32,18 @@ export interface ExtractionTokenUsageJSON {
|
|
|
32
32
|
completion_tokens?: number;
|
|
33
33
|
total_tokens?: number;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* A moment an extracted value was taken from. `in` is `'speech'` (said in the video), `'picture'`
|
|
37
|
+
* (shown or written on screen) or `'post'` (the post's own text: title, channel, description;
|
|
38
|
+
* no `start`/`end` then).
|
|
39
|
+
*/
|
|
40
|
+
export interface FieldEvidence {
|
|
41
|
+
start?: number;
|
|
42
|
+
end?: number;
|
|
43
|
+
in: 'speech' | 'picture' | 'post';
|
|
44
|
+
}
|
|
45
|
+
/** For each field of `data` that has a value, the moments of the video it comes from (at most 5). */
|
|
46
|
+
export type ExtractionEvidence = Record<string, FieldEvidence[]>;
|
|
35
47
|
export interface ExtractionResponseJSON {
|
|
36
48
|
status: 'success';
|
|
37
49
|
data: Record<string, unknown>;
|
|
@@ -43,6 +55,8 @@ export interface ExtractionResponseJSON {
|
|
|
43
55
|
transcript_error?: WatchTranscriptError;
|
|
44
56
|
/** When the request had no schema: the schema written from `what_to_extract`, to pass as `schema` next time. */
|
|
45
57
|
schema?: ExtractionSchema;
|
|
58
|
+
/** Where each value of `data` comes from. */
|
|
59
|
+
evidence?: ExtractionEvidence;
|
|
46
60
|
usage?: ExtractionTokenUsageJSON;
|
|
47
61
|
}
|
|
48
62
|
export declare class ExtractionTokenUsage {
|
package/dist/webhooks.d.ts
CHANGED
|
@@ -33,6 +33,12 @@ export interface WebhookEvent {
|
|
|
33
33
|
video_info?: Record<string, unknown>;
|
|
34
34
|
/** `extract_video.completed` only, when the request had no schema: the schema written from `what_to_extract`. */
|
|
35
35
|
schema?: Record<string, unknown>;
|
|
36
|
+
/** `extract_video.completed` only: the moments each value of `result` comes from. */
|
|
37
|
+
evidence?: Record<string, Array<{
|
|
38
|
+
start?: number;
|
|
39
|
+
end?: number;
|
|
40
|
+
in: 'speech' | 'picture' | 'post';
|
|
41
|
+
}>>;
|
|
36
42
|
error?: AsyncJobError | null;
|
|
37
43
|
};
|
|
38
44
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
NamespaceJSON,
|
|
22
22
|
NamespaceRef,
|
|
23
23
|
NamespaceRefJSON,
|
|
24
|
+
ExtractionEvidence,
|
|
24
25
|
ExtractionSchema,
|
|
25
26
|
UsageBlock,
|
|
26
27
|
UsageBlockJSON,
|
|
@@ -72,7 +73,7 @@ export { Job } from './jobs';
|
|
|
72
73
|
export type { TaskStatus, PollableTask, PollOptions, JobOperation, SubmitOptions, RunOptions, JobInfo } from './jobs';
|
|
73
74
|
|
|
74
75
|
/** SDK version (keep in sync with package.json) */
|
|
75
|
-
export const SDK_VERSION = '2.
|
|
76
|
+
export const SDK_VERSION = '2.7.0';
|
|
76
77
|
|
|
77
78
|
/**
|
|
78
79
|
* A LIVE room usually answers in 1-5 s, up to ~30 s when the API has to open a TikTok page, and two
|
|
@@ -294,6 +295,8 @@ export interface ExtractDataResult {
|
|
|
294
295
|
data: Record<string, unknown>;
|
|
295
296
|
/** When the request had no schema: the schema written from `what_to_extract`, to pass as `schema` next time. */
|
|
296
297
|
schema?: ExtractionSchema;
|
|
298
|
+
/** For each field of `data` that has a value, the moments of the video it comes from. */
|
|
299
|
+
evidence?: ExtractionEvidence;
|
|
297
300
|
video_info?: VideoInfo;
|
|
298
301
|
file_info?: FileInfo;
|
|
299
302
|
/** With `include_scenes: true`: number of frames that were analyzed to produce the scenes. */
|
|
@@ -746,6 +749,7 @@ export class VidNavigatorClient {
|
|
|
746
749
|
video_info: task.video_info,
|
|
747
750
|
...pickSceneNotes(task),
|
|
748
751
|
...(task.schema ? { schema: task.schema } : {}),
|
|
752
|
+
...(task.evidence ? { evidence: task.evidence } : {}),
|
|
749
753
|
usage: task.usage,
|
|
750
754
|
}),
|
|
751
755
|
});
|
|
@@ -1381,6 +1385,7 @@ export class VidNavigatorClient {
|
|
|
1381
1385
|
data: Record<string, unknown>;
|
|
1382
1386
|
file_info?: FileInfoJSON;
|
|
1383
1387
|
schema?: ExtractionSchema;
|
|
1388
|
+
evidence?: ExtractionEvidence;
|
|
1384
1389
|
usage?: UsageBlockJSON;
|
|
1385
1390
|
} & SceneNotes;
|
|
1386
1391
|
let body: ExtractFileBody;
|
|
@@ -1402,6 +1407,7 @@ export class VidNavigatorClient {
|
|
|
1402
1407
|
file_info: body.file_info ? FileInfo.fromJSON(body.file_info) : undefined,
|
|
1403
1408
|
...pickSceneNotes(body),
|
|
1404
1409
|
...(body.schema ? { schema: body.schema } : {}),
|
|
1410
|
+
...(body.evidence ? { evidence: body.evidence } : {}),
|
|
1405
1411
|
usage: body.usage ? UsageBlock.fromJSON(body.usage) : undefined,
|
|
1406
1412
|
};
|
|
1407
1413
|
}
|
package/src/models/AsyncJob.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtractionSchema } from './Extraction';
|
|
1
|
+
import type { ExtractionEvidence, ExtractionSchema } from './Extraction';
|
|
2
2
|
import { UsageBlock } from './Usage';
|
|
3
3
|
import { VideoInfo, VideoInfoJSON } from './VideoInfo';
|
|
4
4
|
import { ScenesError, WatchTranscriptError } from './Watch';
|
|
@@ -94,6 +94,8 @@ export interface AsyncJobJSON {
|
|
|
94
94
|
transcript_error?: WatchTranscriptError;
|
|
95
95
|
/** `extract_video` jobs, once completed, when the request had no schema: the schema written from `what_to_extract`. */
|
|
96
96
|
schema?: ExtractionSchema;
|
|
97
|
+
/** `extract_video` jobs, once completed: the moments each value of `result` comes from. */
|
|
98
|
+
evidence?: ExtractionEvidence;
|
|
97
99
|
error?: AsyncJobError | null;
|
|
98
100
|
}
|
|
99
101
|
|
|
@@ -126,6 +128,8 @@ export class AsyncJob<TResult> {
|
|
|
126
128
|
transcript_error?: WatchTranscriptError;
|
|
127
129
|
/** `extract_video` jobs, once completed, when the request had no schema: the schema written from `what_to_extract`, to pass as `schema` next time. */
|
|
128
130
|
schema?: ExtractionSchema;
|
|
131
|
+
/** `extract_video` jobs, once completed: the moments each value of `result` comes from. */
|
|
132
|
+
evidence?: ExtractionEvidence;
|
|
129
133
|
error: AsyncJobError | null;
|
|
130
134
|
/** Per-call usage, populated only when polled with `include_usage: true` and `task_status === 'completed'`. */
|
|
131
135
|
usage?: UsageBlock;
|
|
@@ -147,6 +151,7 @@ export class AsyncJob<TResult> {
|
|
|
147
151
|
this.scenes_error = data.scenes_error;
|
|
148
152
|
this.transcript_error = data.transcript_error;
|
|
149
153
|
this.schema = data.schema;
|
|
154
|
+
this.evidence = data.evidence;
|
|
150
155
|
this.error = data.error ?? null;
|
|
151
156
|
}
|
|
152
157
|
|
package/src/models/Extraction.ts
CHANGED
|
@@ -37,6 +37,20 @@ export interface ExtractionTokenUsageJSON {
|
|
|
37
37
|
total_tokens?: number;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* A moment an extracted value was taken from. `in` is `'speech'` (said in the video), `'picture'`
|
|
42
|
+
* (shown or written on screen) or `'post'` (the post's own text: title, channel, description;
|
|
43
|
+
* no `start`/`end` then).
|
|
44
|
+
*/
|
|
45
|
+
export interface FieldEvidence {
|
|
46
|
+
start?: number;
|
|
47
|
+
end?: number;
|
|
48
|
+
in: 'speech' | 'picture' | 'post';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** For each field of `data` that has a value, the moments of the video it comes from (at most 5). */
|
|
52
|
+
export type ExtractionEvidence = Record<string, FieldEvidence[]>;
|
|
53
|
+
|
|
40
54
|
export interface ExtractionResponseJSON {
|
|
41
55
|
status: 'success';
|
|
42
56
|
data: Record<string, unknown>;
|
|
@@ -48,6 +62,8 @@ export interface ExtractionResponseJSON {
|
|
|
48
62
|
transcript_error?: WatchTranscriptError;
|
|
49
63
|
/** When the request had no schema: the schema written from `what_to_extract`, to pass as `schema` next time. */
|
|
50
64
|
schema?: ExtractionSchema;
|
|
65
|
+
/** Where each value of `data` comes from. */
|
|
66
|
+
evidence?: ExtractionEvidence;
|
|
51
67
|
usage?: ExtractionTokenUsageJSON;
|
|
52
68
|
}
|
|
53
69
|
|
package/src/webhooks.ts
CHANGED
|
@@ -54,6 +54,8 @@ export interface WebhookEvent {
|
|
|
54
54
|
video_info?: Record<string, unknown>;
|
|
55
55
|
/** `extract_video.completed` only, when the request had no schema: the schema written from `what_to_extract`. */
|
|
56
56
|
schema?: Record<string, unknown>;
|
|
57
|
+
/** `extract_video.completed` only: the moments each value of `result` comes from. */
|
|
58
|
+
evidence?: Record<string, Array<{ start?: number; end?: number; in: 'speech' | 'picture' | 'post' }>>;
|
|
57
59
|
error?: AsyncJobError | null;
|
|
58
60
|
};
|
|
59
61
|
}
|