refactor: changed the file name and API to ssstik
This commit is contained in:
parent
3697494696
commit
8bccf19644
@ -1,10 +1,10 @@
|
|||||||
export interface TiktokFetchTT {
|
export interface SSSTikFetchTT {
|
||||||
status: "success" | "error"
|
status: "success" | "error"
|
||||||
message?: string
|
message?: string
|
||||||
result?: string
|
result?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TiktokDownload {
|
export interface SSSTikResult {
|
||||||
status: "success" | "error"
|
status: "success" | "error"
|
||||||
message?: string
|
message?: string
|
||||||
result?: {
|
result?: {
|
||||||
@ -1,12 +1,12 @@
|
|||||||
import Axios from "axios"
|
import Axios from "axios"
|
||||||
import { load } from "cheerio"
|
import { load } from "cheerio"
|
||||||
import { Author, Statistics, TiktokFetchTT } from "../types/tiktokdownload"
|
import { Author, Statistics, SSSTikFetchTT, SSSTikResult } from "../types/ssstik"
|
||||||
|
|
||||||
const fetchTT = (): Promise<TiktokFetchTT> =>
|
const fetchTT = () =>
|
||||||
new Promise(async (resolve, reject) => {
|
new Promise<SSSTikFetchTT>(async (resolve, reject) => {
|
||||||
Axios.get("https://tiktokdownload.online/", {
|
Axios.get("https://ssstik.io", {
|
||||||
headers: {
|
headers: {
|
||||||
"user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0"
|
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
@ -22,12 +22,18 @@ const fetchTT = (): Promise<TiktokFetchTT> =>
|
|||||||
.catch((e) => resolve({ status: "error", message: e.message }))
|
.catch((e) => resolve({ status: "error", message: e.message }))
|
||||||
})
|
})
|
||||||
|
|
||||||
export const TiktokDownload = (url: string) =>
|
export const SSSTik = (url: string) =>
|
||||||
new Promise(async (resolve, reject) => {
|
new Promise<SSSTikResult>(async (resolve, reject) => {
|
||||||
const tt: TiktokFetchTT = await fetchTT()
|
const tt: SSSTikFetchTT = await fetchTT()
|
||||||
if (tt.status !== "success") return resolve(tt)
|
if (tt.status !== "success") return resolve({ status: "error", message: tt.message })
|
||||||
Axios("https://tiktokdownload.online/abc?url=dl", {
|
Axios("https://ssstik.io/abc?url=dl", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||||
|
Origin: "https://ssstik.io",
|
||||||
|
Referer: "https://ssstik.io/en",
|
||||||
|
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0"
|
||||||
|
},
|
||||||
data: new URLSearchParams(
|
data: new URLSearchParams(
|
||||||
Object.entries({
|
Object.entries({
|
||||||
id: url,
|
id: url,
|
||||||
@ -87,5 +93,5 @@ export const TiktokDownload = (url: string) =>
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(console.log)
|
.catch((e) => resolve({ status: "error", message: e.message }))
|
||||||
})
|
})
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { TiktokDownload } from "./tiktokdownload"
|
import { SSSTik } from "./ssstik"
|
||||||
import { TiktokAPI } from "./tiktokapi"
|
import { TiktokAPI } from "./tiktokapi"
|
||||||
|
|
||||||
export const TiktokDL = (url: string, options: { version: "v1" | "v2" }) =>
|
export const TiktokDL = (url: string, options: { version: "v1" | "v2" }) =>
|
||||||
@ -8,7 +8,7 @@ export const TiktokDL = (url: string, options: { version: "v1" | "v2" }) =>
|
|||||||
await TiktokAPI(url).then(resolve).catch(reject)
|
await TiktokAPI(url).then(resolve).catch(reject)
|
||||||
}
|
}
|
||||||
case "v2": {
|
case "v2": {
|
||||||
await TiktokDownload(url).then(resolve).catch(reject)
|
await SSSTik(url).then(resolve).catch(reject)
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
await TiktokAPI(url).then(resolve).catch(reject)
|
await TiktokAPI(url).then(resolve).catch(reject)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user