vidnavigator 2.0.0 → 2.2.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 +45 -13
- package/dist/index.d.ts +18 -5
- package/dist/index.js +24 -5
- package/dist/models/AsyncJob.d.ts +5 -0
- package/dist/models/AsyncJob.js +2 -0
- package/dist/models/TikTok.d.ts +198 -0
- package/dist/models/TikTok.js +101 -2
- package/dist/webhooks.d.ts +4 -2
- package/package.json +39 -39
- package/src/index.ts +1135 -1082
- package/src/models/AsyncJob.ts +6 -0
- package/src/models/TikTok.ts +302 -1
- package/src/webhooks.ts +6 -2
package/dist/models/TikTok.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TikTokSearchTask = exports.TikTokProfileTask = exports.TikTokSearchResult = exports.TikTokVideo = exports.TikTokSearchSubmission = exports.TikTokProfileScrapeSubmission = void 0;
|
|
3
|
+
exports.TikTokLiveSearchTask = exports.TikTokLiveRoom = exports.TikTokLiveSearchSubmission = exports.TikTokSearchTask = exports.TikTokProfileTask = exports.TikTokSearchResult = exports.TikTokVideo = exports.TikTokSearchSubmission = exports.TikTokProfileScrapeSubmission = void 0;
|
|
4
4
|
function toInteger(value) {
|
|
5
5
|
if (value === null || value === undefined)
|
|
6
6
|
return value;
|
|
@@ -54,13 +54,25 @@ function normalizeStats(stats) {
|
|
|
54
54
|
function normalizeSearchStats(stats) {
|
|
55
55
|
if (!stats)
|
|
56
56
|
return undefined;
|
|
57
|
-
|
|
57
|
+
const normalized = {
|
|
58
58
|
pages_fetched: toOptionalInteger(stats.pages_fetched),
|
|
59
|
+
videos_fetched: toOptionalInteger(stats.videos_fetched),
|
|
59
60
|
results_count: toOptionalInteger(stats.results_count),
|
|
60
61
|
next_search_cursor: toInteger(stats.next_search_cursor),
|
|
62
|
+
parallel_search_slices: toOptionalInteger(stats.parallel_search_slices),
|
|
61
63
|
sort_by: stats.sort_by,
|
|
62
64
|
published_within: stats.published_within,
|
|
65
|
+
country: stats.country,
|
|
66
|
+
items_examined: toOptionalInteger(stats.items_examined),
|
|
67
|
+
items_filtered_out: toOptionalInteger(stats.items_filtered_out),
|
|
68
|
+
items_deduplicated: toOptionalInteger(stats.items_deduplicated),
|
|
63
69
|
};
|
|
70
|
+
// Leave out what the API did not send (the items_* counters are conditional).
|
|
71
|
+
for (const key of Object.keys(normalized)) {
|
|
72
|
+
if (normalized[key] === undefined)
|
|
73
|
+
delete normalized[key];
|
|
74
|
+
}
|
|
75
|
+
return normalized;
|
|
64
76
|
}
|
|
65
77
|
function normalizePagination(pagination) {
|
|
66
78
|
if (!pagination)
|
|
@@ -95,6 +107,7 @@ class TikTokSearchSubmission {
|
|
|
95
107
|
this.task_id = data.task_id;
|
|
96
108
|
this.task_status = data.task_status;
|
|
97
109
|
this.query = data.query;
|
|
110
|
+
this.country = data.country;
|
|
98
111
|
this.max_results = toOptionalInteger(data.max_results);
|
|
99
112
|
this.parallel_search_slices = toOptionalInteger(data.parallel_search_slices);
|
|
100
113
|
this.filters = data.filters;
|
|
@@ -190,6 +203,7 @@ class TikTokSearchTask {
|
|
|
190
203
|
this.task_id = data.task_id;
|
|
191
204
|
this.task_status = data.task_status;
|
|
192
205
|
this.query = data.query;
|
|
206
|
+
this.country = data.country;
|
|
193
207
|
this.parallel_search_slices = toOptionalInteger(data.parallel_search_slices);
|
|
194
208
|
this.filters = normalizeSearchFilters(data.filters);
|
|
195
209
|
this.stats = normalizeSearchStats(data.stats);
|
|
@@ -208,3 +222,88 @@ class TikTokSearchTask {
|
|
|
208
222
|
}
|
|
209
223
|
}
|
|
210
224
|
exports.TikTokSearchTask = TikTokSearchTask;
|
|
225
|
+
class TikTokLiveSearchSubmission {
|
|
226
|
+
constructor(data) {
|
|
227
|
+
this.task_id = data.task_id;
|
|
228
|
+
this.task_status = data.task_status;
|
|
229
|
+
this.query = data.query;
|
|
230
|
+
this.country = data.country;
|
|
231
|
+
this.max_results = toOptionalInteger(data.max_results);
|
|
232
|
+
this.include_stream_urls = data.include_stream_urls;
|
|
233
|
+
this.expires_at = data.expires_at;
|
|
234
|
+
this.check_status_url = data.check_status_url;
|
|
235
|
+
this.message = data.message;
|
|
236
|
+
this.webhook_url = data.webhook_url;
|
|
237
|
+
}
|
|
238
|
+
static fromJSON(json) {
|
|
239
|
+
return new TikTokLiveSearchSubmission(json);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
exports.TikTokLiveSearchSubmission = TikTokLiveSearchSubmission;
|
|
243
|
+
/** A TikTok LIVE room that was broadcasting when the search ran. */
|
|
244
|
+
class TikTokLiveRoom {
|
|
245
|
+
constructor(data) {
|
|
246
|
+
this.id = data.id;
|
|
247
|
+
this.title = data.title;
|
|
248
|
+
this.url = data.url;
|
|
249
|
+
this.started_at = toNullableDate(data.started_at);
|
|
250
|
+
this.author = data.author
|
|
251
|
+
? { ...data.author, followers: toInteger(data.author.followers) }
|
|
252
|
+
: undefined;
|
|
253
|
+
this.stats = data.stats
|
|
254
|
+
? {
|
|
255
|
+
viewers: toInteger(data.stats.viewers),
|
|
256
|
+
total_viewers: toInteger(data.stats.total_viewers),
|
|
257
|
+
likes: toInteger(data.stats.likes),
|
|
258
|
+
comments: toInteger(data.stats.comments),
|
|
259
|
+
shares: toInteger(data.stats.shares),
|
|
260
|
+
}
|
|
261
|
+
: undefined;
|
|
262
|
+
this.hashtags = data.hashtags ?? [];
|
|
263
|
+
this.category = data.category;
|
|
264
|
+
this.game_tags = data.game_tags ?? [];
|
|
265
|
+
this.cover_url = data.cover_url;
|
|
266
|
+
if (data.stream_urls) {
|
|
267
|
+
this.stream_urls = {
|
|
268
|
+
default_quality: data.stream_urls.default_quality ?? null,
|
|
269
|
+
flv: data.stream_urls.flv ?? {},
|
|
270
|
+
hls: data.stream_urls.hls ?? {},
|
|
271
|
+
audio_only: data.stream_urls.audio_only ?? null,
|
|
272
|
+
expires_at: toNullableDate(data.stream_urls.expires_at) ?? null,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
static fromJSON(json) {
|
|
277
|
+
return new TikTokLiveRoom(json);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
exports.TikTokLiveRoom = TikTokLiveRoom;
|
|
281
|
+
class TikTokLiveSearchTask {
|
|
282
|
+
constructor(data) {
|
|
283
|
+
this.task_id = data.task_id;
|
|
284
|
+
this.task_status = data.task_status;
|
|
285
|
+
this.query = data.query;
|
|
286
|
+
this.country = data.country;
|
|
287
|
+
this.stats = data.stats
|
|
288
|
+
? {
|
|
289
|
+
...data.stats,
|
|
290
|
+
pages_fetched: toOptionalInteger(data.stats.pages_fetched),
|
|
291
|
+
rooms_fetched: toOptionalInteger(data.stats.rooms_fetched),
|
|
292
|
+
results_count: toOptionalInteger(data.stats.results_count),
|
|
293
|
+
}
|
|
294
|
+
: undefined;
|
|
295
|
+
this.results = data.results?.map(TikTokLiveRoom.fromJSON) ?? [];
|
|
296
|
+
this.pagination = normalizePagination(data.pagination);
|
|
297
|
+
this.download_url = data.download_url;
|
|
298
|
+
this.error_message = data.error_message;
|
|
299
|
+
this.created_at = data.created_at;
|
|
300
|
+
this.completed_at = data.completed_at;
|
|
301
|
+
this.expires_at = data.expires_at;
|
|
302
|
+
this.error = data.error ?? null;
|
|
303
|
+
this.webhook = data.webhook;
|
|
304
|
+
}
|
|
305
|
+
static fromJSON(json) {
|
|
306
|
+
return new TikTokLiveSearchTask(json);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
exports.TikTokLiveSearchTask = TikTokLiveSearchTask;
|
package/dist/webhooks.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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' | 'extract_video.completed' | 'extract_video.failed' | 'tweet_statement.completed' | 'tweet_statement.failed' | 'tiktok_profile.completed' | 'tiktok_profile.failed' | 'tiktok_search.completed' | 'tiktok_search.failed';
|
|
4
|
-
/** `data.result` of a `tiktok_profile.*` / `tiktok_search.*` event: a summary, not the
|
|
3
|
+
export type WebhookEventType = 'transcribe.completed' | 'transcribe.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
|
+
/** `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). */
|
|
7
7
|
stats?: Record<string, unknown>;
|
|
@@ -29,6 +29,8 @@ export interface WebhookEvent {
|
|
|
29
29
|
result?: Record<string, unknown> | TikTokWebhookResult | null;
|
|
30
30
|
/** True when the result exceeded 256 KB; fetch it with `resume(task_id).result()` instead. */
|
|
31
31
|
result_truncated?: boolean;
|
|
32
|
+
/** `extract_video.completed` only: raw `video_info` of the video. Sent even when `result_truncated` is true. */
|
|
33
|
+
video_info?: Record<string, unknown>;
|
|
32
34
|
error?: AsyncJobError | null;
|
|
33
35
|
};
|
|
34
36
|
}
|
package/package.json
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vidnavigator",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "Official JavaScript SDK for the VidNavigator Developer API",
|
|
5
|
-
"author": "VidNavigator",
|
|
6
|
-
"license": "Apache-2.0",
|
|
7
|
-
"homepage": "https://vidnavigator.com",
|
|
8
|
-
"main": "dist/index.js",
|
|
9
|
-
"types": "dist/index.d.ts",
|
|
10
|
-
"files": [
|
|
11
|
-
"dist",
|
|
12
|
-
"src"
|
|
13
|
-
],
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsc",
|
|
16
|
-
"prepublishOnly": "npm run build"
|
|
17
|
-
},
|
|
18
|
-
"repository": {
|
|
19
|
-
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/vidnavigator/vidnavigator-js.git"
|
|
21
|
-
},
|
|
22
|
-
"keywords": [
|
|
23
|
-
"vidnavigator",
|
|
24
|
-
"sdk",
|
|
25
|
-
"api",
|
|
26
|
-
"video",
|
|
27
|
-
"transcription",
|
|
28
|
-
"analysis"
|
|
29
|
-
],
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"axios": "^1.6.0",
|
|
32
|
-
"form-data": "^4.0.0"
|
|
33
|
-
},
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"@types/node": "^20.4.2",
|
|
36
|
-
"typescript": "^5.1.3",
|
|
37
|
-
"@types/form-data": "^2.5.0"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "vidnavigator",
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"description": "Official JavaScript SDK for the VidNavigator Developer API",
|
|
5
|
+
"author": "VidNavigator",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"homepage": "https://vidnavigator.com",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"src"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/vidnavigator/vidnavigator-js.git"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"vidnavigator",
|
|
24
|
+
"sdk",
|
|
25
|
+
"api",
|
|
26
|
+
"video",
|
|
27
|
+
"transcription",
|
|
28
|
+
"analysis"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"axios": "^1.6.0",
|
|
32
|
+
"form-data": "^4.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^20.4.2",
|
|
36
|
+
"typescript": "^5.1.3",
|
|
37
|
+
"@types/form-data": "^2.5.0"
|
|
38
|
+
}
|
|
39
|
+
}
|