vidnavigator 2.2.0 → 2.3.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 +35 -2
- package/dist/index.d.ts +23 -3
- package/dist/index.js +41 -2
- package/dist/models/TikTok.d.ts +117 -0
- package/dist/models/TikTok.js +57 -1
- package/package.json +1 -1
- package/src/index.ts +66 -3
- package/src/models/TikTok.ts +179 -0
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
|
- **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.
|
|
15
|
+
- **TikTok LIVE room** — check one room or streamer right away, with its latest comments, pinned comment and top viewers.
|
|
15
16
|
- **Instagram carousel support** — select a specific video by index, or transcribe every video in a carousel post with one call.
|
|
16
17
|
- **AI-powered analysis** — get summaries, people mentioned, places, key subjects, and direct answers to questions about any video or audio.
|
|
17
18
|
- **Structured data extraction** — define a JSON schema and receive typed, structured fields extracted from any transcript (powered by LLMs).
|
|
@@ -493,6 +494,27 @@ for (const room of task.results) {
|
|
|
493
494
|
- `country` defaults to `'us'`. Results keep TikTok's ranking; a keyword with no LIVE room in that country at that moment completes with zero results.
|
|
494
495
|
- Billing: 1 `residential_request` per 30 rooms TikTok returned (`task.stats.rooms_fetched`), minimum 1 per search.
|
|
495
496
|
|
|
497
|
+
### 6c. TikTok LIVE room (sync)
|
|
498
|
+
|
|
499
|
+
`vn.getTikTokLiveRoom()` returns one LIVE room right away, no job: by `room_id`, `username` or `url` (exactly one). Use it to check whether someone is live, to follow a room found by LIVE search, or to read its latest comments:
|
|
500
|
+
|
|
501
|
+
```ts
|
|
502
|
+
const { room, comments } = await vn.getTikTokLiveRoom({ username: 'tiktok', include_comments: true });
|
|
503
|
+
|
|
504
|
+
console.log(room.status, room.title, room.stats?.viewers, room.stats?.new_followers);
|
|
505
|
+
if (room.isLive) {
|
|
506
|
+
for (const c of comments ?? []) console.log(c.created_at, c.author?.unique_id, c.text);
|
|
507
|
+
} else {
|
|
508
|
+
console.log('ended at', room.ended_at);
|
|
509
|
+
}
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
- `room_id`: a LIVE room id, as a string (room ids have more digits than a JavaScript number holds). `username`: the streamer, with or without `@`: their current LIVE, or their last one when they are offline. `url`: `https://www.tiktok.com/@username/live`, the profile URL, or a room's `share_url`.
|
|
513
|
+
- The room (`TikTokLiveRoomDetail`) has the LIVE search room fields plus `status` (`'live'` / `'ended'`, also `room.isLive`), `ended_at`, `stats.new_followers`, `author.bio`, `author.following`, `share_url`, `chat_enabled`, `subscribers_only`, `age_restricted` and `products` (items on sale). It has no likes, comment count or share count: LIVE search returns those.
|
|
514
|
+
- `include_comments: true` adds `comments` (newest first, up to `comments_limit`, max 50; TikTok keeps only about the last 50 of a LIVE), `pinned_comment`, `intro` and `top_viewers`. An ended room has no comments.
|
|
515
|
+
- A room or account that does not exist throws `NotFoundError` (`error_code` `'live_not_found'`). The call usually takes a few seconds; a shorter `axiosConfig.timeout` is raised to two minutes for it.
|
|
516
|
+
- Billing: 1 `residential_request` per room, 2 with `include_comments` (1 when the room has ended). Not billed when the room is not found.
|
|
517
|
+
|
|
496
518
|
### 7. Instagram carousel posts (multiple videos)
|
|
497
519
|
|
|
498
520
|
Instagram carousel posts can contain multiple videos. You can select a specific video by index, or transcribe them all at once:
|
|
@@ -662,7 +684,7 @@ Search YouTube videos and uploaded files with AI-powered ranking/reranking.
|
|
|
662
684
|
// Search YouTube videos
|
|
663
685
|
const videoResults = await vn.searchYouTube({
|
|
664
686
|
query: 'how to deploy a Node.js app',
|
|
665
|
-
focus: 'relevance', // 'relevance' (default) | 'popularity' | 'brevity'
|
|
687
|
+
focus: 'relevance', // 'relevance' (default) | 'recency' | 'popularity' | 'brevity'
|
|
666
688
|
max_results: 5, // caps how many candidates are analysed (and the cost)
|
|
667
689
|
include_usage: true, // attach a per-call usage block
|
|
668
690
|
});
|
|
@@ -678,6 +700,15 @@ if (videoResults.status === 'partial') {
|
|
|
678
700
|
console.log('Partial results:', videoResults.error_code); // "insufficient_credits_video_search"
|
|
679
701
|
}
|
|
680
702
|
|
|
703
|
+
// The filters combine: the most recent videos of five minutes at most, published since 2025
|
|
704
|
+
const recent = await vn.searchYouTube({
|
|
705
|
+
query: 'how to deploy a Node.js app',
|
|
706
|
+
focus: 'recency',
|
|
707
|
+
duration: 300,
|
|
708
|
+
start_year: 2025,
|
|
709
|
+
max_results: 5,
|
|
710
|
+
});
|
|
711
|
+
|
|
681
712
|
// Search uploaded files — optionally scoped to a namespace
|
|
682
713
|
const fileResults = await vn.searchFiles({
|
|
683
714
|
query: 'quarterly revenue discussion',
|
|
@@ -810,6 +841,7 @@ Results: `transcribe` → same shape as `transcribeVideo()`; `extractVideo` →
|
|
|
810
841
|
| `getTikTokSearch(task_id, query?)` | Poll search status and retrieve a page of results. Options: `cursor`, `limit`, `include_usage` |
|
|
811
842
|
| `submitTikTokLiveSearch(payload)` | Start an async TikTok LIVE search. Returns a `task_id` immediately. Options: `max_results`, `country`, `include_stream_urls`, `webhook_url` |
|
|
812
843
|
| `getTikTokLiveSearch(task_id, query?)` | Poll LIVE search status and retrieve a page of rooms. Options: `cursor`, `limit`, `include_usage` |
|
|
844
|
+
| `getTikTokLiveRoom(payload)` | One LIVE room right away, by `room_id`, `username` or `url`. Options: `include_comments`, `comments_limit`, `include_stream_urls`, `include_usage` |
|
|
813
845
|
|
|
814
846
|
Completed profile tasks include `videos`; completed search tasks include `results`. Both include `pagination`, optional `stats`, and an optional short-lived `download_url` for retrieving the whole result as JSON. Failed tasks include `error` (`{ error, message, http_status }`); the older `error_message` string still works but is deprecated. Datetime filters use `after_datetime` and `before_datetime`, each accepting either `YYYY-MM-DD` or full ISO datetime strings with timezone; TikTok `published_at` values are parsed into JavaScript `Date` objects, and numeric counters such as `views` and `likes` are normalized to integers.
|
|
815
847
|
|
|
@@ -873,7 +905,7 @@ Returns `transcript_analysis` containing:
|
|
|
873
905
|
| `searchVideos(payload)` | **Deprecated** — forwards to `searchYouTube()` |
|
|
874
906
|
| `searchFiles(payload)` | Semantic search across uploaded files, with optional `namespace_ids` scope |
|
|
875
907
|
|
|
876
|
-
**`searchYouTube` options:** `query` (required), `use_enhanced_search` (default `true`), `start_year
|
|
908
|
+
**`searchYouTube` options:** `query` (required), `use_enhanced_search` (default `true`), `start_year` / `end_year` (only videos published in or after / in or before that year), `focus` (what comes first among the matches: `'relevance'` (default) \| `'recency'` \| `'popularity'` \| `'brevity'`), `duration` (maximum length in seconds; longer videos are left out), `max_results` (caps candidates analysed & cost; defaults to your plan ceiling), `include_usage`.
|
|
877
909
|
|
|
878
910
|
Results include `relevance_score`, `transcript_summary`, `people`, `places`, `key_subjects`, `query_answer`, `timestamps`, and `relevant_text`. If credits run out mid-search the API returns a partial result: `searchYouTube` surfaces it as `{ status: 'partial', error_code: 'insufficient_credits_video_search', results, usage? }` instead of throwing.
|
|
879
911
|
|
|
@@ -958,6 +990,7 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
|
|
|
958
990
|
| `TikTokLiveSearchSubmission` | Async TikTok LIVE search submission: `task_id`, query, country, `include_stream_urls`, expiry, `webhook_url` |
|
|
959
991
|
| `TikTokLiveSearchTask` | TikTok LIVE search task with status, rooms, pagination, `download_url`, `error`, `webhook`; `stats.rooms_fetched` is what is billed |
|
|
960
992
|
| `TikTokLiveRoom` | A LIVE room: author, `stats.viewers`, `hashtags`, `category`, `game_tags`, `started_at` as a `Date`, and `stream_urls` (FLV / HLS by quality, audio only) |
|
|
993
|
+
| `TikTokLiveRoomDetail` | A `TikTokLiveRoom` from `getTikTokLiveRoom`: `status` / `isLive`, `ended_at`, `stats.new_followers`, `author.bio`, `share_url`, `chat_enabled`, `subscribers_only`, `products` |
|
|
961
994
|
| `TweetStatement` | Structured X/Twitter claim analysis, topics, entities, tone, intent, and source text |
|
|
962
995
|
|
|
963
996
|
## Links
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { VideoInfo, TranscriptOutput, FileInfo, AnalysisResult, VideoSearchResult, FileSearchResult, UsageData, Namespace, NamespaceRef, ExtractionSchema, UsageBlock, CarouselInfo, CarouselVideoResult, TikTokProfileScrapeRequest, TikTokProfileScrapeSubmission, TikTokProfileTask, TikTokSearchRequest, TikTokSearchSubmission, TikTokSearchTask, TikTokLiveSearchRequest, TikTokLiveSearchSubmission, TikTokLiveSearchTask, TweetStatement, AsyncJob } from './models';
|
|
2
|
+
import { VideoInfo, TranscriptOutput, FileInfo, AnalysisResult, VideoSearchResult, FileSearchResult, UsageData, Namespace, NamespaceRef, ExtractionSchema, UsageBlock, CarouselInfo, CarouselVideoResult, TikTokProfileScrapeRequest, TikTokProfileScrapeSubmission, TikTokProfileTask, TikTokSearchRequest, TikTokSearchSubmission, TikTokSearchTask, TikTokLiveSearchRequest, TikTokLiveSearchSubmission, TikTokLiveSearchTask, TikTokLiveRoomRequest, TikTokLiveRoomResult, TweetStatement, AsyncJob } from './models';
|
|
3
3
|
import { Job, JobOperation, PollOptions, RunOptions, SubmitOptions } from './jobs';
|
|
4
4
|
export * from './models';
|
|
5
5
|
export * from './errors';
|
|
@@ -7,7 +7,7 @@ export * from './webhooks';
|
|
|
7
7
|
export { Job } from './jobs';
|
|
8
8
|
export type { TaskStatus, PollableTask, PollOptions, JobOperation, SubmitOptions, RunOptions, JobInfo } from './jobs';
|
|
9
9
|
/** SDK version (keep in sync with package.json) */
|
|
10
|
-
export declare const SDK_VERSION = "2.
|
|
10
|
+
export declare const SDK_VERSION = "2.3.1";
|
|
11
11
|
export interface SDKConfig {
|
|
12
12
|
apiKey: string;
|
|
13
13
|
baseURL?: string;
|
|
@@ -129,13 +129,22 @@ export interface ExtractDataResult {
|
|
|
129
129
|
file_info?: FileInfo;
|
|
130
130
|
usage?: UsageBlock;
|
|
131
131
|
}
|
|
132
|
-
|
|
132
|
+
/**
|
|
133
|
+
* What comes first among the videos that match the query: the best matches
|
|
134
|
+
* (`relevance`), the most recent (`recency`), the most viewed (`popularity`)
|
|
135
|
+
* or the shortest (`brevity`).
|
|
136
|
+
*/
|
|
137
|
+
export type YouTubeSearchFocus = 'relevance' | 'recency' | 'popularity' | 'brevity';
|
|
133
138
|
export type SearchYouTubePayload = {
|
|
134
139
|
query: string;
|
|
135
140
|
use_enhanced_search?: boolean;
|
|
141
|
+
/** Only videos published in or after this year. */
|
|
136
142
|
start_year?: number;
|
|
143
|
+
/** Only videos published in or before this year. */
|
|
137
144
|
end_year?: number;
|
|
145
|
+
/** Defaults to `relevance`. With another value, `explanation` is empty. */
|
|
138
146
|
focus?: YouTubeSearchFocus;
|
|
147
|
+
/** Maximum duration in seconds: longer videos are left out. */
|
|
139
148
|
duration?: number;
|
|
140
149
|
max_results?: number;
|
|
141
150
|
include_usage?: boolean;
|
|
@@ -296,6 +305,17 @@ export declare class VidNavigatorClient {
|
|
|
296
305
|
limit?: number;
|
|
297
306
|
include_usage?: boolean;
|
|
298
307
|
}): Promise<TikTokLiveSearchTask>;
|
|
308
|
+
/**
|
|
309
|
+
* One TikTok LIVE room, right away (`POST /tiktok/live/room`, no job): by `room_id`, `username`
|
|
310
|
+
* or `url`, exactly one. The room says whether it is live or ended (and when), its viewers and new
|
|
311
|
+
* followers, the streamer's bio, and more. With `include_comments: true` the result also has the
|
|
312
|
+
* latest comments (up to 50), the pinned comment, the intro and the top viewers.
|
|
313
|
+
*
|
|
314
|
+
* The room has no likes, comment count or share count: TikTok gives those to LIVE search only.
|
|
315
|
+
* A room or account that does not exist throws `NotFoundError` (`error_code` `live_not_found`)
|
|
316
|
+
* and is not billed. Billing: 1 `residential_request`, 2 with `include_comments`.
|
|
317
|
+
*/
|
|
318
|
+
getTikTokLiveRoom(payload: TikTokLiveRoomRequest): Promise<TikTokLiveRoomResult>;
|
|
299
319
|
getFiles(query?: {
|
|
300
320
|
limit?: number;
|
|
301
321
|
offset?: number;
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,12 @@ __exportStar(require("./webhooks"), exports);
|
|
|
31
31
|
var jobs_2 = require("./jobs");
|
|
32
32
|
Object.defineProperty(exports, "Job", { enumerable: true, get: function () { return jobs_2.Job; } });
|
|
33
33
|
/** SDK version (keep in sync with package.json) */
|
|
34
|
-
exports.SDK_VERSION = '2.
|
|
34
|
+
exports.SDK_VERSION = '2.3.1';
|
|
35
|
+
/**
|
|
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
|
+
* minutes at worst. A shorter configured axios timeout is raised to this for that call only.
|
|
38
|
+
*/
|
|
39
|
+
const LIVE_ROOM_TIMEOUT_MS = 120000;
|
|
35
40
|
//endregion
|
|
36
41
|
function parseTranscribeData(inner, usage) {
|
|
37
42
|
if ('videos' in inner && 'carousel_info' in inner) {
|
|
@@ -205,7 +210,11 @@ class VidNavigatorClient {
|
|
|
205
210
|
job.usage = models_1.UsageBlock.fromJSON(response.usage);
|
|
206
211
|
return job;
|
|
207
212
|
}
|
|
208
|
-
async request(method, url, data, params, extraHeaders) {
|
|
213
|
+
async request(method, url, data, params, extraHeaders, minTimeoutMs) {
|
|
214
|
+
// A call known to run long raises a configured timeout, never lowers it
|
|
215
|
+
// (0 / unset means no timeout at all).
|
|
216
|
+
const configured = this.client.defaults.timeout;
|
|
217
|
+
const timeout = minTimeoutMs && configured ? Math.max(configured, minTimeoutMs) : undefined;
|
|
209
218
|
try {
|
|
210
219
|
const response = await this.client.request({
|
|
211
220
|
method,
|
|
@@ -213,6 +222,7 @@ class VidNavigatorClient {
|
|
|
213
222
|
data,
|
|
214
223
|
params,
|
|
215
224
|
headers: extraHeaders,
|
|
225
|
+
...(timeout !== undefined ? { timeout } : {}),
|
|
216
226
|
});
|
|
217
227
|
return response.data;
|
|
218
228
|
}
|
|
@@ -289,6 +299,35 @@ class VidNavigatorClient {
|
|
|
289
299
|
task.usage = models_1.UsageBlock.fromJSON(response.usage);
|
|
290
300
|
return task;
|
|
291
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* One TikTok LIVE room, right away (`POST /tiktok/live/room`, no job): by `room_id`, `username`
|
|
304
|
+
* or `url`, exactly one. The room says whether it is live or ended (and when), its viewers and new
|
|
305
|
+
* followers, the streamer's bio, and more. With `include_comments: true` the result also has the
|
|
306
|
+
* latest comments (up to 50), the pinned comment, the intro and the top viewers.
|
|
307
|
+
*
|
|
308
|
+
* The room has no likes, comment count or share count: TikTok gives those to LIVE search only.
|
|
309
|
+
* A room or account that does not exist throws `NotFoundError` (`error_code` `live_not_found`)
|
|
310
|
+
* and is not billed. Billing: 1 `residential_request`, 2 with `include_comments`.
|
|
311
|
+
*/
|
|
312
|
+
async getTikTokLiveRoom(payload) {
|
|
313
|
+
const targets = ['room_id', 'username', 'url'].filter((key) => payload?.[key]);
|
|
314
|
+
if (targets.length !== 1) {
|
|
315
|
+
throw new errors_1.VidNavigatorError('Pass exactly one of room_id, username or url');
|
|
316
|
+
}
|
|
317
|
+
let body = payload;
|
|
318
|
+
const roomId = payload.room_id;
|
|
319
|
+
if (typeof roomId === 'number') {
|
|
320
|
+
if (!Number.isSafeInteger(roomId)) {
|
|
321
|
+
throw new errors_1.VidNavigatorError('room_id has more digits than a JavaScript number holds: pass it as a string');
|
|
322
|
+
}
|
|
323
|
+
body = { ...payload, room_id: String(roomId) };
|
|
324
|
+
}
|
|
325
|
+
const response = await this.request('POST', '/tiktok/live/room', body, undefined, undefined, LIVE_ROOM_TIMEOUT_MS);
|
|
326
|
+
const result = (0, models_1.tiktokLiveRoomResultFromJSON)(response.data);
|
|
327
|
+
if (response.usage)
|
|
328
|
+
result.usage = models_1.UsageBlock.fromJSON(response.usage);
|
|
329
|
+
return result;
|
|
330
|
+
}
|
|
292
331
|
//endregion
|
|
293
332
|
//region --- Files ---
|
|
294
333
|
async getFiles(query) {
|
package/dist/models/TikTok.d.ts
CHANGED
|
@@ -440,6 +440,123 @@ export declare class TikTokLiveRoom {
|
|
|
440
440
|
constructor(data: TikTokLiveRoomJSON);
|
|
441
441
|
static fromJSON(json: TikTokLiveRoomJSON): TikTokLiveRoom;
|
|
442
442
|
}
|
|
443
|
+
/** Exactly one of `room_id`, `username` or `url`. */
|
|
444
|
+
export interface TikTokLiveRoomRequest {
|
|
445
|
+
/**
|
|
446
|
+
* A LIVE room ID, e.g. the `id` of a LIVE search room. Pass it as a string: room IDs have more
|
|
447
|
+
* digits than a JavaScript number holds.
|
|
448
|
+
*/
|
|
449
|
+
room_id?: string;
|
|
450
|
+
/** The streamer, with or without `@`: their current LIVE, or their last one when they are offline. */
|
|
451
|
+
username?: string;
|
|
452
|
+
/** `https://www.tiktok.com/@username/live`, the profile URL, or a room's `share_url`. */
|
|
453
|
+
url?: string;
|
|
454
|
+
/**
|
|
455
|
+
* Also return the latest comments (up to 50, newest first), the pinned comment, the intro and the
|
|
456
|
+
* top viewers. Bills 2 `residential_request` instead of 1. Default `false`.
|
|
457
|
+
*/
|
|
458
|
+
include_comments?: boolean;
|
|
459
|
+
/** At most this many comments, 1-50 (default 50). */
|
|
460
|
+
comments_limit?: number;
|
|
461
|
+
/** Playback URLs are returned by default; pass `false` to leave them out. */
|
|
462
|
+
include_stream_urls?: boolean;
|
|
463
|
+
/** Add the `usage` block to the result. */
|
|
464
|
+
include_usage?: boolean;
|
|
465
|
+
}
|
|
466
|
+
export interface TikTokLiveRoomAuthor extends TikTokLiveAuthor {
|
|
467
|
+
bio?: string | null;
|
|
468
|
+
/** Accounts the streamer follows. */
|
|
469
|
+
following?: number | null;
|
|
470
|
+
}
|
|
471
|
+
/** A single room's counters. Likes, comments and shares come with LIVE search only. */
|
|
472
|
+
export interface TikTokLiveRoomStats {
|
|
473
|
+
/** Watching now (0 once the LIVE has ended). */
|
|
474
|
+
viewers?: number | null;
|
|
475
|
+
/** Since the LIVE started. */
|
|
476
|
+
total_viewers?: number | null;
|
|
477
|
+
/** Followers the streamer gained during this LIVE. */
|
|
478
|
+
new_followers?: number | null;
|
|
479
|
+
}
|
|
480
|
+
export interface TikTokLiveRoomDetailJSON extends TikTokLiveRoomJSON {
|
|
481
|
+
author?: TikTokLiveRoomAuthor;
|
|
482
|
+
stats?: TikTokLiveRoomStats;
|
|
483
|
+
status?: 'live' | 'ended' | 'unknown';
|
|
484
|
+
ended_at?: string | null;
|
|
485
|
+
share_url?: string | null;
|
|
486
|
+
age_restricted?: boolean;
|
|
487
|
+
subscribers_only?: boolean;
|
|
488
|
+
chat_enabled?: boolean;
|
|
489
|
+
products?: number;
|
|
490
|
+
}
|
|
491
|
+
/** One LIVE room, as `getTikTokLiveRoom` returns it. */
|
|
492
|
+
export declare class TikTokLiveRoomDetail extends TikTokLiveRoom {
|
|
493
|
+
author?: TikTokLiveRoomAuthor;
|
|
494
|
+
stats?: TikTokLiveRoomStats;
|
|
495
|
+
/** `'live'` while broadcasting, `'ended'` once finished. */
|
|
496
|
+
status?: 'live' | 'ended' | 'unknown';
|
|
497
|
+
ended_at?: Date | null;
|
|
498
|
+
/** The room's share link; it can be passed back as `url`. */
|
|
499
|
+
share_url?: string | null;
|
|
500
|
+
age_restricted?: boolean;
|
|
501
|
+
/** Only the streamer's paying subscribers can watch. */
|
|
502
|
+
subscribers_only?: boolean;
|
|
503
|
+
chat_enabled?: boolean;
|
|
504
|
+
/** Products on sale in the LIVE. */
|
|
505
|
+
products?: number;
|
|
506
|
+
constructor(data: TikTokLiveRoomDetailJSON);
|
|
507
|
+
get isLive(): boolean;
|
|
508
|
+
static fromJSON(json: TikTokLiveRoomDetailJSON): TikTokLiveRoomDetail;
|
|
509
|
+
}
|
|
510
|
+
export interface TikTokLiveCommentJSON {
|
|
511
|
+
id?: string | null;
|
|
512
|
+
text?: string | null;
|
|
513
|
+
language?: string | null;
|
|
514
|
+
created_at?: string | null;
|
|
515
|
+
author?: TikTokLiveAuthor;
|
|
516
|
+
author_is_follower?: boolean;
|
|
517
|
+
author_is_moderator?: boolean;
|
|
518
|
+
author_is_subscriber?: boolean;
|
|
519
|
+
}
|
|
520
|
+
/** A comment posted in a LIVE's chat. */
|
|
521
|
+
export interface TikTokLiveComment {
|
|
522
|
+
id?: string | null;
|
|
523
|
+
text?: string | null;
|
|
524
|
+
/** ISO 639-1 code TikTok detected, or `null`. */
|
|
525
|
+
language?: string | null;
|
|
526
|
+
created_at?: Date | null;
|
|
527
|
+
author?: TikTokLiveAuthor;
|
|
528
|
+
author_is_follower?: boolean;
|
|
529
|
+
author_is_moderator?: boolean;
|
|
530
|
+
/** A paying subscriber of the streamer. */
|
|
531
|
+
author_is_subscriber?: boolean;
|
|
532
|
+
}
|
|
533
|
+
/** One of a LIVE's top viewers, ranked by the gifts they sent. */
|
|
534
|
+
export interface TikTokLiveTopViewer {
|
|
535
|
+
rank?: number | null;
|
|
536
|
+
score?: number | null;
|
|
537
|
+
user?: TikTokLiveAuthor;
|
|
538
|
+
}
|
|
539
|
+
export interface TikTokLiveRoomResultJSON {
|
|
540
|
+
room: TikTokLiveRoomDetailJSON;
|
|
541
|
+
comments?: TikTokLiveCommentJSON[];
|
|
542
|
+
pinned_comment?: TikTokLiveCommentJSON | null;
|
|
543
|
+
intro?: string | null;
|
|
544
|
+
top_viewers?: TikTokLiveTopViewer[];
|
|
545
|
+
}
|
|
546
|
+
export interface TikTokLiveRoomResult {
|
|
547
|
+
room: TikTokLiveRoomDetail;
|
|
548
|
+
/** Latest comments, newest first (TikTok keeps about the last 50). Only with `include_comments`. */
|
|
549
|
+
comments?: TikTokLiveComment[];
|
|
550
|
+
/** The comment the streamer pinned. Only with `include_comments`. */
|
|
551
|
+
pinned_comment?: TikTokLiveComment | null;
|
|
552
|
+
/** The LIVE's intro text. Only with `include_comments`. */
|
|
553
|
+
intro?: string | null;
|
|
554
|
+
/** Top viewers by gifts sent. Only with `include_comments`. */
|
|
555
|
+
top_viewers?: TikTokLiveTopViewer[];
|
|
556
|
+
/** Present when called with `include_usage: true`. */
|
|
557
|
+
usage?: UsageBlock;
|
|
558
|
+
}
|
|
559
|
+
export declare function tiktokLiveRoomResultFromJSON(json: TikTokLiveRoomResultJSON): TikTokLiveRoomResult;
|
|
443
560
|
export interface TikTokLiveSearchStats {
|
|
444
561
|
/** TikTok pages fetched (up to 50 rooms each). */
|
|
445
562
|
pages_fetched?: number;
|
package/dist/models/TikTok.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TikTokLiveSearchTask = exports.TikTokLiveRoom = exports.TikTokLiveSearchSubmission = exports.TikTokSearchTask = exports.TikTokProfileTask = exports.TikTokSearchResult = exports.TikTokVideo = exports.TikTokSearchSubmission = exports.TikTokProfileScrapeSubmission = void 0;
|
|
3
|
+
exports.TikTokLiveSearchTask = exports.TikTokLiveRoomDetail = exports.TikTokLiveRoom = exports.TikTokLiveSearchSubmission = exports.TikTokSearchTask = exports.TikTokProfileTask = exports.TikTokSearchResult = exports.TikTokVideo = exports.TikTokSearchSubmission = exports.TikTokProfileScrapeSubmission = void 0;
|
|
4
|
+
exports.tiktokLiveRoomResultFromJSON = tiktokLiveRoomResultFromJSON;
|
|
4
5
|
function toInteger(value) {
|
|
5
6
|
if (value === null || value === undefined)
|
|
6
7
|
return value;
|
|
@@ -278,6 +279,61 @@ class TikTokLiveRoom {
|
|
|
278
279
|
}
|
|
279
280
|
}
|
|
280
281
|
exports.TikTokLiveRoom = TikTokLiveRoom;
|
|
282
|
+
/** One LIVE room, as `getTikTokLiveRoom` returns it. */
|
|
283
|
+
class TikTokLiveRoomDetail extends TikTokLiveRoom {
|
|
284
|
+
constructor(data) {
|
|
285
|
+
super(data);
|
|
286
|
+
this.author = data.author
|
|
287
|
+
? { ...data.author, followers: toInteger(data.author.followers), following: toInteger(data.author.following) }
|
|
288
|
+
: undefined;
|
|
289
|
+
this.stats = data.stats
|
|
290
|
+
? {
|
|
291
|
+
viewers: toInteger(data.stats.viewers),
|
|
292
|
+
total_viewers: toInteger(data.stats.total_viewers),
|
|
293
|
+
new_followers: toInteger(data.stats.new_followers),
|
|
294
|
+
}
|
|
295
|
+
: undefined;
|
|
296
|
+
this.status = data.status;
|
|
297
|
+
this.ended_at = toNullableDate(data.ended_at);
|
|
298
|
+
this.share_url = data.share_url;
|
|
299
|
+
this.age_restricted = data.age_restricted;
|
|
300
|
+
this.subscribers_only = data.subscribers_only;
|
|
301
|
+
this.chat_enabled = data.chat_enabled;
|
|
302
|
+
this.products = toOptionalInteger(data.products);
|
|
303
|
+
}
|
|
304
|
+
get isLive() {
|
|
305
|
+
return this.status === 'live';
|
|
306
|
+
}
|
|
307
|
+
static fromJSON(json) {
|
|
308
|
+
return new TikTokLiveRoomDetail(json);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
exports.TikTokLiveRoomDetail = TikTokLiveRoomDetail;
|
|
312
|
+
function liveCommentFromJSON(json) {
|
|
313
|
+
return {
|
|
314
|
+
...json,
|
|
315
|
+
created_at: toNullableDate(json.created_at),
|
|
316
|
+
author: json.author ? { ...json.author, followers: toInteger(json.author.followers) } : undefined,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function tiktokLiveRoomResultFromJSON(json) {
|
|
320
|
+
const result = { room: TikTokLiveRoomDetail.fromJSON(json.room) };
|
|
321
|
+
if (json.comments !== undefined)
|
|
322
|
+
result.comments = (json.comments ?? []).map(liveCommentFromJSON);
|
|
323
|
+
if (json.pinned_comment !== undefined) {
|
|
324
|
+
result.pinned_comment = json.pinned_comment ? liveCommentFromJSON(json.pinned_comment) : null;
|
|
325
|
+
}
|
|
326
|
+
if (json.intro !== undefined)
|
|
327
|
+
result.intro = json.intro;
|
|
328
|
+
if (json.top_viewers !== undefined) {
|
|
329
|
+
result.top_viewers = (json.top_viewers ?? []).map((v) => ({
|
|
330
|
+
...v,
|
|
331
|
+
rank: toInteger(v.rank),
|
|
332
|
+
score: toInteger(v.score),
|
|
333
|
+
}));
|
|
334
|
+
}
|
|
335
|
+
return result;
|
|
336
|
+
}
|
|
281
337
|
class TikTokLiveSearchTask {
|
|
282
338
|
constructor(data) {
|
|
283
339
|
this.task_id = data.task_id;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -43,6 +43,10 @@ import {
|
|
|
43
43
|
TikTokLiveSearchSubmissionJSON,
|
|
44
44
|
TikTokLiveSearchTask,
|
|
45
45
|
TikTokLiveSearchTaskJSON,
|
|
46
|
+
TikTokLiveRoomRequest,
|
|
47
|
+
TikTokLiveRoomResult,
|
|
48
|
+
TikTokLiveRoomResultJSON,
|
|
49
|
+
tiktokLiveRoomResultFromJSON,
|
|
46
50
|
TweetStatement,
|
|
47
51
|
AsyncJob,
|
|
48
52
|
AsyncJobJSON,
|
|
@@ -61,7 +65,13 @@ export { Job } from './jobs';
|
|
|
61
65
|
export type { TaskStatus, PollableTask, PollOptions, JobOperation, SubmitOptions, RunOptions, JobInfo } from './jobs';
|
|
62
66
|
|
|
63
67
|
/** SDK version (keep in sync with package.json) */
|
|
64
|
-
export const SDK_VERSION = '2.
|
|
68
|
+
export const SDK_VERSION = '2.3.1';
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A LIVE room usually answers in 1-5 s, up to ~30 s when the API has to open a TikTok page, and two
|
|
72
|
+
* minutes at worst. A shorter configured axios timeout is raised to this for that call only.
|
|
73
|
+
*/
|
|
74
|
+
const LIVE_ROOM_TIMEOUT_MS = 120_000;
|
|
65
75
|
|
|
66
76
|
//region --- Interfaces ---
|
|
67
77
|
export interface SDKConfig {
|
|
@@ -208,14 +218,23 @@ export interface ExtractDataResult {
|
|
|
208
218
|
usage?: UsageBlock;
|
|
209
219
|
}
|
|
210
220
|
|
|
211
|
-
|
|
221
|
+
/**
|
|
222
|
+
* What comes first among the videos that match the query: the best matches
|
|
223
|
+
* (`relevance`), the most recent (`recency`), the most viewed (`popularity`)
|
|
224
|
+
* or the shortest (`brevity`).
|
|
225
|
+
*/
|
|
226
|
+
export type YouTubeSearchFocus = 'relevance' | 'recency' | 'popularity' | 'brevity';
|
|
212
227
|
|
|
213
228
|
export type SearchYouTubePayload = {
|
|
214
229
|
query: string;
|
|
215
230
|
use_enhanced_search?: boolean;
|
|
231
|
+
/** Only videos published in or after this year. */
|
|
216
232
|
start_year?: number;
|
|
233
|
+
/** Only videos published in or before this year. */
|
|
217
234
|
end_year?: number;
|
|
235
|
+
/** Defaults to `relevance`. With another value, `explanation` is empty. */
|
|
218
236
|
focus?: YouTubeSearchFocus;
|
|
237
|
+
/** Maximum duration in seconds: longer videos are left out. */
|
|
219
238
|
duration?: number;
|
|
220
239
|
max_results?: number;
|
|
221
240
|
include_usage?: boolean;
|
|
@@ -614,8 +633,13 @@ export class VidNavigatorClient {
|
|
|
614
633
|
url: string,
|
|
615
634
|
data?: any,
|
|
616
635
|
params?: any,
|
|
617
|
-
extraHeaders?: any
|
|
636
|
+
extraHeaders?: any,
|
|
637
|
+
minTimeoutMs?: number
|
|
618
638
|
): Promise<T> {
|
|
639
|
+
// A call known to run long raises a configured timeout, never lowers it
|
|
640
|
+
// (0 / unset means no timeout at all).
|
|
641
|
+
const configured = this.client.defaults.timeout;
|
|
642
|
+
const timeout = minTimeoutMs && configured ? Math.max(configured, minTimeoutMs) : undefined;
|
|
619
643
|
try {
|
|
620
644
|
const response = await this.client.request<T>({
|
|
621
645
|
method,
|
|
@@ -623,6 +647,7 @@ export class VidNavigatorClient {
|
|
|
623
647
|
data,
|
|
624
648
|
params,
|
|
625
649
|
headers: extraHeaders,
|
|
650
|
+
...(timeout !== undefined ? { timeout } : {}),
|
|
626
651
|
});
|
|
627
652
|
return response.data;
|
|
628
653
|
} catch (error: any) {
|
|
@@ -751,6 +776,44 @@ export class VidNavigatorClient {
|
|
|
751
776
|
if (response.usage) task.usage = UsageBlock.fromJSON(response.usage);
|
|
752
777
|
return task;
|
|
753
778
|
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* One TikTok LIVE room, right away (`POST /tiktok/live/room`, no job): by `room_id`, `username`
|
|
782
|
+
* or `url`, exactly one. The room says whether it is live or ended (and when), its viewers and new
|
|
783
|
+
* followers, the streamer's bio, and more. With `include_comments: true` the result also has the
|
|
784
|
+
* latest comments (up to 50), the pinned comment, the intro and the top viewers.
|
|
785
|
+
*
|
|
786
|
+
* The room has no likes, comment count or share count: TikTok gives those to LIVE search only.
|
|
787
|
+
* A room or account that does not exist throws `NotFoundError` (`error_code` `live_not_found`)
|
|
788
|
+
* and is not billed. Billing: 1 `residential_request`, 2 with `include_comments`.
|
|
789
|
+
*/
|
|
790
|
+
async getTikTokLiveRoom(payload: TikTokLiveRoomRequest): Promise<TikTokLiveRoomResult> {
|
|
791
|
+
const targets = (['room_id', 'username', 'url'] as const).filter((key) => payload?.[key]);
|
|
792
|
+
if (targets.length !== 1) {
|
|
793
|
+
throw new VidNavigatorError('Pass exactly one of room_id, username or url');
|
|
794
|
+
}
|
|
795
|
+
let body: TikTokLiveRoomRequest = payload;
|
|
796
|
+
const roomId: unknown = payload.room_id;
|
|
797
|
+
if (typeof roomId === 'number') {
|
|
798
|
+
if (!Number.isSafeInteger(roomId)) {
|
|
799
|
+
throw new VidNavigatorError(
|
|
800
|
+
'room_id has more digits than a JavaScript number holds: pass it as a string'
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
body = { ...payload, room_id: String(roomId) };
|
|
804
|
+
}
|
|
805
|
+
const response = await this.request<ApiSuccessResponse<TikTokLiveRoomResultJSON>>(
|
|
806
|
+
'POST',
|
|
807
|
+
'/tiktok/live/room',
|
|
808
|
+
body,
|
|
809
|
+
undefined,
|
|
810
|
+
undefined,
|
|
811
|
+
LIVE_ROOM_TIMEOUT_MS
|
|
812
|
+
);
|
|
813
|
+
const result = tiktokLiveRoomResultFromJSON(response.data);
|
|
814
|
+
if (response.usage) result.usage = UsageBlock.fromJSON(response.usage);
|
|
815
|
+
return result;
|
|
816
|
+
}
|
|
754
817
|
//endregion
|
|
755
818
|
|
|
756
819
|
//region --- Files ---
|
package/src/models/TikTok.ts
CHANGED
|
@@ -738,6 +738,185 @@ export class TikTokLiveRoom {
|
|
|
738
738
|
}
|
|
739
739
|
}
|
|
740
740
|
|
|
741
|
+
// --- LIVE room ---
|
|
742
|
+
|
|
743
|
+
/** Exactly one of `room_id`, `username` or `url`. */
|
|
744
|
+
export interface TikTokLiveRoomRequest {
|
|
745
|
+
/**
|
|
746
|
+
* A LIVE room ID, e.g. the `id` of a LIVE search room. Pass it as a string: room IDs have more
|
|
747
|
+
* digits than a JavaScript number holds.
|
|
748
|
+
*/
|
|
749
|
+
room_id?: string;
|
|
750
|
+
/** The streamer, with or without `@`: their current LIVE, or their last one when they are offline. */
|
|
751
|
+
username?: string;
|
|
752
|
+
/** `https://www.tiktok.com/@username/live`, the profile URL, or a room's `share_url`. */
|
|
753
|
+
url?: string;
|
|
754
|
+
/**
|
|
755
|
+
* Also return the latest comments (up to 50, newest first), the pinned comment, the intro and the
|
|
756
|
+
* top viewers. Bills 2 `residential_request` instead of 1. Default `false`.
|
|
757
|
+
*/
|
|
758
|
+
include_comments?: boolean;
|
|
759
|
+
/** At most this many comments, 1-50 (default 50). */
|
|
760
|
+
comments_limit?: number;
|
|
761
|
+
/** Playback URLs are returned by default; pass `false` to leave them out. */
|
|
762
|
+
include_stream_urls?: boolean;
|
|
763
|
+
/** Add the `usage` block to the result. */
|
|
764
|
+
include_usage?: boolean;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
export interface TikTokLiveRoomAuthor extends TikTokLiveAuthor {
|
|
768
|
+
bio?: string | null;
|
|
769
|
+
/** Accounts the streamer follows. */
|
|
770
|
+
following?: number | null;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/** A single room's counters. Likes, comments and shares come with LIVE search only. */
|
|
774
|
+
export interface TikTokLiveRoomStats {
|
|
775
|
+
/** Watching now (0 once the LIVE has ended). */
|
|
776
|
+
viewers?: number | null;
|
|
777
|
+
/** Since the LIVE started. */
|
|
778
|
+
total_viewers?: number | null;
|
|
779
|
+
/** Followers the streamer gained during this LIVE. */
|
|
780
|
+
new_followers?: number | null;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
export interface TikTokLiveRoomDetailJSON extends TikTokLiveRoomJSON {
|
|
784
|
+
author?: TikTokLiveRoomAuthor;
|
|
785
|
+
stats?: TikTokLiveRoomStats;
|
|
786
|
+
status?: 'live' | 'ended' | 'unknown';
|
|
787
|
+
ended_at?: string | null;
|
|
788
|
+
share_url?: string | null;
|
|
789
|
+
age_restricted?: boolean;
|
|
790
|
+
subscribers_only?: boolean;
|
|
791
|
+
chat_enabled?: boolean;
|
|
792
|
+
products?: number;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
/** One LIVE room, as `getTikTokLiveRoom` returns it. */
|
|
796
|
+
export class TikTokLiveRoomDetail extends TikTokLiveRoom {
|
|
797
|
+
declare author?: TikTokLiveRoomAuthor;
|
|
798
|
+
declare stats?: TikTokLiveRoomStats;
|
|
799
|
+
/** `'live'` while broadcasting, `'ended'` once finished. */
|
|
800
|
+
status?: 'live' | 'ended' | 'unknown';
|
|
801
|
+
ended_at?: Date | null;
|
|
802
|
+
/** The room's share link; it can be passed back as `url`. */
|
|
803
|
+
share_url?: string | null;
|
|
804
|
+
age_restricted?: boolean;
|
|
805
|
+
/** Only the streamer's paying subscribers can watch. */
|
|
806
|
+
subscribers_only?: boolean;
|
|
807
|
+
chat_enabled?: boolean;
|
|
808
|
+
/** Products on sale in the LIVE. */
|
|
809
|
+
products?: number;
|
|
810
|
+
|
|
811
|
+
constructor(data: TikTokLiveRoomDetailJSON) {
|
|
812
|
+
super(data);
|
|
813
|
+
this.author = data.author
|
|
814
|
+
? { ...data.author, followers: toInteger(data.author.followers), following: toInteger(data.author.following) }
|
|
815
|
+
: undefined;
|
|
816
|
+
this.stats = data.stats
|
|
817
|
+
? {
|
|
818
|
+
viewers: toInteger(data.stats.viewers),
|
|
819
|
+
total_viewers: toInteger(data.stats.total_viewers),
|
|
820
|
+
new_followers: toInteger(data.stats.new_followers),
|
|
821
|
+
}
|
|
822
|
+
: undefined;
|
|
823
|
+
this.status = data.status;
|
|
824
|
+
this.ended_at = toNullableDate(data.ended_at);
|
|
825
|
+
this.share_url = data.share_url;
|
|
826
|
+
this.age_restricted = data.age_restricted;
|
|
827
|
+
this.subscribers_only = data.subscribers_only;
|
|
828
|
+
this.chat_enabled = data.chat_enabled;
|
|
829
|
+
this.products = toOptionalInteger(data.products);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
get isLive(): boolean {
|
|
833
|
+
return this.status === 'live';
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
static fromJSON(json: TikTokLiveRoomDetailJSON): TikTokLiveRoomDetail {
|
|
837
|
+
return new TikTokLiveRoomDetail(json);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
export interface TikTokLiveCommentJSON {
|
|
842
|
+
id?: string | null;
|
|
843
|
+
text?: string | null;
|
|
844
|
+
language?: string | null;
|
|
845
|
+
created_at?: string | null;
|
|
846
|
+
author?: TikTokLiveAuthor;
|
|
847
|
+
author_is_follower?: boolean;
|
|
848
|
+
author_is_moderator?: boolean;
|
|
849
|
+
author_is_subscriber?: boolean;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/** A comment posted in a LIVE's chat. */
|
|
853
|
+
export interface TikTokLiveComment {
|
|
854
|
+
id?: string | null;
|
|
855
|
+
text?: string | null;
|
|
856
|
+
/** ISO 639-1 code TikTok detected, or `null`. */
|
|
857
|
+
language?: string | null;
|
|
858
|
+
created_at?: Date | null;
|
|
859
|
+
author?: TikTokLiveAuthor;
|
|
860
|
+
author_is_follower?: boolean;
|
|
861
|
+
author_is_moderator?: boolean;
|
|
862
|
+
/** A paying subscriber of the streamer. */
|
|
863
|
+
author_is_subscriber?: boolean;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/** One of a LIVE's top viewers, ranked by the gifts they sent. */
|
|
867
|
+
export interface TikTokLiveTopViewer {
|
|
868
|
+
rank?: number | null;
|
|
869
|
+
score?: number | null;
|
|
870
|
+
user?: TikTokLiveAuthor;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
export interface TikTokLiveRoomResultJSON {
|
|
874
|
+
room: TikTokLiveRoomDetailJSON;
|
|
875
|
+
comments?: TikTokLiveCommentJSON[];
|
|
876
|
+
pinned_comment?: TikTokLiveCommentJSON | null;
|
|
877
|
+
intro?: string | null;
|
|
878
|
+
top_viewers?: TikTokLiveTopViewer[];
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
export interface TikTokLiveRoomResult {
|
|
882
|
+
room: TikTokLiveRoomDetail;
|
|
883
|
+
/** Latest comments, newest first (TikTok keeps about the last 50). Only with `include_comments`. */
|
|
884
|
+
comments?: TikTokLiveComment[];
|
|
885
|
+
/** The comment the streamer pinned. Only with `include_comments`. */
|
|
886
|
+
pinned_comment?: TikTokLiveComment | null;
|
|
887
|
+
/** The LIVE's intro text. Only with `include_comments`. */
|
|
888
|
+
intro?: string | null;
|
|
889
|
+
/** Top viewers by gifts sent. Only with `include_comments`. */
|
|
890
|
+
top_viewers?: TikTokLiveTopViewer[];
|
|
891
|
+
/** Present when called with `include_usage: true`. */
|
|
892
|
+
usage?: UsageBlock;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
function liveCommentFromJSON(json: TikTokLiveCommentJSON): TikTokLiveComment {
|
|
896
|
+
return {
|
|
897
|
+
...json,
|
|
898
|
+
created_at: toNullableDate(json.created_at),
|
|
899
|
+
author: json.author ? { ...json.author, followers: toInteger(json.author.followers) } : undefined,
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
export function tiktokLiveRoomResultFromJSON(json: TikTokLiveRoomResultJSON): TikTokLiveRoomResult {
|
|
904
|
+
const result: TikTokLiveRoomResult = { room: TikTokLiveRoomDetail.fromJSON(json.room) };
|
|
905
|
+
if (json.comments !== undefined) result.comments = (json.comments ?? []).map(liveCommentFromJSON);
|
|
906
|
+
if (json.pinned_comment !== undefined) {
|
|
907
|
+
result.pinned_comment = json.pinned_comment ? liveCommentFromJSON(json.pinned_comment) : null;
|
|
908
|
+
}
|
|
909
|
+
if (json.intro !== undefined) result.intro = json.intro;
|
|
910
|
+
if (json.top_viewers !== undefined) {
|
|
911
|
+
result.top_viewers = (json.top_viewers ?? []).map((v) => ({
|
|
912
|
+
...v,
|
|
913
|
+
rank: toInteger(v.rank),
|
|
914
|
+
score: toInteger(v.score),
|
|
915
|
+
}));
|
|
916
|
+
}
|
|
917
|
+
return result;
|
|
918
|
+
}
|
|
919
|
+
|
|
741
920
|
export interface TikTokLiveSearchStats {
|
|
742
921
|
/** TikTok pages fetched (up to 50 rooms each). */
|
|
743
922
|
pages_fetched?: number;
|