fix: downloader types
This commit is contained in:
parent
db1686fc9b
commit
1ad6d8baea
92
src/index.ts
92
src/index.ts
@ -1,7 +1,7 @@
|
|||||||
/** Types */
|
/** Types */
|
||||||
import { TiktokAPIResponse } from "./types/downloader/tiktokApi"
|
import { TiktokAPIResponse } from "./types/downloader/tiktokApiDownloader"
|
||||||
import { SSSTikResponse } from "./types/downloader/ssstik"
|
import { SSSTikResponse } from "./types/downloader/ssstikDownloader"
|
||||||
import { MusicalDownResponse } from "./types/downloader/musicaldown"
|
import { MusicalDownResponse } from "./types/downloader/musicaldownDownloader"
|
||||||
import { UserSearchResult } from "./types/search/userSearch"
|
import { UserSearchResult } from "./types/search/userSearch"
|
||||||
import { LiveSearchResult } from "./types/search/liveSearch"
|
import { LiveSearchResult } from "./types/search/liveSearch"
|
||||||
import { VideoSearchResult } from "./types/search/videoSearch"
|
import { VideoSearchResult } from "./types/search/videoSearch"
|
||||||
@ -12,9 +12,9 @@ import { TiktokUserFavoriteVideosResponse } from "./types/get/getUserLiked"
|
|||||||
import { TiktokCollectionResponse } from "./types/get/getCollection"
|
import { TiktokCollectionResponse } from "./types/get/getCollection"
|
||||||
|
|
||||||
/** Services */
|
/** Services */
|
||||||
import { extractPlaylistId, TiktokAPI } from "./utils/downloader/tiktokApi"
|
import { TiktokAPI } from "./utils/downloader/tiktokAPIDownloader"
|
||||||
import { SSSTik } from "./utils/downloader/ssstik"
|
import { SSSTik } from "./utils/downloader/ssstikDownloader"
|
||||||
import { MusicalDown } from "./utils/downloader/musicalDown"
|
import { MusicalDown } from "./utils/downloader/musicaldownDownloader"
|
||||||
import { StalkUser } from "./utils/get/getProfile"
|
import { StalkUser } from "./utils/get/getProfile"
|
||||||
import { SearchUser } from "./utils/search/userSearch"
|
import { SearchUser } from "./utils/search/userSearch"
|
||||||
import { SearchLive } from "./utils/search/liveSearch"
|
import { SearchLive } from "./utils/search/liveSearch"
|
||||||
@ -23,7 +23,6 @@ import { getUserPosts } from "./utils/get/getUserPosts"
|
|||||||
import { getUserLiked } from "./utils/get/getUserLiked"
|
import { getUserLiked } from "./utils/get/getUserLiked"
|
||||||
import { SearchVideo } from "./utils/search/videoSearch"
|
import { SearchVideo } from "./utils/search/videoSearch"
|
||||||
import { getCollection } from "./utils/get/getCollection"
|
import { getCollection } from "./utils/get/getCollection"
|
||||||
import { extractCollectionId } from "./utils/downloader/tiktokApi"
|
|
||||||
|
|
||||||
/** Constants */
|
/** Constants */
|
||||||
import { DOWNLOADER_VERSIONS, SEARCH_TYPES } from "./constants"
|
import { DOWNLOADER_VERSIONS, SEARCH_TYPES } from "./constants"
|
||||||
@ -31,6 +30,8 @@ import { ERROR_MESSAGES } from "./constants"
|
|||||||
import { validateCookie } from "./utils/validator"
|
import { validateCookie } from "./utils/validator"
|
||||||
import { TiktokPlaylistResponse } from "./types/get/getPlaylist"
|
import { TiktokPlaylistResponse } from "./types/get/getPlaylist"
|
||||||
import { getPlaylist } from "./utils/get/getPlaylist"
|
import { getPlaylist } from "./utils/get/getPlaylist"
|
||||||
|
import { extractPlaylistId } from "./utils/get/getPlaylist"
|
||||||
|
import { extractCollectionId } from "./utils/get/getCollection"
|
||||||
|
|
||||||
/** Types */
|
/** Types */
|
||||||
type DownloaderVersion = "v1" | "v2" | "v3"
|
type DownloaderVersion = "v1" | "v2" | "v3"
|
||||||
@ -82,7 +83,7 @@ export = {
|
|||||||
Downloader: async <T extends DownloaderVersion>(
|
Downloader: async <T extends DownloaderVersion>(
|
||||||
url: string,
|
url: string,
|
||||||
options?: {
|
options?: {
|
||||||
version: DownloaderVersion
|
version: T
|
||||||
proxy?: string
|
proxy?: string
|
||||||
showOriginalResponse?: boolean
|
showOriginalResponse?: boolean
|
||||||
}
|
}
|
||||||
@ -118,38 +119,6 @@ export = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Get TikTok Collection
|
|
||||||
* @param {string} collectionIdOrUrl - Collection ID or URL (e.g. 7507916135931218695 or https://www.tiktok.com/@username/collection/name-id)
|
|
||||||
* @param {Object} options - The options for collection
|
|
||||||
* @param {string} [options.proxy] - Optional proxy URL
|
|
||||||
* @param {string} [options.page] - Optional page for pagination
|
|
||||||
* @param {number} [options.count] - Optional number of items to fetch
|
|
||||||
* @returns {Promise<TiktokCollectionResponse>}
|
|
||||||
*/
|
|
||||||
Collection: async (
|
|
||||||
collectionIdOrUrl: string,
|
|
||||||
options?: {
|
|
||||||
proxy?: string
|
|
||||||
page?: number
|
|
||||||
count?: number
|
|
||||||
}
|
|
||||||
): Promise<TiktokCollectionResponse> => {
|
|
||||||
const collectionId = extractCollectionId(collectionIdOrUrl)
|
|
||||||
if (!collectionId) {
|
|
||||||
return {
|
|
||||||
status: "error",
|
|
||||||
message: "Invalid collection ID or URL format"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return await getCollection(
|
|
||||||
collectionId,
|
|
||||||
options?.proxy,
|
|
||||||
options?.page,
|
|
||||||
options?.count
|
|
||||||
)
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tiktok Search
|
* Tiktok Search
|
||||||
* @param {string} keyword - The query you want to search
|
* @param {string} keyword - The query you want to search
|
||||||
@ -164,7 +133,7 @@ export = {
|
|||||||
keyword: string,
|
keyword: string,
|
||||||
options?: {
|
options?: {
|
||||||
type?: T
|
type?: T
|
||||||
cookie?: string
|
cookie: string | any[]
|
||||||
page?: number
|
page?: number
|
||||||
proxy?: string
|
proxy?: string
|
||||||
}
|
}
|
||||||
@ -240,11 +209,10 @@ export = {
|
|||||||
StalkUser: async (
|
StalkUser: async (
|
||||||
username: string,
|
username: string,
|
||||||
options?: {
|
options?: {
|
||||||
cookie?: string | any[]
|
|
||||||
proxy?: string
|
proxy?: string
|
||||||
}
|
}
|
||||||
): Promise<TiktokStalkUserResponse> => {
|
): Promise<TiktokStalkUserResponse> => {
|
||||||
return await StalkUser(username, options?.cookie, options?.proxy)
|
return await StalkUser(username, options?.proxy)
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -314,9 +282,41 @@ export = {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get TikTok Collection
|
||||||
|
* @param {string} collectionIdOrUrl - Collection ID or URL (e.g. 7507916135931218695 or https://www.tiktok.com/@username/collection/name-id)
|
||||||
|
* @param {Object} options - The options for collection
|
||||||
|
* @param {string} [options.proxy] - Optional proxy URL
|
||||||
|
* @param {string} [options.page] - Optional page for pagination
|
||||||
|
* @param {number} [options.count] - Optional number of items to fetch
|
||||||
|
* @returns {Promise<TiktokCollectionResponse>}
|
||||||
|
*/
|
||||||
|
Collection: async (
|
||||||
|
collectionIdOrUrl: string,
|
||||||
|
options?: {
|
||||||
|
proxy?: string
|
||||||
|
page?: number
|
||||||
|
count?: number
|
||||||
|
}
|
||||||
|
): Promise<TiktokCollectionResponse> => {
|
||||||
|
const collectionId = extractCollectionId(collectionIdOrUrl)
|
||||||
|
if (!collectionId) {
|
||||||
|
return {
|
||||||
|
status: "error",
|
||||||
|
message: "Invalid collection ID or URL format"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return await getCollection(
|
||||||
|
collectionId,
|
||||||
|
options?.proxy,
|
||||||
|
options?.page,
|
||||||
|
options?.count
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get TikTok Playlist
|
* Get TikTok Playlist
|
||||||
* @param {string} url - URL (e.g. https://www.tiktok.com/@username/playlist/name-id)
|
* @param {string} playlistIdOrUrl - Playlist ID or URL (e.g. 7507916135931218695 or https://www.tiktok.com/@username/playlist/name-id)
|
||||||
* @param {Object} options - The options for playlist
|
* @param {Object} options - The options for playlist
|
||||||
* @param {string} [options.proxy] - Optional proxy URL
|
* @param {string} [options.proxy] - Optional proxy URL
|
||||||
* @param {string} [options.page] - Optional page for pagination
|
* @param {string} [options.page] - Optional page for pagination
|
||||||
@ -324,14 +324,14 @@ export = {
|
|||||||
* @returns {Promise<TiktokPlaylistResponse>}
|
* @returns {Promise<TiktokPlaylistResponse>}
|
||||||
*/
|
*/
|
||||||
Playlist: async (
|
Playlist: async (
|
||||||
url: string,
|
playlistIdOrUrl: string,
|
||||||
options?: {
|
options?: {
|
||||||
proxy?: string
|
proxy?: string
|
||||||
page?: number
|
page?: number
|
||||||
count?: number
|
count?: number
|
||||||
}
|
}
|
||||||
): Promise<TiktokPlaylistResponse> => {
|
): Promise<TiktokPlaylistResponse> => {
|
||||||
const playlistId = extractPlaylistId(url)
|
const playlistId = extractPlaylistId(playlistIdOrUrl)
|
||||||
if (!playlistId) {
|
if (!playlistId) {
|
||||||
return {
|
return {
|
||||||
status: "error",
|
status: "error",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user