fix: fixing several types
This commit is contained in:
parent
fb72a4f74a
commit
4dda8daf85
26
src/constants/index.ts
Normal file
26
src/constants/index.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
export const DOWNLOADER_VERSIONS = {
|
||||||
|
V1: "v1",
|
||||||
|
V2: "v2",
|
||||||
|
V3: "v3"
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export const SEARCH_TYPES = {
|
||||||
|
USER: "user",
|
||||||
|
LIVE: "live",
|
||||||
|
VIDEO: "video"
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export const ERROR_MESSAGES = {
|
||||||
|
COOKIE_REQUIRED: "Cookie is required!",
|
||||||
|
INVALID_VERSION: "Invalid downloader version",
|
||||||
|
INVALID_SEARCH_TYPE: "Invalid search type",
|
||||||
|
INVALID_URL: "Invalid TikTok URL",
|
||||||
|
NETWORK_ERROR: "Network error occurred",
|
||||||
|
RATE_LIMIT: "Rate limit exceeded"
|
||||||
|
} as const
|
||||||
|
|
||||||
|
export const DEFAULT_LIMITS = {
|
||||||
|
POST_LIMIT: 30,
|
||||||
|
COMMENT_LIMIT: 20,
|
||||||
|
SEARCH_PAGE_SIZE: 20
|
||||||
|
} as const
|
||||||
74
src/types/common.ts
Normal file
74
src/types/common.ts
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/** Common Types */
|
||||||
|
export type ResponseStatus = "success" | "error"
|
||||||
|
|
||||||
|
export type BaseResponse = {
|
||||||
|
status: ResponseStatus
|
||||||
|
message?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ContentType = "video" | "image" | "music"
|
||||||
|
|
||||||
|
export type Author = {
|
||||||
|
avatar?: string
|
||||||
|
nickname?: string
|
||||||
|
signature?: string
|
||||||
|
region?: string
|
||||||
|
url?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Statistics = {
|
||||||
|
likeCount?: string | number
|
||||||
|
commentCount?: string | number
|
||||||
|
shareCount?: string | number
|
||||||
|
playCount?: number
|
||||||
|
downloadCount?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Video = {
|
||||||
|
ratio?: string
|
||||||
|
duration?: number
|
||||||
|
playAddr?: string[]
|
||||||
|
downloadAddr?: string[]
|
||||||
|
cover?: string[]
|
||||||
|
dynamicCover?: string[]
|
||||||
|
originCover?: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Music = {
|
||||||
|
id?: number
|
||||||
|
title?: string
|
||||||
|
author?: string
|
||||||
|
album?: string
|
||||||
|
playUrl?: string[]
|
||||||
|
coverLarge?: string[]
|
||||||
|
coverMedium?: string[]
|
||||||
|
coverThumb?: string[]
|
||||||
|
duration?: number
|
||||||
|
isCommerceMusic?: boolean
|
||||||
|
isOriginalSound?: boolean
|
||||||
|
isAuthorArtist?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Content = {
|
||||||
|
type: ContentType
|
||||||
|
id?: string
|
||||||
|
createTime?: number
|
||||||
|
desc?: string
|
||||||
|
author?: Author
|
||||||
|
statistics?: Statistics
|
||||||
|
hashtag?: string[]
|
||||||
|
isTurnOffComment?: boolean
|
||||||
|
isADS?: boolean
|
||||||
|
video?: Video
|
||||||
|
images?: string[]
|
||||||
|
music?: Music
|
||||||
|
videoHD?: string
|
||||||
|
videoSD?: string
|
||||||
|
videoWatermark?: string
|
||||||
|
direct?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type BaseContentResponse = BaseResponse & {
|
||||||
|
result?: Content
|
||||||
|
resultNotParsed?: any
|
||||||
|
}
|
||||||
@ -1,30 +1,16 @@
|
|||||||
export type GetMusicalDownReuqest = {
|
import { BaseResponse, Content } from "../common"
|
||||||
status: "success" | "error"
|
|
||||||
|
export type GetMusicalDownReuqest = BaseResponse & {
|
||||||
request?: {
|
request?: {
|
||||||
[key: string]: string
|
[key: string]: string
|
||||||
}
|
}
|
||||||
message?: string
|
|
||||||
cookie?: string
|
cookie?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MusicalDownResponse = {
|
export type MusicalDownResponse = BaseResponse & {
|
||||||
status: "success" | "error"
|
result?: Content
|
||||||
message?: string
|
|
||||||
result?: {
|
|
||||||
type: "video" | "image"
|
|
||||||
desc?: string
|
|
||||||
author?: {
|
|
||||||
avatar?: string
|
|
||||||
nickname?: string
|
|
||||||
}
|
|
||||||
music?: string
|
|
||||||
images?: string[]
|
|
||||||
videoHD?: string
|
|
||||||
videoWatermark?: string
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GetMusicalDownMusic = {
|
export type GetMusicalDownMusic = BaseResponse & {
|
||||||
status: "success" | "error"
|
|
||||||
result?: string
|
result?: string
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,31 +1,13 @@
|
|||||||
export type SSSTikFetchTT = {
|
import { BaseResponse, Content, Author, Statistics } from "../common"
|
||||||
status: "success" | "error"
|
|
||||||
message?: string
|
export type SSSTikFetchTT = BaseResponse & {
|
||||||
result?: string
|
result?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SSSTikResponse = {
|
export type SSSTikResponse = BaseResponse & {
|
||||||
status: "success" | "error"
|
result?: Content
|
||||||
message?: string
|
|
||||||
result?: {
|
|
||||||
type: "image" | "video" | "music"
|
|
||||||
desc?: string
|
|
||||||
author?: AuthorSSSTik
|
|
||||||
statistics?: StatisticsSSSTik
|
|
||||||
images?: string[]
|
|
||||||
video?: string
|
|
||||||
music?: string
|
|
||||||
direct?: string
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AuthorSSSTik = {
|
export type AuthorSSSTik = Author
|
||||||
avatar: string
|
|
||||||
nickname: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type StatisticsSSSTik = {
|
export type StatisticsSSSTik = Statistics
|
||||||
likeCount: string
|
|
||||||
commentCount: string
|
|
||||||
shareCount: string
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,75 +1,28 @@
|
|||||||
export type TiktokAPIResponse = {
|
import {
|
||||||
status: "success" | "error"
|
BaseContentResponse,
|
||||||
message?: string
|
Content,
|
||||||
result?: {
|
Author,
|
||||||
type: "video" | "image"
|
Statistics,
|
||||||
id: string
|
Video,
|
||||||
createTime: number
|
Music
|
||||||
description: string
|
} from "../common"
|
||||||
author: AuthorTiktokAPI
|
|
||||||
statistics: StatisticsTiktokAPI
|
|
||||||
hashtag: string[]
|
|
||||||
isTurnOffComment: boolean
|
|
||||||
isADS: boolean
|
|
||||||
cover?: string[]
|
|
||||||
dynamicCover?: string[]
|
|
||||||
originCover?: string[]
|
|
||||||
video?: VideoTiktokAPI
|
|
||||||
images?: string[]
|
|
||||||
music: MusicTiktokAPI
|
|
||||||
}
|
|
||||||
resultNotParsed?: any
|
|
||||||
}
|
|
||||||
|
|
||||||
export type AuthorTiktokAPI = {
|
export type TiktokAPIResponse = BaseContentResponse
|
||||||
uid: number
|
|
||||||
|
export type AuthorTiktokAPI = Author & {
|
||||||
|
uid: string
|
||||||
username: string
|
username: string
|
||||||
nickname: string
|
avatarThumb: string
|
||||||
signature: string
|
avatarMedium: string
|
||||||
region: string
|
|
||||||
avatarThumb: string[]
|
|
||||||
avatarMedium: string[]
|
|
||||||
url: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type StatisticsTiktokAPI = {
|
export type StatisticsTiktokAPI = Statistics
|
||||||
playCount: number
|
|
||||||
downloadCount: number
|
|
||||||
shareCount: number
|
|
||||||
commentCount: number
|
|
||||||
diggCount: number
|
|
||||||
collectCount: number
|
|
||||||
forwardCount: number
|
|
||||||
whatsappShareCount: number
|
|
||||||
loseCount: number
|
|
||||||
loseCommentCount: number
|
|
||||||
repostCount: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export type VideoTiktokAPI = {
|
export type VideoTiktokAPI = Video
|
||||||
ratio: string
|
|
||||||
duration: number
|
|
||||||
playAddr: string[]
|
|
||||||
downloadAddr: string[]
|
|
||||||
cover: string[]
|
|
||||||
dynamicCover: string[]
|
|
||||||
originCover: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export type MusicTiktokAPI = {
|
export type MusicTiktokAPI = Music
|
||||||
id: number
|
|
||||||
title: string
|
export type ResultTiktokAPI = Content
|
||||||
author: string
|
|
||||||
album: string
|
|
||||||
playUrl: string[]
|
|
||||||
coverLarge: string[]
|
|
||||||
coverMedium: string[]
|
|
||||||
coverThumb: string[]
|
|
||||||
duration: number
|
|
||||||
isCommerceMusic: boolean
|
|
||||||
isOriginalSound: boolean
|
|
||||||
isAuthorArtist: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ResponseParserTiktokAPI = {
|
export type ResponseParserTiktokAPI = {
|
||||||
content?: any
|
content?: any
|
||||||
|
|||||||
@ -27,7 +27,7 @@ export type Posts = {
|
|||||||
export type StatsPost = {
|
export type StatsPost = {
|
||||||
collectCount: number
|
collectCount: number
|
||||||
commentCount: number
|
commentCount: number
|
||||||
diggCount: number
|
likeCount: number
|
||||||
playCount: number
|
playCount: number
|
||||||
shareCount: number
|
shareCount: number
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/types/search/index.ts
Normal file
18
src/types/search/index.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { VideoSearchResult } from "./videoSearch"
|
||||||
|
import { LiveSearchResult } from "./liveSearch"
|
||||||
|
import { UserSearchResult } from "./userSearch"
|
||||||
|
|
||||||
|
export type SearchType = "video" | "live" | "user"
|
||||||
|
|
||||||
|
export type SearchResult = {
|
||||||
|
type: SearchType
|
||||||
|
data: VideoSearchResult | LiveSearchResult | UserSearchResult
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TiktokSearchResponse = {
|
||||||
|
status: "success" | "error"
|
||||||
|
message?: string
|
||||||
|
result?: SearchResult[]
|
||||||
|
page?: number
|
||||||
|
totalResults?: number
|
||||||
|
}
|
||||||
@ -30,7 +30,7 @@ export type VideoSearch = {
|
|||||||
export type StatisticsVideoSearch = {
|
export type StatisticsVideoSearch = {
|
||||||
collectCount: number
|
collectCount: number
|
||||||
commentCount: number
|
commentCount: number
|
||||||
diggCount: number
|
likeCount: number
|
||||||
playCount: number
|
playCount: number
|
||||||
shareCount: number
|
shareCount: number
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user