vidnavigator 2.4.0 → 2.5.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.
@@ -1,8 +1,9 @@
1
1
  import { UsageBlock } from './Usage';
2
2
  import { VideoInfo, VideoInfoJSON } from './VideoInfo';
3
+ import { ScenesError, WatchTranscriptError } from './Watch';
3
4
 
4
- /** Async job kinds returned by the `/transcribe/async`, `/watch/async`, `/extract/video/async` and `/tweet/statement/async` endpoints. */
5
- export type AsyncJobType = 'transcribe' | 'watch' | 'extract_video' | 'tweet_statement';
5
+ /** Async job kinds returned by the `/transcribe/async`, `/watch/async`, `/analyze/video/async`, `/extract/video/async` and `/tweet/statement/async` endpoints. */
6
+ export type AsyncJobType = 'transcribe' | 'watch' | 'analyze_video' | 'extract_video' | 'tweet_statement';
6
7
 
7
8
  /** `processing` = accepted and being worked on. `completed` and `failed` are terminal. */
8
9
  export type AsyncTaskStatus = 'processing' | 'completed' | 'failed';
@@ -86,6 +87,10 @@ export interface AsyncJobJSON {
86
87
  result?: any;
87
88
  /** `extract_video` jobs, once completed: the `video_info` the synchronous endpoint returns. */
88
89
  video_info?: VideoInfoJSON;
90
+ /** `extract_video` jobs, once completed with `include_scenes`: the `frames_analyzed` the synchronous endpoint returns. */
91
+ frames_analyzed?: number;
92
+ scenes_error?: ScenesError;
93
+ transcript_error?: WatchTranscriptError;
89
94
  error?: AsyncJobError | null;
90
95
  }
91
96
 
@@ -110,6 +115,12 @@ export class AsyncJob<TResult> {
110
115
  result: TResult | null;
111
116
  /** `extract_video` jobs, once completed: metadata of the video the data was extracted from. */
112
117
  video_info?: VideoInfo;
118
+ /** `extract_video` jobs, once completed with `include_scenes`: number of frames that were analyzed to produce the scenes. */
119
+ frames_analyzed?: number;
120
+ /** `extract_video` jobs with `include_scenes`: why the picture could not be read. The fields were then extracted from the transcript alone. */
121
+ scenes_error?: ScenesError;
122
+ /** `extract_video` jobs with `include_scenes`: why there is no transcript. The fields were then extracted from the scenes alone. */
123
+ transcript_error?: WatchTranscriptError;
113
124
  error: AsyncJobError | null;
114
125
  /** Per-call usage, populated only when polled with `include_usage: true` and `task_status === 'completed'`. */
115
126
  usage?: UsageBlock;
@@ -127,6 +138,9 @@ export class AsyncJob<TResult> {
127
138
  this.webhook = data.webhook;
128
139
  this.result = data.result !== undefined && data.result !== null ? parseResult(data.result) : null;
129
140
  this.video_info = data.video_info ? VideoInfo.fromJSON(data.video_info) : undefined;
141
+ this.frames_analyzed = data.frames_analyzed;
142
+ this.scenes_error = data.scenes_error;
143
+ this.transcript_error = data.transcript_error;
130
144
  this.error = data.error ?? null;
131
145
  }
132
146
 
@@ -1,52 +1,57 @@
1
- import { FileInfoJSON } from './FileInfo';
2
- import { VideoInfoJSON } from './VideoInfo';
3
-
4
- export type ExtractionFieldType =
5
- | 'String'
6
- | 'Number'
7
- | 'Boolean'
8
- | 'Integer'
9
- | 'Object'
10
- | 'Array'
11
- | 'Enum';
12
-
13
- export interface ExtractionField {
14
- type: ExtractionFieldType;
15
- description: string;
16
- properties?: Record<string, ExtractionField>;
17
- items?: ExtractionField;
18
- enum?: string[];
19
- }
20
-
21
- /** Custom schema: field name -> field definition */
22
- export type ExtractionSchema = Record<string, ExtractionField>;
23
-
24
- export interface ExtractionTokenUsageJSON {
25
- prompt_tokens?: number;
26
- completion_tokens?: number;
27
- total_tokens?: number;
28
- }
29
-
30
- export interface ExtractionResponseJSON {
31
- status: 'success';
32
- data: Record<string, unknown>;
33
- video_info?: VideoInfoJSON;
34
- file_info?: FileInfoJSON;
35
- usage?: ExtractionTokenUsageJSON;
36
- }
37
-
38
- export class ExtractionTokenUsage {
39
- prompt_tokens?: number;
40
- completion_tokens?: number;
41
- total_tokens?: number;
42
-
43
- constructor(data: ExtractionTokenUsageJSON) {
44
- this.prompt_tokens = data.prompt_tokens;
45
- this.completion_tokens = data.completion_tokens;
46
- this.total_tokens = data.total_tokens;
47
- }
48
-
49
- static fromJSON(json: ExtractionTokenUsageJSON): ExtractionTokenUsage {
50
- return new ExtractionTokenUsage(json);
51
- }
52
- }
1
+ import { FileInfoJSON } from './FileInfo';
2
+ import { VideoInfoJSON } from './VideoInfo';
3
+ import { ScenesError, WatchTranscriptError } from './Watch';
4
+
5
+ export type ExtractionFieldType =
6
+ | 'String'
7
+ | 'Number'
8
+ | 'Boolean'
9
+ | 'Integer'
10
+ | 'Object'
11
+ | 'Array'
12
+ | 'Enum';
13
+
14
+ export interface ExtractionField {
15
+ type: ExtractionFieldType;
16
+ description: string;
17
+ properties?: Record<string, ExtractionField>;
18
+ items?: ExtractionField;
19
+ enum?: string[];
20
+ }
21
+
22
+ /** Custom schema: field name -> field definition */
23
+ export type ExtractionSchema = Record<string, ExtractionField>;
24
+
25
+ export interface ExtractionTokenUsageJSON {
26
+ prompt_tokens?: number;
27
+ completion_tokens?: number;
28
+ total_tokens?: number;
29
+ }
30
+
31
+ export interface ExtractionResponseJSON {
32
+ status: 'success';
33
+ data: Record<string, unknown>;
34
+ video_info?: VideoInfoJSON;
35
+ file_info?: FileInfoJSON;
36
+ /** With `include_scenes`: number of frames that were analyzed to produce the scenes. */
37
+ frames_analyzed?: number;
38
+ scenes_error?: ScenesError;
39
+ transcript_error?: WatchTranscriptError;
40
+ usage?: ExtractionTokenUsageJSON;
41
+ }
42
+
43
+ export class ExtractionTokenUsage {
44
+ prompt_tokens?: number;
45
+ completion_tokens?: number;
46
+ total_tokens?: number;
47
+
48
+ constructor(data: ExtractionTokenUsageJSON) {
49
+ this.prompt_tokens = data.prompt_tokens;
50
+ this.completion_tokens = data.completion_tokens;
51
+ this.total_tokens = data.total_tokens;
52
+ }
53
+
54
+ static fromJSON(json: ExtractionTokenUsageJSON): ExtractionTokenUsage {
55
+ return new ExtractionTokenUsage(json);
56
+ }
57
+ }
@@ -1,7 +1,14 @@
1
1
  import { NamespaceRef, NamespaceRefJSON } from './Namespace';
2
+ import { ScenesError } from './Watch';
2
3
 
3
4
  export type FileStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled';
4
5
 
6
+ /**
7
+ * Where the scene analysis of a file stands. `none`: never asked for. `completed`: the scenes are
8
+ * returned by `getFile()`. `failed`: see `scenes_error`.
9
+ */
10
+ export type FileScenesStatus = 'none' | 'processing' | 'completed' | 'failed';
11
+
5
12
  export interface FileInfoJSON {
6
13
  id: string;
7
14
  name: string;
@@ -14,6 +21,9 @@ export interface FileInfoJSON {
14
21
  original_file_date?: string;
15
22
  has_transcript?: boolean;
16
23
  error_message?: string;
24
+ scenes_status?: FileScenesStatus;
25
+ frames_analyzed?: number;
26
+ scenes_error?: ScenesError;
17
27
  namespace_ids?: string[];
18
28
  namespaces?: NamespaceRefJSON[];
19
29
  }
@@ -33,6 +43,12 @@ export class FileInfo {
33
43
  original_file_date?: string;
34
44
  has_transcript?: boolean;
35
45
  error_message?: string;
46
+ /** Where the scene analysis of the file stands. */
47
+ scenes_status?: FileScenesStatus;
48
+ /** Number of frames that were analyzed to produce the scenes. Present when `scenes_status` is `completed`. */
49
+ frames_analyzed?: number;
50
+ /** Present when `scenes_status` is `failed`. `frames_not_available` means the file has no picture (an audio file). */
51
+ scenes_error?: ScenesError;
36
52
  namespace_ids?: string[];
37
53
  namespaces?: NamespaceRef[];
38
54
 
@@ -48,6 +64,9 @@ export class FileInfo {
48
64
  this.original_file_date = data.original_file_date;
49
65
  this.has_transcript = data.has_transcript;
50
66
  this.error_message = data.error_message;
67
+ this.scenes_status = data.scenes_status;
68
+ this.frames_analyzed = data.frames_analyzed;
69
+ this.scenes_error = data.scenes_error;
51
70
  this.namespace_ids = data.namespace_ids;
52
71
  this.namespaces = data.namespaces?.map(NamespaceRef.fromJSON);
53
72
  }
@@ -9,7 +9,7 @@ export interface VideoSceneJSON {
9
9
  on_screen_text?: string;
10
10
  }
11
11
 
12
- /** What a video shows between `start` and `end`. */
12
+ /** What a video, or an uploaded file, shows between `start` and `end`. */
13
13
  export class VideoScene {
14
14
  /** Start of the scene, in seconds from the beginning of the video. */
15
15
  start: number;
@@ -32,12 +32,18 @@ export class VideoScene {
32
32
  }
33
33
  }
34
34
 
35
- /** Why a watched video came back without a transcript (e.g. `transcript_not_available`). */
35
+ /** Why a video or a file came back without a transcript (e.g. `transcript_not_available`). */
36
36
  export interface WatchTranscriptError {
37
37
  error?: string;
38
38
  message?: string;
39
39
  }
40
40
 
41
+ /** Why the scenes of a video or a file could not be had (e.g. `frames_not_available`). */
42
+ export interface ScenesError {
43
+ error?: string;
44
+ message?: string;
45
+ }
46
+
41
47
  export interface WatchResultJSON {
42
48
  video_info: VideoInfoJSON;
43
49
  transcript?: TranscriptOutputJSON;
package/src/webhooks.ts CHANGED
@@ -8,6 +8,8 @@ export type WebhookEventType =
8
8
  | 'transcribe.failed'
9
9
  | 'watch.completed'
10
10
  | 'watch.failed'
11
+ | 'analyze_video.completed'
12
+ | 'analyze_video.failed'
11
13
  | 'extract_video.completed'
12
14
  | 'extract_video.failed'
13
15
  | 'tweet_statement.completed'
@@ -40,8 +42,8 @@ export interface WebhookEvent {
40
42
  job_type?: string;
41
43
  check_status_url?: string;
42
44
  /**
43
- * Raw (unparsed) result of the completed job. For transcription, watch, extraction and tweet jobs
44
- * it is the same data the job's `result()` parses. For TikTok tasks it is a summary only,
45
+ * Raw (unparsed) result of the completed job. For transcription, watch, analysis, extraction and tweet
46
+ * jobs it is the same data the job's `result()` parses. For TikTok tasks it is a summary only,
45
47
  * {@link TikTokWebhookResult} (a scrape can hold thousands of videos); fetch the videos with
46
48
  * `vn.tiktokProfile.resume(task_id).result()`. Omitted when `result_truncated` is true.
47
49
  */