feat: add turn off comment status for v1
This commit is contained in:
parent
3bcbecbb6e
commit
03a081d87b
@ -9,6 +9,7 @@ export type TiktokAPIResponse = {
|
|||||||
author: Author
|
author: Author
|
||||||
statistics: Statistics
|
statistics: Statistics
|
||||||
hashtag: string[]
|
hashtag: string[]
|
||||||
|
isTurnOffComment: boolean
|
||||||
isADS: boolean
|
isADS: boolean
|
||||||
cover?: string[]
|
cover?: string[]
|
||||||
dynamicCover?: string[]
|
dynamicCover?: string[]
|
||||||
@ -17,6 +18,7 @@ export type TiktokAPIResponse = {
|
|||||||
images?: string[]
|
images?: string[]
|
||||||
music: Music
|
music: Music
|
||||||
}
|
}
|
||||||
|
resultNotParsed?: any
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Author = {
|
export type Author = {
|
||||||
|
|||||||
@ -20,11 +20,16 @@ const TiktokURLregex =
|
|||||||
* Tiktok API Downloader
|
* Tiktok API Downloader
|
||||||
* @param {string} url - Tiktok URL
|
* @param {string} url - Tiktok URL
|
||||||
* @param {string} proxy - Your Proxy (optional)
|
* @param {string} proxy - Your Proxy (optional)
|
||||||
|
* @param {boolean} showOriginalResponse - Show Original Response (optional)
|
||||||
* @returns {Promise<TiktokAPIResponse>}
|
* @returns {Promise<TiktokAPIResponse>}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const TiktokAPI = (url: string, proxy?: string) =>
|
export const TiktokAPI = (
|
||||||
new Promise<TiktokAPIResponse>((resolve) => {
|
url: string,
|
||||||
|
proxy?: string,
|
||||||
|
showOriginalResponse?: boolean
|
||||||
|
): Promise<TiktokAPIResponse> =>
|
||||||
|
new Promise((resolve) => {
|
||||||
if (!TiktokURLregex.test(url)) {
|
if (!TiktokURLregex.test(url)) {
|
||||||
return resolve({
|
return resolve({
|
||||||
status: "error",
|
status: "error",
|
||||||
@ -66,29 +71,31 @@ export const TiktokAPI = (url: string, proxy?: string) =>
|
|||||||
|
|
||||||
const { content, author, statistics, music } = data2
|
const { content, author, statistics, music } = data2
|
||||||
|
|
||||||
|
let response: TiktokAPIResponse
|
||||||
// Download Result
|
// Download Result
|
||||||
if (content.image_post_info) {
|
if (content.image_post_info) {
|
||||||
// Images or Slide Result
|
// Images or Slide Result
|
||||||
resolve({
|
response = {
|
||||||
status: "success",
|
status: "success",
|
||||||
result: {
|
result: {
|
||||||
type: "image",
|
type: "image",
|
||||||
id: content.aweme_id,
|
id: content.aweme_id,
|
||||||
createTime: content.create_time,
|
createTime: content.create_time,
|
||||||
description: content.desc,
|
description: content.desc,
|
||||||
|
isTurnOffComment: content.item_comment_settings === 3,
|
||||||
hashtag: content.text_extra
|
hashtag: content.text_extra
|
||||||
.filter((x) => x.hashtag_name !== undefined)
|
.filter((x: any) => x.hashtag_name !== undefined)
|
||||||
.map((v) => v.hashtag_name),
|
.map((v: any) => v.hashtag_name),
|
||||||
isADS: content.is_ads,
|
isADS: content.is_ads,
|
||||||
author,
|
author,
|
||||||
statistics,
|
statistics,
|
||||||
images:
|
images:
|
||||||
content.image_post_info.images?.map(
|
content.image_post_info.images?.map(
|
||||||
(v) => v?.display_image?.url_list[0]
|
(v: any) => v?.display_image?.url_list[0]
|
||||||
) || [],
|
) || [],
|
||||||
music
|
music
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
} else {
|
} else {
|
||||||
// Video Result
|
// Video Result
|
||||||
const video: Video = {
|
const video: Video = {
|
||||||
@ -101,24 +108,34 @@ export const TiktokAPI = (url: string, proxy?: string) =>
|
|||||||
originCover: content.video?.origin_cover?.url_list || []
|
originCover: content.video?.origin_cover?.url_list || []
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve({
|
response = {
|
||||||
status: "success",
|
status: "success",
|
||||||
result: {
|
result: {
|
||||||
type: "video",
|
type: "video",
|
||||||
id: content.aweme_id,
|
id: content.aweme_id,
|
||||||
createTime: content.create_time,
|
createTime: content.create_time,
|
||||||
description: content.desc,
|
description: content.desc,
|
||||||
|
isTurnOffComment: content.item_comment_settings === 3,
|
||||||
hashtag: content.text_extra
|
hashtag: content.text_extra
|
||||||
.filter((x) => x.hashtag_name !== undefined)
|
.filter((x: any) => x.hashtag_name !== undefined)
|
||||||
.map((v) => v.hashtag_name),
|
.map((v: any) => v.hashtag_name),
|
||||||
isADS: content.is_ads,
|
isADS: content.is_ads,
|
||||||
author,
|
author,
|
||||||
statistics,
|
statistics,
|
||||||
video,
|
video,
|
||||||
music
|
music
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show Original Response
|
||||||
|
if (showOriginalResponse) {
|
||||||
|
response = {
|
||||||
|
status: "success",
|
||||||
|
resultNotParsed: data2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resolve(response)
|
||||||
})
|
})
|
||||||
.catch((e) => resolve({ status: "error", message: e.message }))
|
.catch((e) => resolve({ status: "error", message: e.message }))
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user