feat: adding some test files
This commit is contained in:
parent
c7af8d53a9
commit
4f7cd9f083
@ -1,14 +1,15 @@
|
||||
import { Collection } from "../src/utils/downloader/tiktokApi"
|
||||
import Tiktok from "../src/index"
|
||||
|
||||
async function testCollection() {
|
||||
try {
|
||||
// You can use either a collection ID or URL
|
||||
const collectionId = "7507916135931218695"
|
||||
const collectionUrl = "https://www.tiktok.com/@getrex.co.nz/collection/big%20back-7507916135931218695"
|
||||
const collectionUrl =
|
||||
"https://www.tiktok.com/@getrex.co.nz/collection/big%20back-7507916135931218695"
|
||||
const collectionShareableLink = "https://vt.tiktok.com/ZShvmqNjQ/"
|
||||
|
||||
console.log("Testing Collection method...")
|
||||
const result = await Collection(collectionId, {
|
||||
const result = await Tiktok.Collection(collectionId, {
|
||||
page: 1,
|
||||
count: 5, // Optional: Number of items to fetch
|
||||
proxy: undefined // Optional: Add your proxy if needed
|
||||
@ -29,7 +30,9 @@ async function testCollection() {
|
||||
console.log(`ID: ${item.id}`)
|
||||
console.log(`Description: ${item.desc}`)
|
||||
console.log(`Author: ${item.author.nickname}`)
|
||||
console.log(`Created: ${new Date(item.createTime * 1000).toLocaleString()}`)
|
||||
console.log(
|
||||
`Created: ${new Date(item.createTime * 1000).toLocaleString()}`
|
||||
)
|
||||
|
||||
// Log video URL
|
||||
if (item.video?.playAddr?.[0]) {
|
||||
@ -50,7 +53,7 @@ async function testCollection() {
|
||||
// Log hashtags if available
|
||||
if (item.textExtra?.length > 0) {
|
||||
console.log("\nHashtags:")
|
||||
item.textExtra.forEach(tag => {
|
||||
item.textExtra.forEach((tag) => {
|
||||
if (tag.hashtagName) {
|
||||
console.log(`- #${tag.hashtagName}`)
|
||||
}
|
||||
|
||||
54
test/comments-test.ts
Normal file
54
test/comments-test.ts
Normal file
@ -0,0 +1,54 @@
|
||||
// Test for Tiktok Video Comments
|
||||
import Tiktok from "../src/index"
|
||||
|
||||
async function testComments() {
|
||||
try {
|
||||
const url = "https://www.tiktok.com/@tobz2k19/video/7451777267107187986" // Change to a valid TikTok video URL
|
||||
const result = await Tiktok.GetVideoComments(url, {
|
||||
commentLimit: 10,
|
||||
proxy: undefined
|
||||
})
|
||||
if (result.status === "success" && result.result) {
|
||||
console.log("\nComments fetched successfully!")
|
||||
console.log("========================")
|
||||
console.log("Comments Overview:")
|
||||
console.log("========================")
|
||||
console.log(`Total comments fetched: ${result.result.length}`)
|
||||
// Log all comments
|
||||
result.result.forEach((comment, index) => {
|
||||
console.log(`\nComment ${index + 1}:`)
|
||||
console.log("-------------------")
|
||||
console.log(`ID: ${comment.cid}`)
|
||||
if (comment.user) {
|
||||
console.log(
|
||||
`Author: ${comment.user.nickname} (@${comment.user.username})`
|
||||
)
|
||||
console.log(`Verified: ${comment.user.isVerified ? "Yes" : "No"}`)
|
||||
}
|
||||
console.log(`Text: ${comment.text}`)
|
||||
if (comment.createTime) {
|
||||
console.log(
|
||||
`Created: ${new Date(comment.createTime * 1000).toLocaleString()}`
|
||||
)
|
||||
}
|
||||
// Log comment statistics
|
||||
if (typeof comment.likeCount !== "undefined") {
|
||||
console.log("\nStatistics:")
|
||||
console.log(`- Likes: ${comment.likeCount}`)
|
||||
}
|
||||
if (typeof comment.replyCommentTotal !== "undefined") {
|
||||
console.log(`- Replies: ${comment.replyCommentTotal}`)
|
||||
}
|
||||
if (comment.isAuthorLiked) console.log("👍 Liked by author")
|
||||
if (comment.isCommentTranslatable) console.log("🌐 Translatable")
|
||||
console.log("========================")
|
||||
})
|
||||
} else {
|
||||
console.error("Error:", result.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Test failed:", error)
|
||||
}
|
||||
}
|
||||
|
||||
testComments()
|
||||
49
test/downloader-v1-test.ts
Normal file
49
test/downloader-v1-test.ts
Normal file
@ -0,0 +1,49 @@
|
||||
// Test for Tiktok Downloader v1
|
||||
import Tiktok from "../src/index"
|
||||
|
||||
async function testDownloaderV1() {
|
||||
try {
|
||||
const url = "https://www.tiktok.com/@tobz2k19/video/7451777267107187986" // Change to a valid TikTok video URL
|
||||
console.log(`\nTesting Downloader version: v1`)
|
||||
const result = await Tiktok.Downloader(url, {
|
||||
version: "v1",
|
||||
proxy: undefined
|
||||
})
|
||||
if (result.status === "success" && result.result) {
|
||||
const r = result.result
|
||||
console.log(`Type: ${r.type}`)
|
||||
console.log(`ID: ${r.id}`)
|
||||
console.log(`Description: ${r.desc}`)
|
||||
if (r.author) {
|
||||
console.log(`Author: ${r.author.nickname}`)
|
||||
}
|
||||
if (r.statistics) {
|
||||
console.log("Statistics:")
|
||||
console.log(`- Likes: ${r.statistics.likeCount}`)
|
||||
console.log(`- Comments: ${r.statistics.commentCount}`)
|
||||
console.log(`- Shares: ${r.statistics.shareCount}`)
|
||||
console.log(`- Plays: ${r.statistics.playCount}`)
|
||||
}
|
||||
if (r.video?.playAddr?.length) {
|
||||
console.log(`Video URL: ${r.video.playAddr[0]}`)
|
||||
}
|
||||
if (r.images?.length) {
|
||||
console.log(`Images: ${r.images.join(", ")}`)
|
||||
}
|
||||
if (r.music) {
|
||||
console.log(`Music:`)
|
||||
console.log(`- Title: ${r.music.title}`)
|
||||
if (r.music.playUrl?.length) {
|
||||
console.log(`- Music URL: ${r.music.playUrl[0]}`)
|
||||
}
|
||||
}
|
||||
console.log("========================")
|
||||
} else {
|
||||
console.error("Error:", result.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Test failed:", error)
|
||||
}
|
||||
}
|
||||
|
||||
testDownloaderV1()
|
||||
47
test/downloader-v2-test.ts
Normal file
47
test/downloader-v2-test.ts
Normal file
@ -0,0 +1,47 @@
|
||||
// Test for Tiktok Downloader v2
|
||||
import Tiktok from "../src/index"
|
||||
|
||||
async function testDownloaderV2() {
|
||||
try {
|
||||
const url = "https://www.tiktok.com/@tobz2k19/video/7451777267107187986" // Change to a valid TikTok video URL
|
||||
console.log(`\nTesting Downloader version: v2`)
|
||||
const result = await Tiktok.Downloader(url, {
|
||||
version: "v2",
|
||||
proxy: undefined
|
||||
})
|
||||
if (result.status === "success" && result.result) {
|
||||
const r = result.result
|
||||
console.log(`Type: ${r.type}`)
|
||||
if (r.desc) console.log(`Description: ${r.desc}`)
|
||||
if (r.author && r.author.nickname) {
|
||||
console.log(`Author: ${r.author.nickname}`)
|
||||
} else if (r.author && r.author.avatar) {
|
||||
// fallback for v2 author structure
|
||||
console.log(`Author Avatar: ${r.author.avatar}`)
|
||||
}
|
||||
if (r.statistics) {
|
||||
console.log("Statistics:")
|
||||
if (r.statistics.likeCount !== undefined)
|
||||
console.log(`- Likes: ${r.statistics.likeCount}`)
|
||||
if (r.statistics.commentCount !== undefined)
|
||||
console.log(`- Comments: ${r.statistics.commentCount}`)
|
||||
if (r.statistics.shareCount !== undefined)
|
||||
console.log(`- Shares: ${r.statistics.shareCount}`)
|
||||
}
|
||||
if (r.video?.playAddr?.length) {
|
||||
console.log(`Video URL: ${r.video.playAddr[0]}`)
|
||||
}
|
||||
if (r.music?.playUrl?.length) {
|
||||
console.log(`Music URL: ${r.music.playUrl[0]}`)
|
||||
}
|
||||
if (r.images?.length) console.log(`Images: ${r.images.join(", ")}`)
|
||||
console.log("========================")
|
||||
} else {
|
||||
console.error("Error:", result.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Test failed:", error)
|
||||
}
|
||||
}
|
||||
|
||||
testDownloaderV2()
|
||||
35
test/downloader-v3-test.ts
Normal file
35
test/downloader-v3-test.ts
Normal file
@ -0,0 +1,35 @@
|
||||
// Test for Tiktok Downloader v3
|
||||
import Tiktok from "../src/index"
|
||||
|
||||
async function testDownloaderV3() {
|
||||
try {
|
||||
const url = "https://www.tiktok.com/@tobz2k19/video/7451777267107187986" // Change to a valid TikTok video URL
|
||||
console.log(`\nTesting Downloader version: v3`)
|
||||
const result = await Tiktok.Downloader(url, {
|
||||
version: "v3",
|
||||
proxy: undefined
|
||||
})
|
||||
if (result.status === "success" && result.result) {
|
||||
const r = result.result
|
||||
console.log(`Type: ${r.type}`)
|
||||
if (r.desc) console.log(`Description: ${r.desc}`)
|
||||
if (r.author && r.author.nickname) {
|
||||
console.log(`Author: ${r.author.nickname}`)
|
||||
} else if (r.author && r.author.avatar) {
|
||||
// fallback for v3 author structure
|
||||
console.log(`Author Avatar: ${r.author.avatar}`)
|
||||
}
|
||||
if (r.videoHD) console.log(`Video HD: ${r.videoHD}`)
|
||||
if (r.videoWatermark) console.log(`Video Watermark: ${r.videoWatermark}`)
|
||||
if (r.images?.length) console.log(`Images: ${r.images.join(", ")}`)
|
||||
if (r.music) console.log(`Music: ${r.music}`)
|
||||
console.log("========================")
|
||||
} else {
|
||||
console.error("Error:", result.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Test failed:", error)
|
||||
}
|
||||
}
|
||||
|
||||
testDownloaderV3()
|
||||
48
test/playlist-test.ts
Normal file
48
test/playlist-test.ts
Normal file
@ -0,0 +1,48 @@
|
||||
// Test for Tiktok Playlist
|
||||
import Tiktok from "../src/index"
|
||||
|
||||
async function testPlaylist() {
|
||||
try {
|
||||
const playlistUrl =
|
||||
"https://www.tiktok.com/@tobz2k19/playlist/tset-7511644672511626004" // Ganti dengan URL playlist yang valid jika perlu
|
||||
console.log(`\nTesting Playlist: ${playlistUrl}`)
|
||||
const result = await Tiktok.Playlist(playlistUrl, {
|
||||
proxy: undefined,
|
||||
page: 1,
|
||||
count: 5
|
||||
})
|
||||
if (result.status === "success" && result.result) {
|
||||
const { itemList, hasMore, extra } = result.result
|
||||
console.log(`Total Videos: ${itemList.length}`)
|
||||
itemList.forEach((item, idx) => {
|
||||
console.log(`\n[${idx + 1}] ID: ${item.id}`)
|
||||
console.log(`Description: ${item.desc}`)
|
||||
if (item.author) {
|
||||
console.log(`Author: ${item.author.nickname}`)
|
||||
}
|
||||
if (item.stats) {
|
||||
console.log("Statistics:")
|
||||
console.log(`- Likes: ${item.stats.diggCount}`)
|
||||
console.log(`- Comments: ${item.stats.commentCount}`)
|
||||
console.log(`- Shares: ${item.stats.shareCount}`)
|
||||
console.log(`- Plays: ${item.stats.playCount}`)
|
||||
}
|
||||
if (item.video?.playAddr?.length) {
|
||||
console.log(`Video URL: ${item.video.playAddr}`)
|
||||
}
|
||||
})
|
||||
console.log("========================")
|
||||
if (hasMore) {
|
||||
console.log(
|
||||
"There are more videos. Use the 'page' option to fetch next page."
|
||||
)
|
||||
}
|
||||
} else {
|
||||
console.error("Error:", result.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Test failed:", error)
|
||||
}
|
||||
}
|
||||
|
||||
testPlaylist()
|
||||
41
test/profile-test.ts
Normal file
41
test/profile-test.ts
Normal file
@ -0,0 +1,41 @@
|
||||
// Test for Tiktok Stalk User Profile
|
||||
import Tiktok from "../src/index"
|
||||
|
||||
async function testProfile() {
|
||||
try {
|
||||
const username = "tobz2k19" // 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
|
||||
console.log("\nProfile fetched successfully!")
|
||||
console.log("========================")
|
||||
console.log("User Profile:")
|
||||
console.log("========================")
|
||||
console.log(`Username: @${user.username}`)
|
||||
console.log(`Nickname: ${user.nickname}`)
|
||||
console.log(`Signature: ${user.signature}`)
|
||||
console.log(`Verified: ${user.verified ? "Yes" : "No"}`)
|
||||
console.log(`Region: ${user.region}`)
|
||||
console.log(`Private Account: ${user.privateAccount ? "Yes" : "No"}`)
|
||||
console.log(`Commerce User: ${user.commerceUser ? "Yes" : "No"}`)
|
||||
console.log(`Avatar: ${user.avatarLarger}`)
|
||||
console.log("\nStats:")
|
||||
console.log(`- Followers: ${stats.followerCount}`)
|
||||
console.log(`- Following: ${stats.followingCount}`)
|
||||
console.log(`- Hearts: ${stats.heartCount}`)
|
||||
console.log(`- Videos: ${stats.videoCount}`)
|
||||
console.log(`- Likes: ${stats.likeCount}`)
|
||||
console.log(`- Friends: ${stats.friendCount}`)
|
||||
console.log("========================")
|
||||
} else {
|
||||
console.error("Error:", result.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Test failed:", error)
|
||||
}
|
||||
}
|
||||
|
||||
testProfile()
|
||||
42
test/search-live-test.ts
Normal file
42
test/search-live-test.ts
Normal file
@ -0,0 +1,42 @@
|
||||
// Test for Tiktok Search Live
|
||||
import Tiktok from "../src/index"
|
||||
|
||||
async function testSearchLive() {
|
||||
try {
|
||||
const keyword = "call of duty" // Change to a valid search keyword
|
||||
const cookie = "" // Optional: provide a valid TikTok cookie if needed
|
||||
console.log(`\nTesting Search type: live`)
|
||||
const result = await Tiktok.Search(keyword, {
|
||||
type: "live",
|
||||
cookie,
|
||||
page: 1,
|
||||
proxy: undefined
|
||||
})
|
||||
if (result.status === "success" && result.result) {
|
||||
console.log("Success! Parsed Result:")
|
||||
result.result.forEach((item, index) => {
|
||||
if (item.type === "live") {
|
||||
const live = item as typeof item & { liveInfo: any }
|
||||
if (live.liveInfo) {
|
||||
console.log(`\nResult ${index + 1}:`)
|
||||
console.log("-------------------")
|
||||
console.log(`ID: ${live.liveInfo.id}`)
|
||||
console.log(`Title: ${live.liveInfo.title}`)
|
||||
console.log(`Hashtag: ${live.liveInfo.hashtag}`)
|
||||
if (live.liveInfo.owner)
|
||||
console.log(`Owner: ${live.liveInfo.owner.nickname}`)
|
||||
if (live.liveInfo.stats)
|
||||
console.log(`Viewers: ${live.liveInfo.stats.viewerCount}`)
|
||||
console.log("========================")
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.error("Error:", result.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Test failed:", error)
|
||||
}
|
||||
}
|
||||
|
||||
testSearchLive()
|
||||
46
test/search-user-test.ts
Normal file
46
test/search-user-test.ts
Normal file
@ -0,0 +1,46 @@
|
||||
// Test for Tiktok Search User
|
||||
import Tiktok from "../src/index"
|
||||
|
||||
async function testSearchUser() {
|
||||
try {
|
||||
const keyword = "call of duty" // Change to a valid search keyword
|
||||
const cookie = "" // Optional: provide a valid TikTok cookie if needed
|
||||
console.log(`\nTesting Search type: user`)
|
||||
const result = await Tiktok.Search(keyword, {
|
||||
type: "user",
|
||||
cookie,
|
||||
page: 1,
|
||||
proxy: undefined
|
||||
})
|
||||
if (result.status === "success" && result.result) {
|
||||
console.log("Success! Parsed Result:")
|
||||
result.result.forEach((item, index) => {
|
||||
if (item.type === "user") {
|
||||
const user = item as typeof item & {
|
||||
uid: string
|
||||
username: string
|
||||
nickname: string
|
||||
followerCount: number
|
||||
isVerified: boolean
|
||||
url: string
|
||||
}
|
||||
console.log(`\nResult ${index + 1}:`)
|
||||
console.log("-------------------")
|
||||
console.log(`UID: ${user.uid}`)
|
||||
console.log(`Username: ${user.username}`)
|
||||
console.log(`Nickname: ${user.nickname}`)
|
||||
console.log(`Followers: ${user.followerCount}`)
|
||||
console.log(`Verified: ${user.isVerified ? "Yes" : "No"}`)
|
||||
console.log(`Profile URL: ${user.url}`)
|
||||
console.log("========================")
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.error("Error:", result.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Test failed:", error)
|
||||
}
|
||||
}
|
||||
|
||||
testSearchUser()
|
||||
53
test/search-video-test.ts
Normal file
53
test/search-video-test.ts
Normal file
@ -0,0 +1,53 @@
|
||||
// Test for Tiktok Search Video
|
||||
import Tiktok from "../src/index"
|
||||
|
||||
async function testSearchVideo() {
|
||||
try {
|
||||
const keyword = "call of duty" // Change to a valid search keyword
|
||||
const cookie = "" // Optional: provide a valid TikTok cookie if needed
|
||||
console.log(`\nTesting Search type: video`)
|
||||
const result = await Tiktok.Search(keyword, {
|
||||
type: "video",
|
||||
cookie,
|
||||
page: 1,
|
||||
proxy: undefined
|
||||
})
|
||||
if (result.status === "success" && result.result) {
|
||||
console.log("Success! Parsed Result:")
|
||||
result.result.forEach((item, index) => {
|
||||
if (item.type === "video") {
|
||||
const video = item as typeof item & {
|
||||
id: string
|
||||
desc: string
|
||||
author: any
|
||||
createTime: number
|
||||
stats: any
|
||||
}
|
||||
console.log(`\nResult ${index + 1}:`)
|
||||
console.log("-------------------")
|
||||
console.log(`ID: ${video.id}`)
|
||||
console.log(`Description: ${video.desc}`)
|
||||
if (video.author) console.log(`Author: ${video.author.nickname}`)
|
||||
if (video.createTime)
|
||||
console.log(
|
||||
`Created: ${new Date(video.createTime * 1000).toLocaleString()}`
|
||||
)
|
||||
if (video.stats) {
|
||||
console.log("Statistics:")
|
||||
console.log(`- Likes: ${video.stats.likeCount}`)
|
||||
console.log(`- Comments: ${video.stats.commentCount}`)
|
||||
console.log(`- Shares: ${video.stats.shareCount}`)
|
||||
console.log(`- Plays: ${video.stats.playCount}`)
|
||||
}
|
||||
console.log("========================")
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.error("Error:", result.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Test failed:", error)
|
||||
}
|
||||
}
|
||||
|
||||
testSearchVideo()
|
||||
65
test/userliked-test.ts
Normal file
65
test/userliked-test.ts
Normal file
@ -0,0 +1,65 @@
|
||||
// Test for Tiktok Get User Liked Videos
|
||||
import Tiktok from "../src/index"
|
||||
|
||||
async function testUserLiked() {
|
||||
try {
|
||||
const username = "Tobz2k19" // Change to a valid TikTok username
|
||||
const cookie = "" // Optional: provide a valid TikTok cookie if needed
|
||||
const result = await Tiktok.GetUserLiked(username, {
|
||||
cookie,
|
||||
postLimit: 5,
|
||||
proxy: undefined
|
||||
})
|
||||
if (result.status === "success" && result.result) {
|
||||
console.log("\nUser Liked Videos fetched successfully!")
|
||||
console.log("========================")
|
||||
console.log("Liked Videos Overview:")
|
||||
console.log("========================")
|
||||
console.log(`Total liked videos fetched: ${result.result.length}`)
|
||||
result.result.forEach((liked, index) => {
|
||||
console.log(`\nLiked Video ${index + 1}:`)
|
||||
console.log("-------------------")
|
||||
console.log(`ID: ${liked.id}`)
|
||||
console.log(`Description: ${liked.desc}`)
|
||||
if (liked.author) {
|
||||
console.log(
|
||||
`Author: ${liked.author.nickname} (@${liked.author.username})`
|
||||
)
|
||||
}
|
||||
if (liked.createTime) {
|
||||
console.log(
|
||||
`Created: ${new Date(
|
||||
Number(liked.createTime) * 1000
|
||||
).toLocaleString()}`
|
||||
)
|
||||
}
|
||||
if (liked.stats) {
|
||||
console.log("Statistics:")
|
||||
console.log(`- Likes: ${liked.stats.diggCount}`)
|
||||
console.log(`- Favorites: ${liked.stats.collectCount}`)
|
||||
console.log(`- Comments: ${liked.stats.commentCount}`)
|
||||
console.log(`- Shares: ${liked.stats.shareCount}`)
|
||||
console.log(`- Plays: ${liked.stats.playCount}`)
|
||||
console.log(`- Reposts: ${liked.stats.repostCount}`)
|
||||
}
|
||||
if (liked.video?.playAddr) {
|
||||
console.log(`Video URL: ${liked.video.playAddr}`)
|
||||
}
|
||||
if (liked.imagePost?.length) {
|
||||
console.log(
|
||||
`Images: \n${liked.imagePost
|
||||
.map((img) => img.images)
|
||||
.join("\n - ")}`
|
||||
)
|
||||
}
|
||||
console.log("========================")
|
||||
})
|
||||
} else {
|
||||
console.error("Error:", result.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Test failed:", error)
|
||||
}
|
||||
}
|
||||
|
||||
testUserLiked()
|
||||
55
test/userposts-test.ts
Normal file
55
test/userposts-test.ts
Normal file
@ -0,0 +1,55 @@
|
||||
// Test for Tiktok Get User Posts
|
||||
import Tiktok from "../src/index"
|
||||
|
||||
async function testUserPosts() {
|
||||
try {
|
||||
const username = "Tobz2k19" // Change to a valid TikTok username
|
||||
const result = await Tiktok.GetUserPosts(username, {
|
||||
postLimit: 5,
|
||||
proxy: undefined
|
||||
})
|
||||
if (result.status === "success" && result.result) {
|
||||
console.log("\nUser Posts fetched successfully!")
|
||||
console.log("========================")
|
||||
console.log("Posts Overview:")
|
||||
console.log("========================")
|
||||
console.log(`Total posts fetched: ${result.result.length}`)
|
||||
result.result.forEach((post, index) => {
|
||||
console.log(`\nPost ${index + 1}:`)
|
||||
console.log("-------------------")
|
||||
console.log(`ID: ${post.id}`)
|
||||
console.log(`Description: ${post.desc}`)
|
||||
if (post.author) {
|
||||
console.log(
|
||||
`Author: ${post.author.nickname} (@${post.author.username})`
|
||||
)
|
||||
}
|
||||
if (post.createTime) {
|
||||
console.log(
|
||||
`Created: ${new Date(post.createTime * 1000).toLocaleString()}`
|
||||
)
|
||||
}
|
||||
if (post.stats) {
|
||||
console.log("Statistics:")
|
||||
console.log(`- Likes: ${post.stats.likeCount}`)
|
||||
console.log(`- Comments: ${post.stats.commentCount}`)
|
||||
console.log(`- Shares: ${post.stats.shareCount}`)
|
||||
console.log(`- Plays: ${post.stats.playCount}`)
|
||||
}
|
||||
if (post.video?.playAddr) {
|
||||
console.log(`Video URL: ${post.video.playAddr}`)
|
||||
}
|
||||
if (post.imagePost?.length) {
|
||||
console.log(`Images: ${post.imagePost.join(", ")}`)
|
||||
}
|
||||
console.log("========================")
|
||||
})
|
||||
} else {
|
||||
console.error("Error:", result.message)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Test failed:", error)
|
||||
}
|
||||
}
|
||||
|
||||
testUserPosts()
|
||||
Loading…
x
Reference in New Issue
Block a user