vidnavigator 2.6.0 → 3.0.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 +105 -111
- package/dist/index.d.ts +19 -109
- package/dist/index.js +16 -54
- package/dist/models/AsyncJob.d.ts +7 -3
- package/dist/models/AsyncJob.js +1 -0
- package/dist/models/Extraction.d.ts +14 -0
- package/dist/models/SearchResult.d.ts +5 -1
- package/dist/models/TweetStatement.d.ts +10 -0
- package/dist/models/index.d.ts +0 -1
- package/dist/models/index.js +0 -1
- package/dist/webhooks.d.ts +8 -2
- package/package.json +1 -1
- package/src/index.ts +32 -172
- package/src/models/AsyncJob.ts +8 -3
- package/src/models/Extraction.ts +16 -0
- package/src/models/SearchResult.ts +6 -1
- package/src/models/TweetStatement.ts +10 -0
- package/src/models/index.ts +0 -1
- package/src/webhooks.ts +3 -3
- package/src/models/AnalysisResult.ts +0 -51
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { VideoInfo, TranscriptOutput, FileInfo,
|
|
2
|
+
import { VideoInfo, TranscriptOutput, FileInfo, 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 = "
|
|
10
|
+
export declare const SDK_VERSION = "3.0.0";
|
|
11
11
|
export interface SDKConfig {
|
|
12
12
|
apiKey: string;
|
|
13
13
|
baseURL?: string;
|
|
@@ -62,19 +62,6 @@ export type WatchInput = {
|
|
|
62
62
|
export type WatchVideoPayload = WatchInput & {
|
|
63
63
|
include_usage?: boolean;
|
|
64
64
|
};
|
|
65
|
-
/** Input for {@link VidNavigatorClient.analyze}. A plain string is treated as `video_url`. */
|
|
66
|
-
export type AnalyzeVideoInput = {
|
|
67
|
-
video_url: string;
|
|
68
|
-
/** Optional question about the video. */
|
|
69
|
-
query?: string;
|
|
70
|
-
/**
|
|
71
|
-
* Default false. `true` also reads what the video shows: the analysis is made from the
|
|
72
|
-
* transcript and the scenes together, and the result has `scenes` and `frames_analyzed`.
|
|
73
|
-
*/
|
|
74
|
-
include_scenes?: boolean;
|
|
75
|
-
/** Return the transcript as a single string instead of segments. */
|
|
76
|
-
transcript_text?: boolean;
|
|
77
|
-
} & WebhookOption;
|
|
78
65
|
/**
|
|
79
66
|
* Input for {@link VidNavigatorClient.extractVideo}: a JSON Schema `schema`, or a JSON/YAML
|
|
80
67
|
* `schemaFilePath`, or neither with `what_to_extract`: the schema is then written from that text
|
|
@@ -104,6 +91,12 @@ export type ExtractVideoInput = ({
|
|
|
104
91
|
/** Input for {@link VidNavigatorClient.tweetStatement}. A plain string is treated as `tweet_id`. */
|
|
105
92
|
export type TweetStatementInput = {
|
|
106
93
|
tweet_id: string;
|
|
94
|
+
/**
|
|
95
|
+
* Default false. `true` also reads what the post's video and the quoted post's video show (their
|
|
96
|
+
* scenes, with the text readable on screen) and uses it with their transcripts. The result then
|
|
97
|
+
* has `frames_analyzed`, and `scenes_error` when a video's picture could not be read.
|
|
98
|
+
*/
|
|
99
|
+
include_scenes?: boolean;
|
|
107
100
|
} & WebhookOption;
|
|
108
101
|
export type TranscriptResult = {
|
|
109
102
|
video_info: VideoInfo;
|
|
@@ -125,8 +118,6 @@ export type TranscribeVideoResult = TranscribeVideoSingleResult | TranscribeVide
|
|
|
125
118
|
export type TranscribeAsyncJob = AsyncJob<TranscribeVideoResult>;
|
|
126
119
|
/** Snapshot of a watch task. `result` is a {@link WatchResult}. */
|
|
127
120
|
export type WatchAsyncJob = AsyncJob<WatchResult>;
|
|
128
|
-
/** Snapshot of a video analysis task. `result` has the same shape as {@link VidNavigatorClient.analyzeVideo}'s return value. */
|
|
129
|
-
export type AnalyzeVideoAsyncJob = AsyncJob<AnalyzeVideoResult>;
|
|
130
121
|
/** Snapshot of an extraction task. `result` is the extracted object, shaped like your schema. */
|
|
131
122
|
export type ExtractVideoAsyncJob = AsyncJob<Record<string, unknown>>;
|
|
132
123
|
/** Snapshot of a tweet claim analysis task. `result` is a {@link TweetStatement}. */
|
|
@@ -147,7 +138,6 @@ export interface TranscribeOperation extends JobOperation<string | TranscribeInp
|
|
|
147
138
|
submit(input: string | TranscribeInput, options?: SubmitOptions): Promise<Job<TranscribeAsyncJob, TranscribeVideoResult>>;
|
|
148
139
|
}
|
|
149
140
|
export type WatchJob = Job<WatchAsyncJob, WatchResult>;
|
|
150
|
-
export type AnalyzeVideoJob = Job<AnalyzeVideoAsyncJob, AnalyzeVideoResult>;
|
|
151
141
|
export type ExtractVideoJob = Job<ExtractVideoAsyncJob, ExtractDataResult>;
|
|
152
142
|
export type TweetStatementJob = Job<TweetStatementAsyncJob, TweetStatement>;
|
|
153
143
|
/** `result()` resolves to the completed task with **all** pages of `videos` collected. */
|
|
@@ -193,6 +183,8 @@ export interface ExtractDataResult {
|
|
|
193
183
|
data: Record<string, unknown>;
|
|
194
184
|
/** When the request had no schema: the schema written from `what_to_extract`, to pass as `schema` next time. */
|
|
195
185
|
schema?: ExtractionSchema;
|
|
186
|
+
/** For each field of `data` that has a value, the moments of the video it comes from. */
|
|
187
|
+
evidence?: ExtractionEvidence;
|
|
196
188
|
video_info?: VideoInfo;
|
|
197
189
|
file_info?: FileInfo;
|
|
198
190
|
/** With `include_scenes: true`: number of frames that were analyzed to produce the scenes. */
|
|
@@ -246,61 +238,6 @@ export type SearchFilesResult = {
|
|
|
246
238
|
explanation?: string;
|
|
247
239
|
usage?: UsageBlock;
|
|
248
240
|
};
|
|
249
|
-
export type AnalyzeVideoPayload = {
|
|
250
|
-
video_url: string;
|
|
251
|
-
query?: string;
|
|
252
|
-
/**
|
|
253
|
-
* Default false. `true` also reads what the video shows: the analysis is made from the
|
|
254
|
-
* transcript and the scenes together, and the result has `scenes` and `frames_analyzed`.
|
|
255
|
-
*/
|
|
256
|
-
include_scenes?: boolean;
|
|
257
|
-
transcript_text?: boolean;
|
|
258
|
-
include_usage?: boolean;
|
|
259
|
-
};
|
|
260
|
-
export type AnalyzeFilePayload = {
|
|
261
|
-
file_id: string;
|
|
262
|
-
query?: string;
|
|
263
|
-
/**
|
|
264
|
-
* Default false. `true` analyzes the file from its transcript and its scenes together. The
|
|
265
|
-
* scenes are the ones kept with the file: ask for them at the upload (`include_scenes`) or with
|
|
266
|
-
* {@link VidNavigatorClient.analyzeFileScenes}. A file that has none is refused with
|
|
267
|
-
* `ScenesNotAvailableError`.
|
|
268
|
-
*/
|
|
269
|
-
include_scenes?: boolean;
|
|
270
|
-
transcript_text?: boolean;
|
|
271
|
-
include_usage?: boolean;
|
|
272
|
-
};
|
|
273
|
-
export type AnalyzeVideoResult = {
|
|
274
|
-
video_info: VideoInfo;
|
|
275
|
-
transcript: TranscriptOutput;
|
|
276
|
-
transcript_analysis: AnalysisResult;
|
|
277
|
-
/**
|
|
278
|
-
* With `include_scenes: true`: what the video shows, in chronological order. Empty when the
|
|
279
|
-
* picture could not be read (see `scenes_error`).
|
|
280
|
-
*/
|
|
281
|
-
scenes?: VideoScene[];
|
|
282
|
-
/** With `include_scenes: true`: number of frames that were analyzed to produce the scenes. */
|
|
283
|
-
frames_analyzed?: number;
|
|
284
|
-
/** With `include_scenes: true`, when the picture could not be read: the analysis was made from the transcript alone. */
|
|
285
|
-
scenes_error?: ScenesError;
|
|
286
|
-
/** With `include_scenes: true`, when there is no transcript: the analysis was made from the scenes alone. */
|
|
287
|
-
transcript_error?: WatchTranscriptError;
|
|
288
|
-
usage?: UsageBlock;
|
|
289
|
-
};
|
|
290
|
-
export type AnalyzeFileResult = {
|
|
291
|
-
file_info: FileInfo;
|
|
292
|
-
transcript: TranscriptOutput;
|
|
293
|
-
transcript_analysis: AnalysisResult;
|
|
294
|
-
/** With `include_scenes: true`: what the file shows, in chronological order. */
|
|
295
|
-
scenes?: VideoScene[];
|
|
296
|
-
/** With `include_scenes: true`: number of frames that were analyzed to produce the scenes. */
|
|
297
|
-
frames_analyzed?: number;
|
|
298
|
-
/** Why the scenes could not be read, when the answer carries it. A file that has no scenes at all is refused with `ScenesNotAvailableError` instead. */
|
|
299
|
-
scenes_error?: ScenesError;
|
|
300
|
-
/** With `include_scenes: true`, when the file has no speech: the analysis was made from the scenes alone. */
|
|
301
|
-
transcript_error?: WatchTranscriptError;
|
|
302
|
-
usage?: UsageBlock;
|
|
303
|
-
};
|
|
304
241
|
export type ExtractVideoDataPayload = {
|
|
305
242
|
video_url: string;
|
|
306
243
|
/** A standard JSON Schema. Optional when `what_to_extract` is given. */
|
|
@@ -323,9 +260,8 @@ export type ExtractVideoDataMultipartPayload = {
|
|
|
323
260
|
include_scenes?: boolean;
|
|
324
261
|
include_usage?: boolean;
|
|
325
262
|
} & WebhookOption;
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
} & WebhookOption;
|
|
263
|
+
/** Payload of {@link VidNavigatorClient.getTweetStatement}: the same fields as {@link TweetStatementInput}. */
|
|
264
|
+
export type TweetStatementPayload = TweetStatementInput;
|
|
329
265
|
export type ExtractFileDataPayload = {
|
|
330
266
|
file_id: string;
|
|
331
267
|
/** A standard JSON Schema. Optional when `what_to_extract` is given. */
|
|
@@ -369,13 +305,6 @@ export declare class VidNavigatorClient {
|
|
|
369
305
|
* says why. Same shapes as {@link VidNavigatorClient.transcribe}.
|
|
370
306
|
*/
|
|
371
307
|
readonly watch: JobOperation<string | WatchInput, WatchAsyncJob, WatchResult>;
|
|
372
|
-
/**
|
|
373
|
-
* Analysis of an online video as a background job, built on `POST /analyze/video/async`: the
|
|
374
|
-
* same analysis and the same result as {@link VidNavigatorClient.analyzeVideo}, without holding
|
|
375
|
-
* a connection open while it runs. Use it with `include_scenes: true` on a video longer than
|
|
376
|
-
* about 10 minutes. Same shapes as {@link VidNavigatorClient.transcribe}.
|
|
377
|
-
*/
|
|
378
|
-
readonly analyze: JobOperation<string | AnalyzeVideoInput, AnalyzeVideoAsyncJob, AnalyzeVideoResult>;
|
|
379
308
|
/**
|
|
380
309
|
* Structured-data extraction from a video of any length, built on `POST /extract/video/async`.
|
|
381
310
|
* The schema is validated when you submit. With `include_scenes: true` the fields are extracted
|
|
@@ -385,7 +314,8 @@ export declare class VidNavigatorClient {
|
|
|
385
314
|
readonly extractVideo: JobOperation<ExtractVideoInput, ExtractVideoAsyncJob, ExtractDataResult>;
|
|
386
315
|
/**
|
|
387
316
|
* Structured claim analysis of an X/Twitter tweet (attached media of any length), built on
|
|
388
|
-
* `POST /tweet/statement/async`.
|
|
317
|
+
* `POST /tweet/statement/async`. With `include_scenes: true`, what the post's video and the quoted
|
|
318
|
+
* post's video show is read as well. Same shapes as {@link VidNavigatorClient.transcribe}.
|
|
389
319
|
*/
|
|
390
320
|
readonly tweetStatement: JobOperation<string | TweetStatementInput, TweetStatementAsyncJob, TweetStatement>;
|
|
391
321
|
/**
|
|
@@ -517,7 +447,7 @@ export declare class VidNavigatorClient {
|
|
|
517
447
|
* The answer has `scenes_status` `processing` when the analysis was started or is already
|
|
518
448
|
* running, and `completed` when the scenes are already there (nothing new is started). Follow
|
|
519
449
|
* `file_info.scenes_status` with {@link VidNavigatorClient.getFile}, which returns the scenes
|
|
520
|
-
* once it is `completed`; `
|
|
450
|
+
* once it is `completed`; `extractFileData` reads them with `include_scenes: true`.
|
|
521
451
|
*
|
|
522
452
|
* An audio file has no picture: the call throws `BadRequestError` with `error_code`
|
|
523
453
|
* `frames_not_available`.
|
|
@@ -547,30 +477,11 @@ export declare class VidNavigatorClient {
|
|
|
547
477
|
namespace_ids: string[];
|
|
548
478
|
namespaces: NamespaceRef[];
|
|
549
479
|
}>;
|
|
550
|
-
/**
|
|
551
|
-
* Analyze an online video: a summary, the people, places and key subjects, and the answer to
|
|
552
|
-
* an optional `query`. With `include_scenes: true` the analysis is made from the transcript and
|
|
553
|
-
* from what the video shows, and the result also has `scenes` and `frames_analyzed`, as
|
|
554
|
-
* {@link VidNavigatorClient.watch} returns them. When the picture cannot be read, the analysis
|
|
555
|
-
* is made from the transcript alone and `scenes_error` says why; a video without a transcript
|
|
556
|
-
* is analyzed from its scenes, and `transcript_error` says why the transcript is missing.
|
|
557
|
-
*
|
|
558
|
-
* This call waits on one HTTP request. With `include_scenes` on a video longer than about
|
|
559
|
-
* 10 minutes, use {@link VidNavigatorClient.analyze}, which runs the same analysis as a
|
|
560
|
-
* background job.
|
|
561
|
-
*/
|
|
562
|
-
analyzeVideo(payload: AnalyzeVideoPayload): Promise<AnalyzeVideoResult>;
|
|
563
|
-
/**
|
|
564
|
-
* Analyze an uploaded file. With `include_scenes: true` the analysis is made from the transcript
|
|
565
|
-
* of the file and its scenes together, and the result also has `scenes` and `frames_analyzed`.
|
|
566
|
-
* The scenes are the ones kept with the file: ask for them at the upload (`include_scenes`) or
|
|
567
|
-
* with {@link VidNavigatorClient.analyzeFileScenes}. A file that has none is refused with
|
|
568
|
-
* `ScenesNotAvailableError` (HTTP 409), whose `scenes_status` says where their analysis stands.
|
|
569
|
-
*/
|
|
570
|
-
analyzeFile(payload: AnalyzeFilePayload): Promise<AnalyzeFileResult>;
|
|
571
480
|
/**
|
|
572
481
|
* Structured claim analysis of an X/Twitter tweet. Blocking convenience wrapper around
|
|
573
482
|
* {@link VidNavigatorClient.tweetStatement}: submits to `POST /tweet/statement/async` and polls.
|
|
483
|
+
* With `include_scenes: true`, what the post's video and the quoted post's video show is read
|
|
484
|
+
* as well, and the result has `frames_analyzed`.
|
|
574
485
|
*/
|
|
575
486
|
getTweetStatement(payload: TweetStatementPayload, options?: RunOptions<TweetStatementAsyncJob>): Promise<TweetStatement>;
|
|
576
487
|
/**
|
|
@@ -599,9 +510,8 @@ export declare class VidNavigatorClient {
|
|
|
599
510
|
*/
|
|
600
511
|
searchYouTube(payload: SearchYouTubePayload): Promise<SearchYouTubeResult>;
|
|
601
512
|
/**
|
|
602
|
-
* @deprecated
|
|
603
|
-
*
|
|
604
|
-
* `searchYouTube` and will be removed in a future release.
|
|
513
|
+
* @deprecated Use {@link VidNavigatorClient.searchYouTube} instead. This alias forwards to
|
|
514
|
+
* `searchYouTube` (`POST /youtube/search`) and will be removed in a future release.
|
|
605
515
|
*/
|
|
606
516
|
searchVideos(payload: SearchYouTubePayload): Promise<SearchYouTubeResult>;
|
|
607
517
|
searchFiles(payload: SearchFilesPayload): Promise<SearchFilesResult>;
|
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 = '
|
|
34
|
+
exports.SDK_VERSION = '3.0.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.
|
|
@@ -80,16 +80,12 @@ function pickSceneNotes(raw) {
|
|
|
80
80
|
function parseScenes(raw) {
|
|
81
81
|
return raw ? { scenes: raw.map((scene) => models_1.VideoScene.fromJSON(scene)) } : {};
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
function parseAnalyzeVideoData(raw, usage) {
|
|
92
|
-
return { video_info: models_1.VideoInfo.fromJSON(raw.video_info), ...parseAnalysisData(raw), usage };
|
|
83
|
+
/** The body of a tweet analysis. `include_scenes` is sent only when true: left out, the API default (false) applies. */
|
|
84
|
+
function tweetStatementBody(input) {
|
|
85
|
+
if (typeof input === 'string')
|
|
86
|
+
return { tweet_id: input };
|
|
87
|
+
const { include_scenes, ...rest } = input;
|
|
88
|
+
return include_scenes === true ? { ...rest, include_scenes: true } : rest;
|
|
93
89
|
}
|
|
94
90
|
function buildAsyncJobParams(options) {
|
|
95
91
|
// Like the TikTok pollers, the async job pollers take include_usage as a query string value.
|
|
@@ -176,12 +172,6 @@ class VidNavigatorClient {
|
|
|
176
172
|
return watched;
|
|
177
173
|
},
|
|
178
174
|
});
|
|
179
|
-
this.analyze = this.defineOperation({
|
|
180
|
-
jobType: 'analyze_video',
|
|
181
|
-
submit: (input) => this.submitAsyncJob('/analyze/video/async', typeof input === 'string' ? { video_url: input } : input),
|
|
182
|
-
fetchTask: (task_id, options) => this.getAsyncJob(`/analyze/video/${encodeURIComponent(task_id)}`, options, (raw) => parseAnalyzeVideoData(raw)),
|
|
183
|
-
toResult: async (task) => ({ ...requireResult(task), usage: task.usage }),
|
|
184
|
-
});
|
|
185
175
|
this.extractVideo = this.defineOperation({
|
|
186
176
|
jobType: 'extract_video',
|
|
187
177
|
submit: (input) => this.submitExtractVideo(input),
|
|
@@ -191,12 +181,13 @@ class VidNavigatorClient {
|
|
|
191
181
|
video_info: task.video_info,
|
|
192
182
|
...pickSceneNotes(task),
|
|
193
183
|
...(task.schema ? { schema: task.schema } : {}),
|
|
184
|
+
...(task.evidence ? { evidence: task.evidence } : {}),
|
|
194
185
|
usage: task.usage,
|
|
195
186
|
}),
|
|
196
187
|
});
|
|
197
188
|
this.tweetStatement = this.defineOperation({
|
|
198
189
|
jobType: 'tweet_statement',
|
|
199
|
-
submit: (input) => this.submitAsyncJob('/tweet/statement/async',
|
|
190
|
+
submit: (input) => this.submitAsyncJob('/tweet/statement/async', tweetStatementBody(input)),
|
|
200
191
|
fetchTask: (task_id, options) => this.getAsyncJob(`/tweet/statement/${encodeURIComponent(task_id)}`, options, (raw) => models_1.TweetStatement.fromJSON(raw)),
|
|
201
192
|
toResult: async (task) => {
|
|
202
193
|
const statement = requireResult(task);
|
|
@@ -492,7 +483,7 @@ class VidNavigatorClient {
|
|
|
492
483
|
* The answer has `scenes_status` `processing` when the analysis was started or is already
|
|
493
484
|
* running, and `completed` when the scenes are already there (nothing new is started). Follow
|
|
494
485
|
* `file_info.scenes_status` with {@link VidNavigatorClient.getFile}, which returns the scenes
|
|
495
|
-
* once it is `completed`; `
|
|
486
|
+
* once it is `completed`; `extractFileData` reads them with `include_scenes: true`.
|
|
496
487
|
*
|
|
497
488
|
* An audio file has no picture: the call throws `BadRequestError` with `error_code`
|
|
498
489
|
* `frames_not_available`.
|
|
@@ -532,41 +523,12 @@ class VidNavigatorClient {
|
|
|
532
523
|
};
|
|
533
524
|
}
|
|
534
525
|
//endregion
|
|
535
|
-
//region ---
|
|
536
|
-
/**
|
|
537
|
-
* Analyze an online video: a summary, the people, places and key subjects, and the answer to
|
|
538
|
-
* an optional `query`. With `include_scenes: true` the analysis is made from the transcript and
|
|
539
|
-
* from what the video shows, and the result also has `scenes` and `frames_analyzed`, as
|
|
540
|
-
* {@link VidNavigatorClient.watch} returns them. When the picture cannot be read, the analysis
|
|
541
|
-
* is made from the transcript alone and `scenes_error` says why; a video without a transcript
|
|
542
|
-
* is analyzed from its scenes, and `transcript_error` says why the transcript is missing.
|
|
543
|
-
*
|
|
544
|
-
* This call waits on one HTTP request. With `include_scenes` on a video longer than about
|
|
545
|
-
* 10 minutes, use {@link VidNavigatorClient.analyze}, which runs the same analysis as a
|
|
546
|
-
* background job.
|
|
547
|
-
*/
|
|
548
|
-
async analyzeVideo(payload) {
|
|
549
|
-
const response = await this.request('POST', '/analyze/video', payload);
|
|
550
|
-
return parseAnalyzeVideoData(response.data, response.usage ? models_1.UsageBlock.fromJSON(response.usage) : undefined);
|
|
551
|
-
}
|
|
552
|
-
/**
|
|
553
|
-
* Analyze an uploaded file. With `include_scenes: true` the analysis is made from the transcript
|
|
554
|
-
* of the file and its scenes together, and the result also has `scenes` and `frames_analyzed`.
|
|
555
|
-
* The scenes are the ones kept with the file: ask for them at the upload (`include_scenes`) or
|
|
556
|
-
* with {@link VidNavigatorClient.analyzeFileScenes}. A file that has none is refused with
|
|
557
|
-
* `ScenesNotAvailableError` (HTTP 409), whose `scenes_status` says where their analysis stands.
|
|
558
|
-
*/
|
|
559
|
-
async analyzeFile(payload) {
|
|
560
|
-
const response = await this.request('POST', '/analyze/file', payload);
|
|
561
|
-
return {
|
|
562
|
-
file_info: models_1.FileInfo.fromJSON(response.data.file_info),
|
|
563
|
-
...parseAnalysisData(response.data),
|
|
564
|
-
usage: response.usage ? models_1.UsageBlock.fromJSON(response.usage) : undefined,
|
|
565
|
-
};
|
|
566
|
-
}
|
|
526
|
+
//region --- X posts ---
|
|
567
527
|
/**
|
|
568
528
|
* Structured claim analysis of an X/Twitter tweet. Blocking convenience wrapper around
|
|
569
529
|
* {@link VidNavigatorClient.tweetStatement}: submits to `POST /tweet/statement/async` and polls.
|
|
530
|
+
* With `include_scenes: true`, what the post's video and the quoted post's video show is read
|
|
531
|
+
* as well, and the result has `frames_analyzed`.
|
|
570
532
|
*/
|
|
571
533
|
async getTweetStatement(payload, options) {
|
|
572
534
|
return this.tweetStatement(payload, options);
|
|
@@ -611,6 +573,7 @@ class VidNavigatorClient {
|
|
|
611
573
|
file_info: body.file_info ? models_1.FileInfo.fromJSON(body.file_info) : undefined,
|
|
612
574
|
...pickSceneNotes(body),
|
|
613
575
|
...(body.schema ? { schema: body.schema } : {}),
|
|
576
|
+
...(body.evidence ? { evidence: body.evidence } : {}),
|
|
614
577
|
usage: body.usage ? models_1.UsageBlock.fromJSON(body.usage) : undefined,
|
|
615
578
|
};
|
|
616
579
|
}
|
|
@@ -649,9 +612,8 @@ class VidNavigatorClient {
|
|
|
649
612
|
};
|
|
650
613
|
}
|
|
651
614
|
/**
|
|
652
|
-
* @deprecated
|
|
653
|
-
*
|
|
654
|
-
* `searchYouTube` and will be removed in a future release.
|
|
615
|
+
* @deprecated Use {@link VidNavigatorClient.searchYouTube} instead. This alias forwards to
|
|
616
|
+
* `searchYouTube` (`POST /youtube/search`) and will be removed in a future release.
|
|
655
617
|
*/
|
|
656
618
|
async searchVideos(payload) {
|
|
657
619
|
warnDeprecated('searchVideos', 'searchYouTube');
|
|
@@ -1,9 +1,9 @@
|
|
|
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';
|
|
5
|
-
/** Async job kinds returned by the `/transcribe/async`, `/watch/async`, `/
|
|
6
|
-
export type AsyncJobType = 'transcribe' | 'watch' | '
|
|
5
|
+
/** Async job kinds returned by the `/transcribe/async`, `/watch/async`, `/extract/video/async` and `/tweet/statement/async` endpoints. */
|
|
6
|
+
export type AsyncJobType = 'transcribe' | 'watch' | 'extract_video' | 'tweet_statement';
|
|
7
7
|
/** `processing` = accepted and being worked on. `completed` and `failed` are terminal. */
|
|
8
8
|
export type AsyncTaskStatus = 'processing' | 'completed' | 'failed';
|
|
9
9
|
/**
|
|
@@ -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 {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { NamedEntity } from './AnalysisResult';
|
|
2
1
|
import { FileInfo, FileInfoJSON } from './FileInfo';
|
|
3
2
|
import { VideoInfo, VideoInfoJSON } from './VideoInfo';
|
|
3
|
+
/** A person or a place a search result mentions, with the context it appears in. */
|
|
4
|
+
export interface NamedEntity {
|
|
5
|
+
name?: string;
|
|
6
|
+
context?: string;
|
|
7
|
+
}
|
|
4
8
|
export interface SearchKeySubject {
|
|
5
9
|
name?: string;
|
|
6
10
|
description?: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UsageBlock } from './Usage';
|
|
2
|
+
import { ScenesError } from './Watch';
|
|
2
3
|
export type TweetClaimType = 'factual_claim' | 'opinion' | 'question' | 'call_to_action' | 'satire' | 'news_sharing' | 'personal_experience';
|
|
3
4
|
export type TweetIntent = 'educate' | 'inform' | 'analyze' | 'persuade' | 'entertain' | 'inspire' | 'challenge';
|
|
4
5
|
export type TweetTone = 'serious' | 'humorous' | 'provocative' | 'neutral' | 'warm' | 'skeptical' | 'inspirational';
|
|
@@ -19,6 +20,8 @@ export interface TweetStatementJSON {
|
|
|
19
20
|
tweet_media_summary?: string | null;
|
|
20
21
|
quoted_tweet_text?: string | null;
|
|
21
22
|
quoted_media_summary?: string | null;
|
|
23
|
+
frames_analyzed?: number;
|
|
24
|
+
scenes_error?: ScenesError;
|
|
22
25
|
}
|
|
23
26
|
export declare class TweetStatement {
|
|
24
27
|
final_statement?: string;
|
|
@@ -36,6 +39,13 @@ export declare class TweetStatement {
|
|
|
36
39
|
tweet_media_summary?: string | null;
|
|
37
40
|
quoted_tweet_text?: string | null;
|
|
38
41
|
quoted_media_summary?: string | null;
|
|
42
|
+
/** With `include_scenes: true`: number of frames analyzed to read the scenes of the post's videos. */
|
|
43
|
+
frames_analyzed?: number;
|
|
44
|
+
/**
|
|
45
|
+
* With `include_scenes: true`, when a video's picture could not be read (e.g. `frames_not_available`).
|
|
46
|
+
* The analysis still succeeds: that video is used through its transcript alone, when it has one.
|
|
47
|
+
*/
|
|
48
|
+
scenes_error?: ScenesError;
|
|
39
49
|
/** Per-call usage, populated when requested with include_usage. */
|
|
40
50
|
usage?: UsageBlock;
|
|
41
51
|
constructor(data: TweetStatementJSON);
|
package/dist/models/index.d.ts
CHANGED
package/dist/models/index.js
CHANGED
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./AnalysisResult"), exports);
|
|
18
17
|
__exportStar(require("./AsyncJob"), exports);
|
|
19
18
|
__exportStar(require("./Carousel"), exports);
|
|
20
19
|
__exportStar(require("./CarouselVideoResult"), exports);
|
package/dist/webhooks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncJobError } from './models';
|
|
2
2
|
/** Event types delivered to a `webhook_url` when an async job reaches a terminal state. */
|
|
3
|
-
export type WebhookEventType = 'transcribe.completed' | 'transcribe.failed' | 'watch.completed' | 'watch.failed' | '
|
|
3
|
+
export type WebhookEventType = 'transcribe.completed' | 'transcribe.failed' | 'watch.completed' | 'watch.failed' | 'extract_video.completed' | 'extract_video.failed' | 'tweet_statement.completed' | 'tweet_statement.failed' | 'tiktok_profile.completed' | 'tiktok_profile.failed' | 'tiktok_search.completed' | 'tiktok_search.failed' | 'tiktok_live_search.completed' | 'tiktok_live_search.failed';
|
|
4
4
|
/** `data.result` of a `tiktok_profile.*` / `tiktok_search.*` / `tiktok_live_search.*` event: a summary, not the items. */
|
|
5
5
|
export interface TikTokWebhookResult {
|
|
6
6
|
/** Same fields as the task's `stats` (e.g. `videos_matched`, or `results_count` / `sort_by` for searches). */
|
|
@@ -21,7 +21,7 @@ export interface WebhookEvent {
|
|
|
21
21
|
job_type?: string;
|
|
22
22
|
check_status_url?: string;
|
|
23
23
|
/**
|
|
24
|
-
* Raw (unparsed) result of the completed job. For transcription, watch,
|
|
24
|
+
* Raw (unparsed) result of the completed job. For transcription, watch, extraction and tweet
|
|
25
25
|
* jobs it is the same data the job's `result()` parses. For TikTok tasks it is a summary only,
|
|
26
26
|
* {@link TikTokWebhookResult} (a scrape can hold thousands of videos); fetch the videos with
|
|
27
27
|
* `vn.tiktokProfile.resume(task_id).result()`. Omitted when `result_truncated` is true.
|
|
@@ -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
|
}
|