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?: {
|
result?: {
|
||||||
user: UserProfile
|
user: UserProfile
|
||||||
stats: StatsUserProfile
|
stats: StatsUserProfile
|
||||||
|
statsV2: StatsV2UserProfile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,6 +34,16 @@ export type StatsUserProfile = {
|
|||||||
friendCount: number
|
friendCount: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export type StatsV2UserProfile = {
|
||||||
|
followerCount: string
|
||||||
|
followingCount: string
|
||||||
|
heartCount: string
|
||||||
|
videoCount: string
|
||||||
|
likeCount: string
|
||||||
|
friendCount: string
|
||||||
|
}
|
||||||
|
|
||||||
export type StatisticsUserProfile = {
|
export type StatisticsUserProfile = {
|
||||||
likeCount: number
|
likeCount: number
|
||||||
shareCount: number
|
shareCount: number
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
TiktokStalkUserResponse,
|
TiktokStalkUserResponse,
|
||||||
StatsUserProfile,
|
StatsUserProfile,
|
||||||
UserProfile
|
UserProfile, StatsV2UserProfile
|
||||||
} from "../../types/get/getProfile"
|
} from "../../types/get/getProfile"
|
||||||
import { _getUserPostsParams, _xttParams } from "../../constants/params"
|
import { _getUserPostsParams, _xttParams } from "../../constants/params"
|
||||||
import { HttpsProxyAgent } from "https-proxy-agent"
|
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 = {
|
let response: TiktokStalkUserResponse = {
|
||||||
status: "success",
|
status: "success",
|
||||||
result: {
|
result: {
|
||||||
user,
|
user,
|
||||||
stats
|
stats,
|
||||||
|
statsV2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,5 +111,15 @@ const parseDataUser = (dataUser: any) => {
|
|||||||
friendCount: dataUser.stats.friendCount
|
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() {
|
async function testProfile() {
|
||||||
try {
|
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, {
|
const result = await Tiktok.StalkUser(username, {
|
||||||
proxy: undefined
|
proxy: undefined
|
||||||
})
|
})
|
||||||
if (result.status === "success" && result.result) {
|
if (result.status === "success" && result.result) {
|
||||||
const user = result.result.user
|
const { user, stats, statsV2 } = result.result
|
||||||
const stats = result.result.stats
|
|
||||||
console.log("\nProfile fetched successfully!")
|
console.log("\nProfile fetched successfully!")
|
||||||
console.log("========================")
|
console.log("========================")
|
||||||
console.log("User Profile:")
|
console.log("User Profile:")
|
||||||
@ -30,6 +29,14 @@ async function testProfile() {
|
|||||||
console.log(`- Likes: ${stats.likeCount}`)
|
console.log(`- Likes: ${stats.likeCount}`)
|
||||||
console.log(`- Friends: ${stats.friendCount}`)
|
console.log(`- Friends: ${stats.friendCount}`)
|
||||||
console.log("========================")
|
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 {
|
} else {
|
||||||
console.error("Error:", result.message)
|
console.error("Error:", result.message)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user