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.
package/README.md CHANGED
@@ -12,6 +12,7 @@ The official JavaScript/TypeScript SDK for the [VidNavigator Developer API](http
12
12
  - **Multi-platform transcription** — YouTube, Instagram Reels & carousel posts, TikTok, X/Twitter, Vimeo, Facebook, Dailymotion, Loom, Snapchat, and more.
13
13
  - **Any video length** — transcription, extraction, and tweet analysis run as background jobs, so there is no duration limit. Get the result with one `await`, or submit many jobs and collect them as they finish.
14
14
  - **Watch a video** — what it shows, scene by scene, with the text readable on screen, next to its transcript, in one result.
15
+ - **Scenes in analysis and extraction** — with `include_scenes`, an analysis or an extraction reads what the video shows as well as what it says, for online videos and for uploaded files.
15
16
  - **Async TikTok profile scraping, keyword search and LIVE search** — collect public TikTok videos, or LIVE rooms with their stream URLs, in the background, then read results via cursor pagination or a signed `download_url`, optionally notified by webhook.
16
17
  - **TikTok LIVE room** — check one room or streamer right away, with its latest comments, pinned comment and top viewers.
17
18
  - **Instagram carousel support** — select a specific video by index, or transcribe every video in a carousel post with one call.
@@ -37,9 +38,9 @@ The official JavaScript/TypeScript SDK for the [VidNavigator Developer API](http
37
38
  | Dailymotion | Yes | Yes | Yes | - |
38
39
  | Loom | Yes | Yes | Yes | - |
39
40
  | Snapchat | Yes, when Snapchat has a transcript | Yes | Yes | Yes (highlights: `img_index`, `all_videos`) |
40
- | Uploaded files | Yes | Yes | - | - |
41
+ | Uploaded files | Yes | Yes | Yes (`include_scenes` at upload, or `analyzeFileScenes()`) | - |
41
42
 
42
- > **Transcript** = fast caption/subtitle extraction. **Transcribe** = speech-to-text via AI models (works when captions are unavailable). **Watch** = what the video shows, scene by scene, next to its transcript, via `vn.watch()`.
43
+ > **Transcript** = fast caption/subtitle extraction. **Transcribe** = speech-to-text via AI models (works when captions are unavailable). **Watch** = what the video shows, scene by scene, next to its transcript, via `vn.watch()`. The same scenes can feed an analysis or an extraction with `include_scenes: true`.
43
44
 
44
45
  ## Installation
45
46
 
@@ -214,7 +215,7 @@ Errors worth handling: `NotFoundError` with `error_code` `'frames_not_available'
214
215
 
215
216
  ### 3. Background jobs: one call, or many at once
216
217
 
217
- Transcription, watch, structured extraction, tweet analysis, and TikTok scraping run as background jobs on VidNavigator. The SDK always uses the async API endpoints, so **video length is never a problem**. You never deal with the request-response limits of long transcriptions.
218
+ Transcription, watch, structured extraction, tweet analysis, and TikTok scraping run as background jobs on VidNavigator. The SDK always uses the async API endpoints, so **video length is never a problem**. You never deal with the request-response limits of long transcriptions. Video analysis has both: `analyzeVideo()` is a direct call, and `vn.analyze` runs the same analysis as a background job, for long videos with `include_scenes`.
218
219
 
219
220
  Each of these operations comes in two shapes:
220
221
 
@@ -222,6 +223,7 @@ Each of these operations comes in two shapes:
222
223
  |---|---|---|
223
224
  | Transcription | `await vn.transcribe(url)` | `await vn.transcribe.submit(url)` |
224
225
  | Watch (scenes and transcript) | `await vn.watch(url)` | `await vn.watch.submit(url)` |
226
+ | Video analysis | `await vn.analyze(url)` | `await vn.analyze.submit(url)` |
225
227
  | Structured extraction | `await vn.extractVideo({ video_url, schema })` | `await vn.extractVideo.submit({ ... })` |
226
228
  | Tweet claim analysis | `await vn.tweetStatement(tweetId)` | `await vn.tweetStatement.submit(tweetId)` |
227
229
  | TikTok profile scrape | `await vn.tiktokProfile(profileUrl)` | `await vn.tiktokProfile.submit(profileUrl)` |
@@ -371,7 +373,7 @@ function pending(): string[] {
371
373
 
372
374
  ### 4. Webhooks
373
375
 
374
- You can also have VidNavigator call your server when a job finishes. Pass `webhook_url` to any of the operations above (transcription, watch, extraction, tweet analysis, TikTok profile and search), or set an account-wide default in **Studio → API**. A per-job `webhook_url` overrides the default, and `webhook_url: ''` turns the default off for that one job. The URL must be a public `https` endpoint; private and loopback hosts are rejected with a `BadRequestError`.
376
+ You can also have VidNavigator call your server when a job finishes. Pass `webhook_url` to any of the operations above (transcription, watch, video analysis, extraction, tweet analysis, TikTok profile and search), or set an account-wide default in **Studio → API**. A per-job `webhook_url` overrides the default, and `webhook_url: ''` turns the default off for that one job. The URL must be a public `https` endpoint; private and loopback hosts are rejected with a `BadRequestError`.
375
377
 
376
378
  Webhooks are optional. Waiting with `result()` or the one-liners works exactly the same whether or not a webhook is set, and it remains the source of truth.
377
379
 
@@ -420,7 +422,7 @@ app.post('/hooks/vidnavigator', express.raw({ type: 'application/json' }), async
420
422
  });
421
423
  ```
422
424
 
423
- - `event.data.result` holds the raw result for transcription, watch, extraction, and tweet events, unless it was over 256 KB (`result_truncated: true`). For TikTok events it is only a summary, `{ stats, download_url_available }`, since a scrape can hold thousands of videos. In every case, `resume(task_id).result()` gets the full parsed result.
425
+ - `event.data.result` holds the raw result for transcription, watch, video analysis, extraction, and tweet events, unless it was over 256 KB (`result_truncated: true`). For TikTok events it is only a summary, `{ stats, download_url_available }`, since a scrape can hold thousands of videos. In every case, `resume(task_id).result()` gets the full parsed result.
424
426
  - `verifyWebhookSignature(rawBody, signatureHeader, secret)` returns `true` or `false` instead of throwing.
425
427
  - Deliveries older than 5 minutes are rejected by default. Change this with `{ toleranceSeconds }`; `0` turns the check off.
426
428
  - Failed deliveries (5xx, 429, network errors) are retried 5 times over about 13 minutes. Other 4xx responses are not retried.
@@ -662,6 +664,61 @@ const { files, has_more } = await vn.getFiles({ status: 'completed', limit: 20,
662
664
  await vn.deleteFile(file_id);
663
665
  ```
664
666
 
667
+ ### 8b. Scenes of an uploaded file
668
+
669
+ Pass `include_scenes: true` at the upload to have the picture of a video file analyzed as well: what it shows, scene by scene, with the text readable on screen, as `vn.watch()` does for an online video. The scenes of a file are analyzed once and kept with it. `file_info.scenes_status` says where that stands (`'none'`, `'processing'`, `'completed'` or `'failed'`), and `getFile()` returns the scenes once it is `'completed'`:
670
+
671
+ ```ts
672
+ const { file_id } = await vn.uploadFile({ filePath: './recipe.mp4', include_scenes: true });
673
+
674
+ let file = await vn.getFile(file_id);
675
+ while (file.file_info.status === 'processing' || file.file_info.scenes_status === 'processing') {
676
+ await new Promise((r) => setTimeout(r, 5000));
677
+ file = await vn.getFile(file_id);
678
+ }
679
+
680
+ console.log(file.file_info.scenes_status, file.file_info.frames_analyzed); // 'completed', and the number of frames analyzed
681
+ for (const scene of file.scenes ?? []) {
682
+ console.log(`[${scene.start}s - ${scene.end}s] ${scene.description}`);
683
+ if (scene.on_screen_text) console.log(` on screen: ${scene.on_screen_text}`);
684
+ }
685
+ ```
686
+
687
+ For a file that is already uploaded, start the same analysis with `analyzeFileScenes()`, then follow `scenes_status` in the same way:
688
+
689
+ ```ts
690
+ const { scenes_status } = await vn.analyzeFileScenes(file_id);
691
+ // 'processing': started, or already running. 'completed': the scenes are already there.
692
+ ```
693
+
694
+ `analyzeFile()` and `extractFileData()` then read the scenes with `include_scenes: true`. The analysis is made from the transcript of the file and its scenes together, and the result also has `scenes` and `frames_analyzed`:
695
+
696
+ ```ts
697
+ const { transcript_analysis, scenes, frames_analyzed } = await vn.analyzeFile({
698
+ file_id,
699
+ query: 'What are the ingredients and their quantities?',
700
+ include_scenes: true,
701
+ });
702
+ ```
703
+
704
+ A file that has no scenes to read is refused with `ScenesNotAvailableError` (HTTP 409). Its `scenes_status` says why: `'none'` (never asked for), `'processing'` (call again once `getFile()` reports `'completed'`) or `'failed'` (see `scenes_error`):
705
+
706
+ ```ts
707
+ import { ScenesNotAvailableError } from 'vidnavigator';
708
+
709
+ try {
710
+ await vn.analyzeFile({ file_id, include_scenes: true });
711
+ } catch (err) {
712
+ if (err instanceof ScenesNotAvailableError && err.scenes_status === 'none') {
713
+ await vn.analyzeFileScenes(file_id); // then wait for scenes_status 'completed' and call again
714
+ } else {
715
+ throw err;
716
+ }
717
+ }
718
+ ```
719
+
720
+ An audio file has no picture. `analyzeFileScenes()` throws `BadRequestError` with `error_code` `'frames_not_available'` for it, and an audio file uploaded with `include_scenes` gets `scenes_status` `'failed'` with the same code in `file_info.scenes_error`. A file without speech is analyzed from its scenes alone, and the result has a `transcript_error`.
721
+
665
722
  ### Analyze an online video
666
723
 
667
724
  ```ts
@@ -676,6 +733,37 @@ console.log(transcript_analysis.query_answer?.answer); // direct ans
676
733
  console.log(transcript_analysis.query_answer?.relevant_segments); // supporting transcript excerpts
677
734
  ```
678
735
 
736
+ Pass `include_scenes: true` to make the analysis from what the video **shows** as well as what it says. The result then also has `scenes` and `frames_analyzed`, as [`vn.watch()`](#2b-watch-a-video-scenes-next-to-the-transcript) returns them:
737
+
738
+ ```ts
739
+ const { transcript_analysis, scenes, frames_analyzed } = await vn.analyzeVideo({
740
+ video_url: 'https://www.tiktok.com/@user/video/1234567890',
741
+ query: 'What are the ingredients and their quantities?',
742
+ include_scenes: true,
743
+ });
744
+
745
+ console.log(transcript_analysis.query_answer?.answer); // also read from the text written on screen
746
+ console.log(`${scenes?.length} scenes from ${frames_analyzed} frames`);
747
+ ```
748
+
749
+ - When the picture cannot be read, the analysis is made from the transcript alone: `scenes` is empty and `scenes_error` says why. A video without a transcript is analyzed from its scenes, and `transcript_error` says why the transcript is missing.
750
+ - With scenes, the segments an answer refers to (`best_segment_index`, `relevant_segments`) are counted among the transcript segments and the scenes together, in chronological order. Use `transcript_analysis.timestamp` to locate the moment.
751
+ - With `include_usage: true`, the frames are the `frame_analysis` charge of the `usage` block: 1 credit per 1,000 frames analyzed, with at least 334 frames per hour of video; for an uploaded file the frames are charged once, when its scenes are analyzed.
752
+
753
+ `analyzeVideo()` waits on a single HTTP request. With `include_scenes` on a video longer than about 10 minutes, use `vn.analyze()`: it runs the same analysis as a [background job](#3-background-jobs-one-call-or-many-at-once) and returns the same result.
754
+
755
+ ```ts
756
+ const result = await vn.analyze(
757
+ { video_url: 'https://www.youtube.com/watch?v=4czjS9h4Fpg', query: 'Where did the rover land?', include_scenes: true },
758
+ { include_usage: true }
759
+ );
760
+ console.log(result.transcript_analysis.query_answer?.answer, result.scenes?.length);
761
+
762
+ // Or start it and come back later, as for any background job
763
+ const job = await vn.analyze.submit({ video_url: url, include_scenes: true });
764
+ const later = await vn.analyze.resume(job.task_id).result();
765
+ ```
766
+
679
767
  ### 9. Extract structured data
680
768
 
681
769
  Define a schema and get back clean, structured data extracted from any video or file transcript. Powered by LLMs with per-call usage tracking (see [Per-call usage](#per-call-usage)).
@@ -731,11 +819,28 @@ const { data } = await vn.extractVideoData({
731
819
  });
732
820
  ```
733
821
 
822
+ Pass `include_scenes: true` to extract from what the video shows as well as what it says: a value shown or written on screen counts as much as one that is said. The result then has `frames_analyzed`:
823
+
824
+ ```ts
825
+ const { data, frames_analyzed } = await vn.extractVideoData({
826
+ video_url: 'https://www.tiktok.com/@user/video/1234567890',
827
+ schema: {
828
+ dish: { type: 'String', description: 'Name of the dish' },
829
+ ingredients: { type: 'Array', description: 'Every ingredient with its quantity', items: { type: 'String', description: 'An ingredient and its quantity' } },
830
+ },
831
+ include_scenes: true,
832
+ });
833
+
834
+ console.log(data, frames_analyzed); // quantities that are only written on screen are found too
835
+ ```
836
+
837
+ When the picture cannot be read, the fields are extracted from the transcript alone and the result has a `scenes_error`; a video without a transcript is extracted from its scenes, with a `transcript_error`. The same option works on an uploaded file, `vn.extractFileData({ file_id, schema, include_scenes: true })`, once the file has its scenes (see [Scenes of an uploaded file](#8b-scenes-of-an-uploaded-file)).
838
+
734
839
  **Supported schema types:** `String`, `Number`, `Boolean`, `Integer`, `Object`, `Array`, `Enum`
735
840
 
736
841
  **Schema rules:** every field needs `type` and `description`. `Array` fields also need `items` (the schema of one element). `Object` fields list their sub-fields in `properties` (up to 10), and `Enum` fields list the allowed values in `enum`. At most 10 top-level fields and 3 levels of nesting. An invalid schema is rejected with a `BadRequestError` before anything runs.
737
842
 
738
- > `extractVideoData()` runs as a background job, so videos of any length work. For many extractions at once, use `vn.extractVideo.submit()` (see [Background jobs](#3-background-jobs-one-call-or-many-at-once)). The result has `data` (the extracted fields), `video_info` (the video's metadata), and `usage` when requested.
843
+ > `extractVideoData()` runs as a background job, so videos of any length work. For many extractions at once, use `vn.extractVideo.submit()` (see [Background jobs](#3-background-jobs-one-call-or-many-at-once)). The result has `data` (the extracted fields), `video_info` (the video's metadata), `frames_analyzed` with `include_scenes`, and `usage` when requested.
739
844
 
740
845
  ### 10. Semantic search
741
846
 
@@ -819,7 +924,7 @@ console.log(`Channels indexed: ${usage.channelsIndexed.used} / ${usage.channelsI
819
924
 
820
925
  ### Per-call usage
821
926
 
822
- Pass `include_usage: true` to most endpoints (`getTranscript`, `transcribeVideo`, `watchVideo`, `analyzeVideo`, `analyzeFile`, `extractVideoData`, `extractFileData`, `searchYouTube`, `searchFiles`) to receive a `usage` block describing exactly what the request cost. For background jobs, pass it in the options: `vn.transcribe(url, { include_usage: true })`, `vn.transcribe.submit(url, { include_usage: true })`, or `vn.transcribe.resume(taskId, { include_usage: true })`. The result's `usage` is filled in once the job completes. A failed job has all its charges reverted, so it has no usage.
927
+ Pass `include_usage: true` to most endpoints (`getTranscript`, `transcribeVideo`, `watchVideo`, `analyzeVideo`, `analyzeFile`, `extractVideoData`, `extractFileData`, `searchYouTube`, `searchFiles`) to receive a `usage` block describing exactly what the request cost. For background jobs (`vn.transcribe`, `vn.watch`, `vn.analyze`, ...), pass it in the options: `vn.transcribe(url, { include_usage: true })`, `vn.transcribe.submit(url, { include_usage: true })`, or `vn.transcribe.resume(taskId, { include_usage: true })`. The result's `usage` is filled in once the job completes. A failed job has all its charges reverted, so it has no usage.
823
928
 
824
929
  The `usage` field is a `UsageBlock`:
825
930
 
@@ -875,7 +980,7 @@ All methods return a `Promise`. Responses are automatically parsed into typed mo
875
980
 
876
981
  | Member | Description |
877
982
  |--------|-------------|
878
- | `vn.transcribe`, `vn.watch`, `vn.extractVideo`, `vn.tweetStatement`, `vn.tiktokProfile`, `vn.tiktokSearch`, `vn.tiktokLiveSearch` | Call directly to submit and wait for the result. Options: `include_usage`, `timeoutMs`, `intervalMs`, `fastStart`, `signal`, `onPoll` |
983
+ | `vn.transcribe`, `vn.watch`, `vn.analyze`, `vn.extractVideo`, `vn.tweetStatement`, `vn.tiktokProfile`, `vn.tiktokSearch`, `vn.tiktokLiveSearch` | Call directly to submit and wait for the result. Options: `include_usage`, `timeoutMs`, `intervalMs`, `fastStart`, `signal`, `onPoll` |
879
984
  | `.submit(input, { include_usage? })` | Start the job and return a `Job` immediately |
880
985
  | `.resume(task_id, { include_usage? })` | Get a `Job` for a job you already started (no request is made) |
881
986
  | `job.task_id`, `job.job_type`, `job.check_status_url`, `job.webhook_url` | Job details from the submit response |
@@ -884,7 +989,7 @@ All methods return a `Promise`. Responses are automatically parsed into typed mo
884
989
  | `job.result(options?)` | Wait until finished and return the result. Throws on failure or timeout; every error carries `task_id` |
885
990
  | `job.wait(options?)` | Wait until finished and return the final task, without throwing on failure |
886
991
 
887
- Results: `transcribe` → same shape as `transcribeVideo()`; `watch` → `WatchResult` (`video_info`, `transcript`, `scenes`, `frames_analyzed`, `usage?`); `extractVideo` → `{ data, video_info, usage? }`; `tweetStatement` → `TweetStatement`; `tiktokProfile` / `tiktokSearch` / `tiktokLiveSearch` → the completed task with every page of `videos` / `results`.
992
+ Results: `transcribe` → same shape as `transcribeVideo()`; `watch` → `WatchResult` (`video_info`, `transcript`, `scenes`, `frames_analyzed`, `usage?`); `analyze` → same shape as `analyzeVideo()`; `extractVideo` → `{ data, video_info, frames_analyzed?, usage? }`; `tweetStatement` → `TweetStatement`; `tiktokProfile` / `tiktokSearch` / `tiktokLiveSearch` → the completed task with every page of `videos` / `results`.
888
993
 
889
994
  ### Webhooks
890
995
 
@@ -894,7 +999,7 @@ Results: `transcribe` → same shape as `transcribeVideo()`; `watch` → `WatchR
894
999
  | `verifyWebhookSignature(rawBody, signatureHeader, secret, options?)` | Same check, returning `true` / `false` |
895
1000
  | `WEBHOOK_HEADERS` | Header names: `signature`, `delivery`, `event`, `taskId` |
896
1001
 
897
- `options`: `toleranceSeconds` (default `300`, `0` turns the check off). Event types: `transcribe.*`, `watch.*`, `extract_video.*`, `tweet_statement.*`, `tiktok_profile.*`, `tiktok_search.*`, `tiktok_live_search.*`, each with `.completed` or `.failed`.
1002
+ `options`: `toleranceSeconds` (default `300`, `0` turns the check off). Event types: `transcribe.*`, `watch.*`, `analyze_video.*`, `extract_video.*`, `tweet_statement.*`, `tiktok_profile.*`, `tiktok_search.*`, `tiktok_live_search.*`, each with `.completed` or `.failed`.
898
1003
 
899
1004
  ### TikTok
900
1005
 
@@ -918,8 +1023,9 @@ Completed profile tasks include `videos`; completed search tasks include `result
918
1023
  | Method | Description |
919
1024
  |--------|-------------|
920
1025
  | `getFiles(query?)` | List uploaded files (paginated). Filter by `status` or `namespace_id` |
921
- | `getFile(file_id, query?)` | Get file info and transcript. Pass `transcript_text: true` for plain text |
922
- | `uploadFile(options)` | Upload audio/video. Options: `filePath`, `wait_for_completion`, `namespace_ids` |
1026
+ | `getFile(file_id, query?)` | Get file info and transcript, and the `scenes` of the file once `file_info.scenes_status` is `'completed'`. Pass `transcript_text: true` for plain text |
1027
+ | `uploadFile(options)` | Upload audio/video. Options: `filePath`, `wait_for_completion`, `namespace_ids`, `include_scenes` (also analyze the scenes of a video file) |
1028
+ | `analyzeFileScenes(file_id)` | Start the scene analysis of a file already uploaded. Returns `{ file_id, scenes_status, message }`, with `scenes_status` `'processing'` or `'completed'` |
923
1029
  | `deleteFile(file_id)` | Delete a file |
924
1030
  | `getFileUrl(file_id)` | Get a signed download URL |
925
1031
  | `retryFileProcessing(file_id)` | Retry a failed processing job |
@@ -941,8 +1047,9 @@ Completed profile tasks include `videos`; completed search tasks include `result
941
1047
 
942
1048
  | Method | Description |
943
1049
  |--------|-------------|
944
- | `analyzeVideo(payload)` | Analyze an online video with an optional natural language query |
945
- | `analyzeFile(payload)` | Analyze an uploaded file with an optional natural language query |
1050
+ | `analyzeVideo(payload)` | Analyze an online video with an optional natural language query. Options: `video_url`, `query`, `include_scenes`, `transcript_text`, `include_usage` |
1051
+ | `analyze(urlOrInput, options?)` | The same analysis as a background job, for long videos with `include_scenes`. Input: `video_url`, `query`, `include_scenes`, `transcript_text`, `webhook_url`. Returns the same result as `analyzeVideo()`. See [Background jobs](#background-jobs) |
1052
+ | `analyzeFile(payload)` | Analyze an uploaded file with an optional natural language query. Options: `file_id`, `query`, `include_scenes`, `transcript_text`, `include_usage` |
946
1053
  | `tweetStatement(tweetIdOrInput, options?)` | Structured claim analysis of an X/Twitter tweet, including attached media of any length. Input: `tweet_id`, `webhook_url`. Returns a `TweetStatement` |
947
1054
  | `getTweetStatement(payload, options?)` | Same as `tweetStatement()`, with the original payload shape |
948
1055
 
@@ -953,15 +1060,17 @@ Returns `transcript_analysis` containing:
953
1060
  - `key_subjects` — important topics (name, description, importance)
954
1061
  - `query_answer` — direct answer to your query (when provided) with `answer`, `best_segment_index`, and `relevant_segments`
955
1062
 
1063
+ With `include_scenes: true`, the result of `analyzeVideo`, `analyze` and `analyzeFile` also has `scenes` (a list of `VideoScene`) and `frames_analyzed`, plus `scenes_error` or `transcript_error` (`{ error, message }`) when the picture or the transcript could not be had. `analyzeFile` on a file that has no scenes throws `ScenesNotAvailableError`.
1064
+
956
1065
  ### Extraction
957
1066
 
958
1067
  | Method | Description |
959
1068
  |--------|-------------|
960
- | `extractVideo(input, options?)` | Structured data from an online video of any length. Input: `video_url`, `schema` or `schemaFilePath`, `what_to_extract`, `transcribe`, `webhook_url`. Returns `{ data, video_info, usage? }` |
1069
+ | `extractVideo(input, options?)` | Structured data from an online video of any length. Input: `video_url`, `schema` or `schemaFilePath`, `what_to_extract`, `transcribe`, `include_scenes`, `webhook_url`. Returns `{ data, video_info, frames_analyzed?, usage? }` |
961
1070
  | `extractVideoData(payload, options?)` | Same as `extractVideo()`, with the original payload shape (`include_usage` in the payload) |
962
- | `extractFileData(payload)` | Extract structured data from an uploaded file transcript |
1071
+ | `extractFileData(payload)` | Extract structured data from an uploaded file transcript, and from its scenes with `include_scenes`. Returns `{ data, file_info, frames_analyzed?, usage? }` |
963
1072
 
964
- **Options:** `schema` (required for JSON requests), `schemaFilePath` (JSON/YAML schema file via multipart form-data), `what_to_extract` (optional guidance), `include_usage` (attach a per-call `UsageBlock`; read LLM tokens via `usage.analysis_tokens`)
1073
+ **Options:** `schema` (required for JSON requests), `schemaFilePath` (JSON/YAML schema file via multipart form-data), `what_to_extract` (optional guidance), `include_scenes` (also extract from what the video or the file shows; the result then has `frames_analyzed`, plus `scenes_error` or `transcript_error` when one of the two could not be had), `include_usage` (attach a per-call `UsageBlock`; read LLM tokens via `usage.analysis_tokens`)
965
1074
 
966
1075
  **Schema field types:** `String`, `Number`, `Boolean`, `Integer`, `Object`, `Array`, `Enum`
967
1076
 
@@ -1016,6 +1125,7 @@ try {
1016
1125
  | `InsufficientCreditsError` | 402 | A job could not start: not enough credits (`limit_exceeded`). Extends `PaymentRequiredError` |
1017
1126
  | `AccessDeniedError` | 403 | Insufficient permissions |
1018
1127
  | `NotFoundError` | 404 | Resource does not exist, or a job's `task_id` is unknown or expired (`task_not_found`) |
1128
+ | `ScenesNotAvailableError` | 409 | `include_scenes` was asked on an uploaded file that has no scenes to read (`scenes_not_available`). Has `scenes_status` (`'none'`, `'processing'` or `'failed'`) and, when failed, `scenes_error` |
1019
1129
  | `StorageQuotaExceededError` | 413 | Storage quota exceeded |
1020
1130
  | `RateLimitExceededError` | 429 | Too many requests |
1021
1131
  | `TooManyActiveJobsError` | 429 | A job could not start: too many of your jobs are already running (`too_many_active_jobs`). Extends `RateLimitExceededError` |
@@ -1034,7 +1144,7 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
1034
1144
  | Class | Description |
1035
1145
  |-------|-------------|
1036
1146
  | `VideoInfo` | Video metadata: title, channel, duration, views, likes, published date, keywords, carousel info |
1037
- | `FileInfo` | Uploaded file: name, size, type, duration, status, `namespace_ids`, `namespaces` |
1147
+ | `FileInfo` | Uploaded file: name, size, type, duration, status, `namespace_ids`, `namespaces`, and where its scene analysis stands: `scenes_status`, `frames_analyzed`, `scenes_error` |
1038
1148
  | `TranscriptSegment` | Timed segment: `text`, `start`, `end` (seconds) |
1039
1149
  | `AnalysisResult` | AI analysis: summary, people, places, key subjects, query answer |
1040
1150
  | `Namespace` | Full namespace: id, name, created/updated timestamps |
@@ -1048,9 +1158,9 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
1048
1158
  | `CarouselInfo` | Carousel summary: total items, video/image count, transcribed count, total duration |
1049
1159
  | `CarouselVideoResult` | Per-video result in a carousel: index, status, video info, transcript |
1050
1160
  | `Job` | Handle returned by `.submit()` / `.resume()`: `task_id`, `status()`, `refresh()`, `result()`, `wait()` |
1051
- | `AsyncJob<T>` | Task snapshot of a transcription, watch, extraction, or tweet job (from `job.refresh()` / `job.wait()`): `task_status`, `result`, `error`, `webhook`, `request`, timestamps |
1161
+ | `AsyncJob<T>` | Task snapshot of a transcription, watch, video analysis, extraction, or tweet job (from `job.refresh()` / `job.wait()`): `task_status`, `result`, `error`, `webhook`, `request`, timestamps |
1052
1162
  | `WatchResult` | A watched video, from `watch()`: `video_info`, `transcript` (left out with `include_transcript: false`), `transcript_error`, `scenes`, `frames_analyzed`, `usage` |
1053
- | `VideoScene` | What a video shows between `start` and `end` (seconds): `description`, `on_screen_text` |
1163
+ | `VideoScene` | What a video or an uploaded file shows between `start` and `end` (seconds): `description`, `on_screen_text`. Returned by `watch()`, by `getFile()`, and by the analyses asked with `include_scenes` |
1054
1164
  | `TikTokProfileScrapeSubmission` | Async scrape submission: `task_id`, status, profile URL, expiry, `webhook_url` |
1055
1165
  | `TikTokProfileTask` | TikTok profile scrape task with status, profile metadata, videos, pagination, `download_url`, `error`, `webhook` |
1056
1166
  | `TikTokVideo` | Public TikTok video metadata returned by profile scraping, including `published_at` as a `Date` and integer counters |
@@ -1063,6 +1173,13 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
1063
1173
  | `TikTokLiveRoomDetail` | A `TikTokLiveRoom` from `getTikTokLiveRoom`: `status` / `isLive`, `ended_at`, `stats.new_followers`, `author.bio`, `share_url`, `chat_enabled`, `subscribers_only`, `products` |
1064
1174
  | `TweetStatement` | Structured X/Twitter claim analysis, topics, entities, tone, intent, and source text |
1065
1175
 
1176
+ ## What's new in 2.5.0
1177
+
1178
+ - **Scenes in analysis and extraction:** `include_scenes: true` on `analyzeVideo()`, `analyzeFile()`, `extractVideo()` / `extractVideoData()` and `extractFileData()` makes the analysis or the extraction from what the video shows as well as what it says. Analysis results gain `scenes` and `frames_analyzed`, extraction results gain `frames_analyzed`; `scenes_error` and `transcript_error` say when one of the two could not be had.
1179
+ - **Video analysis as a background job:** [`vn.analyze()`](#analyze-an-online-video) runs the analysis of `analyzeVideo()` as a background job, for long videos with `include_scenes`, with `vn.analyze.submit()`, `vn.analyze.resume(task_id)` and the `analyze_video.completed` / `analyze_video.failed` webhook events. `analyzeVideo()` itself still makes a direct call.
1180
+ - **Scenes of an uploaded file:** [`uploadFile({ include_scenes: true })`](#8b-scenes-of-an-uploaded-file) analyzes the scenes of a video file at the upload, and `analyzeFileScenes(file_id)` does it for a file already uploaded. `file_info` gains `scenes_status`, `frames_analyzed` and `scenes_error`, and `getFile()` returns the `scenes` once they are there.
1181
+ - **`ScenesNotAvailableError`** (HTTP 409): thrown by `analyzeFile()` and `extractFileData()` when `include_scenes` is asked on a file that has no scenes to read. Its `scenes_status` says where their analysis stands.
1182
+
1066
1183
  ## What's new in 2.4.0
1067
1184
 
1068
1185
  - **Watch:** [`vn.watch()`](#2b-watch-a-video-scenes-next-to-the-transcript) reads what a video shows, next to what it says: a list of scenes (`start`, `end`, `description`, `on_screen_text`) and the transcript, in one result. `detail` sets how closely the picture is followed, `include_transcript: false` returns the scenes only. Runs as a background job like `vn.transcribe()`, with `vn.watch.submit()`, `vn.watch.resume(task_id)`, `watchVideo()` and the `watch.completed` / `watch.failed` webhook events.
package/dist/errors.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Custom exception classes for VidNavigator SDK.
3
3
  */
4
+ import { FileScenesStatus, ScenesError } from './models';
4
5
  /**
5
6
  * Base class for all VidNavigator SDK errors.
6
7
  * Contains additional information from the API response when available.
@@ -95,6 +96,18 @@ export declare class InsufficientCreditsError extends PaymentRequiredError {
95
96
  export declare class TooManyActiveJobsError extends RateLimitExceededError {
96
97
  constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
97
98
  }
99
+ /**
100
+ * Raised when `include_scenes` was asked on an uploaded file that has no scenes to read
101
+ * (HTTP 409, `scenes_not_available`). `scenes_status` says where their analysis stands: `none`
102
+ * (never asked for: start it with `analyzeFileScenes(file_id)`), `processing` (call again once
103
+ * `getFile()` reports `completed`) or `failed` (see `scenes_error`).
104
+ */
105
+ export declare class ScenesNotAvailableError extends VidNavigatorError {
106
+ readonly scenes_status?: Exclude<FileScenesStatus, 'completed'>;
107
+ /** Present when `scenes_status` is `failed`, e.g. `frames_not_available` for an audio file. */
108
+ readonly scenes_error?: ScenesError;
109
+ constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any, scenes_status?: Exclude<FileScenesStatus, 'completed'>, scenes_error?: ScenesError);
110
+ }
98
111
  /**
99
112
  * Raised when waiting for a job exceeds `timeoutMs`. Always carries `task_id`: the job keeps
100
113
  * running server-side and its result stays readable for 1 hour after it finishes, so resume it
package/dist/errors.js CHANGED
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
- /**
3
- * Custom exception classes for VidNavigator SDK.
4
- */
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.WebhookSignatureError = exports.TaskTimeoutError = exports.TooManyActiveJobsError = exports.InsufficientCreditsError = exports.SystemOverloadError = exports.GeoRestrictedError = exports.StorageQuotaExceededError = exports.ServerError = exports.PaymentRequiredError = exports.RateLimitExceededError = exports.NotFoundError = exports.AccessDeniedError = exports.BadRequestError = exports.AuthenticationError = exports.VidNavigatorError = void 0;
3
+ exports.WebhookSignatureError = exports.TaskTimeoutError = exports.ScenesNotAvailableError = exports.TooManyActiveJobsError = exports.InsufficientCreditsError = exports.SystemOverloadError = exports.GeoRestrictedError = exports.StorageQuotaExceededError = exports.ServerError = exports.PaymentRequiredError = exports.RateLimitExceededError = exports.NotFoundError = exports.AccessDeniedError = exports.BadRequestError = exports.AuthenticationError = exports.VidNavigatorError = void 0;
7
4
  /**
8
5
  * Base class for all VidNavigator SDK errors.
9
6
  * Contains additional information from the API response when available.
@@ -157,6 +154,22 @@ class TooManyActiveJobsError extends RateLimitExceededError {
157
154
  }
158
155
  }
159
156
  exports.TooManyActiveJobsError = TooManyActiveJobsError;
157
+ /**
158
+ * Raised when `include_scenes` was asked on an uploaded file that has no scenes to read
159
+ * (HTTP 409, `scenes_not_available`). `scenes_status` says where their analysis stands: `none`
160
+ * (never asked for: start it with `analyzeFileScenes(file_id)`), `processing` (call again once
161
+ * `getFile()` reports `completed`) or `failed` (see `scenes_error`).
162
+ */
163
+ class ScenesNotAvailableError extends VidNavigatorError {
164
+ constructor(message, status_code, error_code, error_message, details, scenes_status, scenes_error) {
165
+ super(message, status_code, error_code, error_message, details);
166
+ this.name = 'ScenesNotAvailableError';
167
+ this.scenes_status = scenes_status;
168
+ this.scenes_error = scenes_error;
169
+ Object.setPrototypeOf(this, ScenesNotAvailableError.prototype);
170
+ }
171
+ }
172
+ exports.ScenesNotAvailableError = ScenesNotAvailableError;
160
173
  /**
161
174
  * Raised when waiting for a job exceeds `timeoutMs`. Always carries `task_id`: the job keeps
162
175
  * running server-side and its result stays readable for 1 hour after it finishes, so resume it
package/dist/http.js CHANGED
@@ -31,6 +31,11 @@ function buildApiError(status, data, fallbackMessage) {
31
31
  return new errors_1.AccessDeniedError(message, status, errorCode, errorMessage, details);
32
32
  case 404:
33
33
  return new errors_1.NotFoundError(message, status, errorCode, errorMessage, details);
34
+ case 409:
35
+ if (errorCode === 'scenes_not_available') {
36
+ return new errors_1.ScenesNotAvailableError(message, status, errorCode, errorMessage, details, data?.scenes_status, data?.scenes_error);
37
+ }
38
+ return new errors_1.VidNavigatorError(message, status, errorCode, errorMessage, details);
34
39
  case 413:
35
40
  return new errors_1.StorageQuotaExceededError(message, status, errorCode, errorMessage, details);
36
41
  case 429: