vidnavigator 2.7.0 → 3.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/README.md +97 -109
- package/dist/index.d.ts +17 -109
- package/dist/index.js +14 -54
- package/dist/models/AsyncJob.d.ts +2 -2
- package/dist/models/SearchResult.d.ts +13 -7
- package/dist/models/SearchResult.js +16 -6
- 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 +2 -2
- package/package.json +1 -1
- package/src/index.ts +26 -172
- package/src/models/AsyncJob.ts +2 -2
- package/src/models/SearchResult.ts +31 -14
- package/src/models/TweetStatement.ts +10 -0
- package/src/models/index.ts +0 -1
- package/src/webhooks.ts +1 -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.1";
|
|
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. */
|
|
@@ -248,61 +238,6 @@ export type SearchFilesResult = {
|
|
|
248
238
|
explanation?: string;
|
|
249
239
|
usage?: UsageBlock;
|
|
250
240
|
};
|
|
251
|
-
export type AnalyzeVideoPayload = {
|
|
252
|
-
video_url: string;
|
|
253
|
-
query?: string;
|
|
254
|
-
/**
|
|
255
|
-
* Default false. `true` also reads what the video shows: the analysis is made from the
|
|
256
|
-
* transcript and the scenes together, and the result has `scenes` and `frames_analyzed`.
|
|
257
|
-
*/
|
|
258
|
-
include_scenes?: boolean;
|
|
259
|
-
transcript_text?: boolean;
|
|
260
|
-
include_usage?: boolean;
|
|
261
|
-
};
|
|
262
|
-
export type AnalyzeFilePayload = {
|
|
263
|
-
file_id: string;
|
|
264
|
-
query?: string;
|
|
265
|
-
/**
|
|
266
|
-
* Default false. `true` analyzes the file from its transcript and its scenes together. The
|
|
267
|
-
* scenes are the ones kept with the file: ask for them at the upload (`include_scenes`) or with
|
|
268
|
-
* {@link VidNavigatorClient.analyzeFileScenes}. A file that has none is refused with
|
|
269
|
-
* `ScenesNotAvailableError`.
|
|
270
|
-
*/
|
|
271
|
-
include_scenes?: boolean;
|
|
272
|
-
transcript_text?: boolean;
|
|
273
|
-
include_usage?: boolean;
|
|
274
|
-
};
|
|
275
|
-
export type AnalyzeVideoResult = {
|
|
276
|
-
video_info: VideoInfo;
|
|
277
|
-
transcript: TranscriptOutput;
|
|
278
|
-
transcript_analysis: AnalysisResult;
|
|
279
|
-
/**
|
|
280
|
-
* With `include_scenes: true`: what the video shows, in chronological order. Empty when the
|
|
281
|
-
* picture could not be read (see `scenes_error`).
|
|
282
|
-
*/
|
|
283
|
-
scenes?: VideoScene[];
|
|
284
|
-
/** With `include_scenes: true`: number of frames that were analyzed to produce the scenes. */
|
|
285
|
-
frames_analyzed?: number;
|
|
286
|
-
/** With `include_scenes: true`, when the picture could not be read: the analysis was made from the transcript alone. */
|
|
287
|
-
scenes_error?: ScenesError;
|
|
288
|
-
/** With `include_scenes: true`, when there is no transcript: the analysis was made from the scenes alone. */
|
|
289
|
-
transcript_error?: WatchTranscriptError;
|
|
290
|
-
usage?: UsageBlock;
|
|
291
|
-
};
|
|
292
|
-
export type AnalyzeFileResult = {
|
|
293
|
-
file_info: FileInfo;
|
|
294
|
-
transcript: TranscriptOutput;
|
|
295
|
-
transcript_analysis: AnalysisResult;
|
|
296
|
-
/** With `include_scenes: true`: what the file shows, in chronological order. */
|
|
297
|
-
scenes?: VideoScene[];
|
|
298
|
-
/** With `include_scenes: true`: number of frames that were analyzed to produce the scenes. */
|
|
299
|
-
frames_analyzed?: number;
|
|
300
|
-
/** 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. */
|
|
301
|
-
scenes_error?: ScenesError;
|
|
302
|
-
/** With `include_scenes: true`, when the file has no speech: the analysis was made from the scenes alone. */
|
|
303
|
-
transcript_error?: WatchTranscriptError;
|
|
304
|
-
usage?: UsageBlock;
|
|
305
|
-
};
|
|
306
241
|
export type ExtractVideoDataPayload = {
|
|
307
242
|
video_url: string;
|
|
308
243
|
/** A standard JSON Schema. Optional when `what_to_extract` is given. */
|
|
@@ -325,9 +260,8 @@ export type ExtractVideoDataMultipartPayload = {
|
|
|
325
260
|
include_scenes?: boolean;
|
|
326
261
|
include_usage?: boolean;
|
|
327
262
|
} & WebhookOption;
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
} & WebhookOption;
|
|
263
|
+
/** Payload of {@link VidNavigatorClient.getTweetStatement}: the same fields as {@link TweetStatementInput}. */
|
|
264
|
+
export type TweetStatementPayload = TweetStatementInput;
|
|
331
265
|
export type ExtractFileDataPayload = {
|
|
332
266
|
file_id: string;
|
|
333
267
|
/** A standard JSON Schema. Optional when `what_to_extract` is given. */
|
|
@@ -371,13 +305,6 @@ export declare class VidNavigatorClient {
|
|
|
371
305
|
* says why. Same shapes as {@link VidNavigatorClient.transcribe}.
|
|
372
306
|
*/
|
|
373
307
|
readonly watch: JobOperation<string | WatchInput, WatchAsyncJob, WatchResult>;
|
|
374
|
-
/**
|
|
375
|
-
* Analysis of an online video as a background job, built on `POST /analyze/video/async`: the
|
|
376
|
-
* same analysis and the same result as {@link VidNavigatorClient.analyzeVideo}, without holding
|
|
377
|
-
* a connection open while it runs. Use it with `include_scenes: true` on a video longer than
|
|
378
|
-
* about 10 minutes. Same shapes as {@link VidNavigatorClient.transcribe}.
|
|
379
|
-
*/
|
|
380
|
-
readonly analyze: JobOperation<string | AnalyzeVideoInput, AnalyzeVideoAsyncJob, AnalyzeVideoResult>;
|
|
381
308
|
/**
|
|
382
309
|
* Structured-data extraction from a video of any length, built on `POST /extract/video/async`.
|
|
383
310
|
* The schema is validated when you submit. With `include_scenes: true` the fields are extracted
|
|
@@ -387,7 +314,8 @@ export declare class VidNavigatorClient {
|
|
|
387
314
|
readonly extractVideo: JobOperation<ExtractVideoInput, ExtractVideoAsyncJob, ExtractDataResult>;
|
|
388
315
|
/**
|
|
389
316
|
* Structured claim analysis of an X/Twitter tweet (attached media of any length), built on
|
|
390
|
-
* `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}.
|
|
391
319
|
*/
|
|
392
320
|
readonly tweetStatement: JobOperation<string | TweetStatementInput, TweetStatementAsyncJob, TweetStatement>;
|
|
393
321
|
/**
|
|
@@ -519,7 +447,7 @@ export declare class VidNavigatorClient {
|
|
|
519
447
|
* The answer has `scenes_status` `processing` when the analysis was started or is already
|
|
520
448
|
* running, and `completed` when the scenes are already there (nothing new is started). Follow
|
|
521
449
|
* `file_info.scenes_status` with {@link VidNavigatorClient.getFile}, which returns the scenes
|
|
522
|
-
* once it is `completed`; `
|
|
450
|
+
* once it is `completed`; `extractFileData` reads them with `include_scenes: true`.
|
|
523
451
|
*
|
|
524
452
|
* An audio file has no picture: the call throws `BadRequestError` with `error_code`
|
|
525
453
|
* `frames_not_available`.
|
|
@@ -549,30 +477,11 @@ export declare class VidNavigatorClient {
|
|
|
549
477
|
namespace_ids: string[];
|
|
550
478
|
namespaces: NamespaceRef[];
|
|
551
479
|
}>;
|
|
552
|
-
/**
|
|
553
|
-
* Analyze an online video: a summary, the people, places and key subjects, and the answer to
|
|
554
|
-
* an optional `query`. With `include_scenes: true` the analysis is made from the transcript and
|
|
555
|
-
* from what the video shows, and the result also has `scenes` and `frames_analyzed`, as
|
|
556
|
-
* {@link VidNavigatorClient.watch} returns them. When the picture cannot be read, the analysis
|
|
557
|
-
* is made from the transcript alone and `scenes_error` says why; a video without a transcript
|
|
558
|
-
* is analyzed from its scenes, and `transcript_error` says why the transcript is missing.
|
|
559
|
-
*
|
|
560
|
-
* This call waits on one HTTP request. With `include_scenes` on a video longer than about
|
|
561
|
-
* 10 minutes, use {@link VidNavigatorClient.analyze}, which runs the same analysis as a
|
|
562
|
-
* background job.
|
|
563
|
-
*/
|
|
564
|
-
analyzeVideo(payload: AnalyzeVideoPayload): Promise<AnalyzeVideoResult>;
|
|
565
|
-
/**
|
|
566
|
-
* Analyze an uploaded file. With `include_scenes: true` the analysis is made from the transcript
|
|
567
|
-
* of the file and its scenes together, and the result also has `scenes` and `frames_analyzed`.
|
|
568
|
-
* The scenes are the ones kept with the file: ask for them at the upload (`include_scenes`) or
|
|
569
|
-
* with {@link VidNavigatorClient.analyzeFileScenes}. A file that has none is refused with
|
|
570
|
-
* `ScenesNotAvailableError` (HTTP 409), whose `scenes_status` says where their analysis stands.
|
|
571
|
-
*/
|
|
572
|
-
analyzeFile(payload: AnalyzeFilePayload): Promise<AnalyzeFileResult>;
|
|
573
480
|
/**
|
|
574
481
|
* Structured claim analysis of an X/Twitter tweet. Blocking convenience wrapper around
|
|
575
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`.
|
|
576
485
|
*/
|
|
577
486
|
getTweetStatement(payload: TweetStatementPayload, options?: RunOptions<TweetStatementAsyncJob>): Promise<TweetStatement>;
|
|
578
487
|
/**
|
|
@@ -601,9 +510,8 @@ export declare class VidNavigatorClient {
|
|
|
601
510
|
*/
|
|
602
511
|
searchYouTube(payload: SearchYouTubePayload): Promise<SearchYouTubeResult>;
|
|
603
512
|
/**
|
|
604
|
-
* @deprecated
|
|
605
|
-
*
|
|
606
|
-
* `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.
|
|
607
515
|
*/
|
|
608
516
|
searchVideos(payload: SearchYouTubePayload): Promise<SearchYouTubeResult>;
|
|
609
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.1';
|
|
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),
|
|
@@ -197,7 +187,7 @@ class VidNavigatorClient {
|
|
|
197
187
|
});
|
|
198
188
|
this.tweetStatement = this.defineOperation({
|
|
199
189
|
jobType: 'tweet_statement',
|
|
200
|
-
submit: (input) => this.submitAsyncJob('/tweet/statement/async',
|
|
190
|
+
submit: (input) => this.submitAsyncJob('/tweet/statement/async', tweetStatementBody(input)),
|
|
201
191
|
fetchTask: (task_id, options) => this.getAsyncJob(`/tweet/statement/${encodeURIComponent(task_id)}`, options, (raw) => models_1.TweetStatement.fromJSON(raw)),
|
|
202
192
|
toResult: async (task) => {
|
|
203
193
|
const statement = requireResult(task);
|
|
@@ -493,7 +483,7 @@ class VidNavigatorClient {
|
|
|
493
483
|
* The answer has `scenes_status` `processing` when the analysis was started or is already
|
|
494
484
|
* running, and `completed` when the scenes are already there (nothing new is started). Follow
|
|
495
485
|
* `file_info.scenes_status` with {@link VidNavigatorClient.getFile}, which returns the scenes
|
|
496
|
-
* once it is `completed`; `
|
|
486
|
+
* once it is `completed`; `extractFileData` reads them with `include_scenes: true`.
|
|
497
487
|
*
|
|
498
488
|
* An audio file has no picture: the call throws `BadRequestError` with `error_code`
|
|
499
489
|
* `frames_not_available`.
|
|
@@ -533,41 +523,12 @@ class VidNavigatorClient {
|
|
|
533
523
|
};
|
|
534
524
|
}
|
|
535
525
|
//endregion
|
|
536
|
-
//region ---
|
|
537
|
-
/**
|
|
538
|
-
* Analyze an online video: a summary, the people, places and key subjects, and the answer to
|
|
539
|
-
* an optional `query`. With `include_scenes: true` the analysis is made from the transcript and
|
|
540
|
-
* from what the video shows, and the result also has `scenes` and `frames_analyzed`, as
|
|
541
|
-
* {@link VidNavigatorClient.watch} returns them. When the picture cannot be read, the analysis
|
|
542
|
-
* is made from the transcript alone and `scenes_error` says why; a video without a transcript
|
|
543
|
-
* is analyzed from its scenes, and `transcript_error` says why the transcript is missing.
|
|
544
|
-
*
|
|
545
|
-
* This call waits on one HTTP request. With `include_scenes` on a video longer than about
|
|
546
|
-
* 10 minutes, use {@link VidNavigatorClient.analyze}, which runs the same analysis as a
|
|
547
|
-
* background job.
|
|
548
|
-
*/
|
|
549
|
-
async analyzeVideo(payload) {
|
|
550
|
-
const response = await this.request('POST', '/analyze/video', payload);
|
|
551
|
-
return parseAnalyzeVideoData(response.data, response.usage ? models_1.UsageBlock.fromJSON(response.usage) : undefined);
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* Analyze an uploaded file. With `include_scenes: true` the analysis is made from the transcript
|
|
555
|
-
* of the file and its scenes together, and the result also has `scenes` and `frames_analyzed`.
|
|
556
|
-
* The scenes are the ones kept with the file: ask for them at the upload (`include_scenes`) or
|
|
557
|
-
* with {@link VidNavigatorClient.analyzeFileScenes}. A file that has none is refused with
|
|
558
|
-
* `ScenesNotAvailableError` (HTTP 409), whose `scenes_status` says where their analysis stands.
|
|
559
|
-
*/
|
|
560
|
-
async analyzeFile(payload) {
|
|
561
|
-
const response = await this.request('POST', '/analyze/file', payload);
|
|
562
|
-
return {
|
|
563
|
-
file_info: models_1.FileInfo.fromJSON(response.data.file_info),
|
|
564
|
-
...parseAnalysisData(response.data),
|
|
565
|
-
usage: response.usage ? models_1.UsageBlock.fromJSON(response.usage) : undefined,
|
|
566
|
-
};
|
|
567
|
-
}
|
|
526
|
+
//region --- X posts ---
|
|
568
527
|
/**
|
|
569
528
|
* Structured claim analysis of an X/Twitter tweet. Blocking convenience wrapper around
|
|
570
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`.
|
|
571
532
|
*/
|
|
572
533
|
async getTweetStatement(payload, options) {
|
|
573
534
|
return this.tweetStatement(payload, options);
|
|
@@ -651,9 +612,8 @@ class VidNavigatorClient {
|
|
|
651
612
|
};
|
|
652
613
|
}
|
|
653
614
|
/**
|
|
654
|
-
* @deprecated
|
|
655
|
-
*
|
|
656
|
-
* `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.
|
|
657
617
|
*/
|
|
658
618
|
async searchVideos(payload) {
|
|
659
619
|
warnDeprecated('searchVideos', 'searchYouTube');
|
|
@@ -2,8 +2,8 @@ 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
|
/**
|
|
@@ -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. */
|
|
4
|
+
export interface NamedEntity {
|
|
5
|
+
name?: string;
|
|
6
|
+
context?: string;
|
|
7
|
+
}
|
|
4
8
|
export interface SearchKeySubject {
|
|
5
9
|
name?: string;
|
|
6
10
|
description?: string;
|
|
@@ -10,18 +14,20 @@ export interface BaseSearchResult {
|
|
|
10
14
|
transcript_summary?: string;
|
|
11
15
|
}
|
|
12
16
|
export interface VideoSearchResultJSON extends VideoInfoJSON, BaseSearchResult {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
/** Names, as the API sends them. */
|
|
18
|
+
people?: Array<string | NamedEntity>;
|
|
19
|
+
places?: Array<string | NamedEntity>;
|
|
20
|
+
key_subjects?: Array<string | SearchKeySubject>;
|
|
16
21
|
timestamp?: number;
|
|
17
22
|
relevant_text?: string;
|
|
18
23
|
query_relevance?: string;
|
|
19
24
|
}
|
|
20
25
|
export interface FileSearchResultJSON extends FileInfoJSON, BaseSearchResult {
|
|
21
26
|
file_url?: string;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
/** Names, as the API sends them. */
|
|
28
|
+
people?: Array<string | NamedEntity>;
|
|
29
|
+
places?: Array<string | NamedEntity>;
|
|
30
|
+
key_subjects?: Array<string | SearchKeySubject>;
|
|
25
31
|
timestamps?: number[];
|
|
26
32
|
relevant_text?: string;
|
|
27
33
|
query_answer?: string;
|
|
@@ -3,6 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FileSearchResult = exports.VideoSearchResult = void 0;
|
|
4
4
|
const FileInfo_1 = require("./FileInfo");
|
|
5
5
|
const VideoInfo_1 = require("./VideoInfo");
|
|
6
|
+
/**
|
|
7
|
+
* The API sends `people`, `places` and `key_subjects` as lists of names
|
|
8
|
+
* (`["Sam Altman"]`). Each name is turned into `{ name }`, so `.name` reads the
|
|
9
|
+
* same whatever the API sent; an entry that is already an object is kept.
|
|
10
|
+
*/
|
|
11
|
+
function toNamed(values) {
|
|
12
|
+
if (!Array.isArray(values))
|
|
13
|
+
return undefined;
|
|
14
|
+
return values.map((value) => (typeof value === 'string' ? { name: value } : value));
|
|
15
|
+
}
|
|
6
16
|
/**
|
|
7
17
|
* Represents a single video result from a search query.
|
|
8
18
|
*/
|
|
@@ -11,9 +21,9 @@ class VideoSearchResult extends VideoInfo_1.VideoInfo {
|
|
|
11
21
|
super(data);
|
|
12
22
|
this.relevance_score = data.relevance_score;
|
|
13
23
|
this.transcript_summary = data.transcript_summary;
|
|
14
|
-
this.people = data.people;
|
|
15
|
-
this.places = data.places;
|
|
16
|
-
this.key_subjects = data.key_subjects;
|
|
24
|
+
this.people = toNamed(data.people);
|
|
25
|
+
this.places = toNamed(data.places);
|
|
26
|
+
this.key_subjects = toNamed(data.key_subjects);
|
|
17
27
|
this.timestamp = data.timestamp;
|
|
18
28
|
this.relevant_text = data.relevant_text;
|
|
19
29
|
this.query_relevance = data.query_relevance;
|
|
@@ -32,9 +42,9 @@ class FileSearchResult extends FileInfo_1.FileInfo {
|
|
|
32
42
|
this.relevance_score = data.relevance_score;
|
|
33
43
|
this.transcript_summary = data.transcript_summary;
|
|
34
44
|
this.file_url = data.file_url;
|
|
35
|
-
this.people = data.people;
|
|
36
|
-
this.places = data.places;
|
|
37
|
-
this.key_subjects = data.key_subjects;
|
|
45
|
+
this.people = toNamed(data.people);
|
|
46
|
+
this.places = toNamed(data.places);
|
|
47
|
+
this.key_subjects = toNamed(data.key_subjects);
|
|
38
48
|
this.timestamps = data.timestamps;
|
|
39
49
|
this.relevant_text = data.relevant_text;
|
|
40
50
|
this.query_answer = data.query_answer;
|
|
@@ -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.
|