Merge pull request #57 from isereb/feat/user-stalk-stats-v2
feat: adding statsV2
This commit is contained in:
commit
c11772d092
@ -4,6 +4,7 @@ export type TiktokStalkUserResponse = {
|
||||
result?: {
|
||||
user: UserProfile
|
||||
stats: StatsUserProfile
|
||||
statsV2: StatsV2UserProfile
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,6 +34,16 @@ export type StatsUserProfile = {
|
||||
friendCount: number
|
||||
}
|
||||
|
||||
|
||||
export type StatsV2UserProfile = {
|
||||
followerCount: string
|
||||
followingCount: string
|
||||
heartCount: string
|
||||
videoCount: string
|
||||
likeCount: string
|
||||
friendCount: string
|
||||
}
|
||||
|
||||
export type StatisticsUserProfile = {
|
||||
likeCount: number
|
||||
shareCount: number
|
||||
|
||||
@ -8,7 +8,7 @@ import {
|
||||
import {
|
||||
TiktokStalkUserResponse,
|
||||
StatsUserProfile,
|
||||
UserProfile
|
||||
UserProfile, StatsV2UserProfile
|
||||
} from "../../types/get/getProfile"
|
||||
import { _getUserPostsParams, _xttParams } from "../../constants/params"
|
||||
import { HttpsProxyAgent } from "https-proxy-agent"
|
||||
@ -66,13 +66,14 @@ export const StalkUser = (
|
||||
})
|
||||
}
|
||||
|
||||
const { user, stats } = parseDataUser(dataUser)
|
||||
const { user, stats, statsV2 } = parseDataUser(dataUser)
|
||||
|
||||
let response: TiktokStalkUserResponse = {
|
||||
status: "success",
|
||||
result: {
|
||||
user,
|
||||
stats
|
||||
stats,
|
||||
statsV2
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,5 +111,15 @@ const parseDataUser = (dataUser: any) => {
|
||||
friendCount: dataUser.stats.friendCount
|
||||
}
|
||||
|
||||
return { user, stats }
|
||||
// Statistics V2 Result
|
||||
const statsV2: StatsV2UserProfile = {
|
||||
followerCount: dataUser.statsV2.followerCount,
|
||||
followingCount: dataUser.statsV2.followingCount,
|
||||
heartCount: dataUser.statsV2.heartCount,
|
||||
videoCount: dataUser.statsV2.videoCount,
|
||||
likeCount: dataUser.statsV2.diggCount,
|
||||
friendCount: dataUser.statsV2.friendCount
|
||||
}
|
||||
|
||||
return { user, stats, statsV2 }
|
||||
}
|
||||
|
||||
@ -3,13 +3,12 @@ import Tiktok from "../src/index"
|
||||
|
||||
async function testProfile() {
|
||||
try {
|
||||
const username = "tobz2k19" // Change to a valid TikTok username
|
||||
const username = "charlidamelio" // Change to a valid TikTok username
|
||||
const result = await Tiktok.StalkUser(username, {
|
||||
proxy: undefined
|
||||
})
|
||||
if (result.status === "success" && result.result) {
|
||||
const user = result.result.user
|
||||
const stats = result.result.stats
|
||||
const { user, stats, statsV2 } = result.result
|
||||
console.log("\nProfile fetched successfully!")
|
||||
console.log("========================")
|
||||
console.log("User Profile:")
|
||||
@ -30,6 +29,14 @@ async function testProfile() {
|
||||
console.log(`- Likes: ${stats.likeCount}`)
|
||||
console.log(`- Friends: ${stats.friendCount}`)
|
||||
console.log("========================")
|
||||
console.log("\nStats V2:")
|
||||
console.log(`- Followers: ${statsV2.followerCount}`)
|
||||
console.log(`- Following: ${statsV2.followingCount}`)
|
||||
console.log(`- Hearts: ${statsV2.heartCount}`)
|
||||
console.log(`- Videos: ${statsV2.videoCount}`)
|
||||
console.log(`- Likes: ${statsV2.likeCount}`)
|
||||
console.log(`- Friends: ${statsV2.friendCount}`)
|
||||
console.log("========================")
|
||||
} else {
|
||||
console.error("Error:", result.message)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user