@tobyg74/tiktok-api-dl
Advanced tools
Comparing version 1.0.11 to 1.0.12
export * from "./utils/switch"; | ||
export * from "./utils/tiktok_stalker"; |
@@ -18,1 +18,2 @@ "use strict"; | ||
__exportStar(require("./utils/switch"), exports); | ||
__exportStar(require("./utils/tiktok_stalker"), exports); |
@@ -7,3 +7,2 @@ export interface StalkResult { | ||
stats: Stats; | ||
posts: Posts[]; | ||
}; | ||
@@ -32,15 +31,3 @@ } | ||
friendCount: number; | ||
postCount: number; | ||
} | ||
export interface Posts { | ||
id: string; | ||
desc: string; | ||
createTime: number; | ||
author: string; | ||
locationCreated: string; | ||
hashtags: string[]; | ||
statistics: Statistics; | ||
video: Video; | ||
music: Music; | ||
} | ||
export interface Statistics { | ||
@@ -47,0 +34,0 @@ likeCount: number; |
@@ -6,2 +6,2 @@ import { MusicalDownResponse } from "../types/musicaldown"; | ||
version: "v1" | "v2" | "v3"; | ||
}) => Promise<MusicalDownResponse | SSSTikResponse | TiktokAPIResponse>; | ||
}) => Promise<TiktokAPIResponse | SSSTikResponse | MusicalDownResponse>; |
@@ -10,12 +10,20 @@ "use strict"; | ||
case "v1": { | ||
await (0, downloader_tiktokApi_1.TiktokAPI)(url).then(resolve).catch(reject); | ||
const response = await (0, downloader_tiktokApi_1.TiktokAPI)(url); | ||
resolve(response); | ||
break; | ||
} | ||
case "v2": { | ||
await (0, downloader_ssstik_1.SSSTik)(url).then(resolve).catch(reject); | ||
const response = await (0, downloader_ssstik_1.SSSTik)(url); | ||
resolve(response); | ||
break; | ||
} | ||
case "v3": { | ||
await (0, downloader_musicaldown_1.MusicalDown)(url).then(resolve).catch(reject); | ||
const response = await (0, downloader_musicaldown_1.MusicalDown)(url); | ||
resolve(response); | ||
break; | ||
} | ||
default: { | ||
await (0, downloader_tiktokApi_1.TiktokAPI)(url).then(resolve).catch(reject); | ||
const response = await (0, downloader_tiktokApi_1.TiktokAPI)(url); | ||
resolve(response); | ||
break; | ||
} | ||
@@ -22,0 +30,0 @@ } |
@@ -10,2 +10,3 @@ "use strict"; | ||
const api_1 = require("../api"); | ||
const fs_1 = __importDefault(require("fs")); | ||
const getCookie = () => new Promise((resolve, reject) => { | ||
@@ -29,5 +30,6 @@ axios_1.default | ||
.then(({ data }) => { | ||
fs_1.default.writeFileSync("data.html", data); | ||
const $ = (0, cheerio_1.load)(data); | ||
const result = JSON.parse($("script#SIGI_STATE").text()); | ||
if (!result.UserModule) { | ||
const result = JSON.parse($("script#__UNIVERSAL_DATA_FOR_REHYDRATION__").text()); | ||
if (!result?.__DEFAULT_SCOPE__?.["webapp.user-detail"]) { | ||
return resolve({ | ||
@@ -38,82 +40,25 @@ status: "error", | ||
} | ||
const user = result.UserModule; | ||
const itemKeys = Object.keys(result.ItemModule); | ||
const dataUser = result.__DEFAULT_SCOPE__["webapp.user-detail"].userInfo; | ||
const users = { | ||
username: user.users[username].uniqueId, | ||
nickname: user.users[username].nickname, | ||
avatarLarger: user.users[username].avatarLarger, | ||
avatarThumb: user.users[username].avatarThumb, | ||
avatarMedium: user.users[username].avatarMedium, | ||
signature: user.users[username].signature, | ||
verified: user.users[username].verified, | ||
privateAccount: user.users[username].privateAccount, | ||
region: user.users[username].region, | ||
commerceUser: user.users[username].commerceUserInfo.commerceUser, | ||
usernameModifyTime: user.users[username].uniqueIdModifyTime, | ||
nicknameModifyTime: user.users[username].nickNameModifyTime | ||
username: dataUser.user.uniqueId, | ||
nickname: dataUser.user.nickname, | ||
avatarLarger: dataUser.user.avatarLarger, | ||
avatarThumb: dataUser.user.avatarThumb, | ||
avatarMedium: dataUser.user.avatarMedium, | ||
signature: dataUser.user.signature, | ||
verified: dataUser.user.verified, | ||
privateAccount: dataUser.user.privateAccount, | ||
region: dataUser.user.region, | ||
commerceUser: dataUser.user.commerceUserInfo.commerceUser, | ||
usernameModifyTime: dataUser.user.uniqueIdModifyTime, | ||
nicknameModifyTime: dataUser.user.nickNameModifyTime | ||
}; | ||
const stats = { | ||
followerCount: user.stats[username].followerCount, | ||
followingCount: user.stats[username].followingCount, | ||
heartCount: user.stats[username].heartCount, | ||
videoCount: user.stats[username].videoCount, | ||
likeCount: user.stats[username].diggCount, | ||
friendCount: user.stats[username].friendCount, | ||
postCount: itemKeys.length | ||
followerCount: dataUser.stats.followerCount, | ||
followingCount: dataUser.stats.followingCount, | ||
heartCount: dataUser.stats.heartCount, | ||
videoCount: dataUser.stats.videoCount, | ||
likeCount: dataUser.stats.diggCount, | ||
friendCount: dataUser.stats.friendCount | ||
}; | ||
const posts = []; | ||
itemKeys.forEach((key) => { | ||
const post = result.ItemModule[key]; | ||
let media; | ||
if (post.imagePost) { | ||
media = { | ||
images: post.imagePost.images.map((v) => v.imageURL.urlList[0]) | ||
}; | ||
} | ||
else { | ||
media = { | ||
video: { | ||
id: post.video.id, | ||
duration: post.video.duration, | ||
ratio: post.video.ratio, | ||
cover: post.video.cover, | ||
originCover: post.video.originCover, | ||
dynamicCover: post.video.dynamicCover, | ||
playAddr: post.video.playAddr, | ||
downloadAddr: post.video.downloadAddr, | ||
format: post.video.format, | ||
bitrate: post.video.bitrate | ||
} | ||
}; | ||
} | ||
const music = { | ||
id: post.music.id, | ||
title: post.music.title, | ||
authorName: post.music.authorName, | ||
album: post.music.album, | ||
coverLarge: post.music.coverLarge, | ||
coverMedium: post.music.coverMedium, | ||
coverThumb: post.music.coverThumb, | ||
playUrl: post.music.playUrl, | ||
duration: post.music.duration | ||
}; | ||
const statistics = { | ||
likeCount: post.stats.diggCount, | ||
shareCount: post.stats.shareCount, | ||
commentCount: post.stats.commentCount, | ||
playCount: post.stats.playCount, | ||
favoriteCount: post.stats.collectCount | ||
}; | ||
posts.push({ | ||
id: post.id, | ||
desc: post.desc, | ||
createTime: post.createTime, | ||
author: post.author, | ||
locationCreated: post.locationCreated, | ||
hashtags: post.challenges.map((v) => v.title), | ||
statistics, | ||
music, | ||
...media | ||
}); | ||
}); | ||
resolve({ | ||
@@ -123,4 +68,3 @@ status: "success", | ||
users, | ||
stats, | ||
posts | ||
stats | ||
} | ||
@@ -127,0 +71,0 @@ }); |
{ | ||
"name": "@tobyg74/tiktok-api-dl", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "Scraper for downloading media in the form of videos, images and audio from Tiktok. Also for stalking Tiktok Users", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -21,2 +21,3 @@ <h1 align="center"> | ||
- [Description](#description) | ||
- [How to get Tiktok Cookie](#how-to-get-tiktok-cookie) | ||
- [Install](#install) | ||
@@ -41,2 +42,11 @@ - [From NPM](#from-npm) | ||
# How to get Tiktok Cookie | ||
(If the Default Cookie Has Expired) | ||
- Login at [Tiktok](https://www.tiktok.com/) | ||
- When you have finished logging in, you can press CTRL + SHIFT + I or Right Click and select Inspect | ||
- Go to the Console section then type <b>document.cookie<b> | ||
- Then Copy Paste your Cookie and Use it for TiktokStalk | ||
# Install | ||
@@ -43,0 +53,0 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
272
0
32066
700
1