fix(v3): repair musicalDown broken logics
This commit is contained in:
parent
b5955b75b4
commit
732c0d4c14
@ -48,7 +48,8 @@ async function handleMediaDownload(
|
|||||||
|
|
||||||
const { result } = data
|
const { result } = data
|
||||||
const author = result.author
|
const author = result.author
|
||||||
const username = version === "v1" ? author.username : author.nickname
|
const username =
|
||||||
|
version === "v1" ? author.username : version === "v2" ? author.nickname : ""
|
||||||
|
|
||||||
Logger.success(
|
Logger.success(
|
||||||
`${
|
`${
|
||||||
@ -63,7 +64,7 @@ async function handleMediaDownload(
|
|||||||
version === "v1"
|
version === "v1"
|
||||||
? result.video.downloadAddr[0]
|
? result.video.downloadAddr[0]
|
||||||
: version === "v2"
|
: version === "v2"
|
||||||
? result.video
|
? result.video.playAddr[0]
|
||||||
: result.videoHD
|
: result.videoHD
|
||||||
const videoName = `ttdl_${username}_${Date.now()}.mp4`
|
const videoName = `ttdl_${username}_${Date.now()}.mp4`
|
||||||
|
|
||||||
|
|||||||
@ -1,19 +1,14 @@
|
|||||||
import Axios from "axios"
|
import Axios from "axios"
|
||||||
import { load } from "cheerio"
|
import { load } from "cheerio"
|
||||||
type CheerioAPI = ReturnType<typeof load>
|
|
||||||
import {
|
import {
|
||||||
MusicalDownResponse,
|
MusicalDownResponse,
|
||||||
GetMusicalDownMusic,
|
|
||||||
GetMusicalDownReuqest
|
GetMusicalDownReuqest
|
||||||
} from "../../types/downloader/musicaldown"
|
} from "../../types/downloader/musicaldown"
|
||||||
import {
|
import { _musicaldownapi, _musicaldownurl } from "../../constants/api"
|
||||||
_musicaldownapi,
|
|
||||||
_musicaldownmusicapi,
|
|
||||||
_musicaldownurl
|
|
||||||
} from "../../constants/api"
|
|
||||||
import { HttpsProxyAgent } from "https-proxy-agent"
|
import { HttpsProxyAgent } from "https-proxy-agent"
|
||||||
import { SocksProxyAgent } from "socks-proxy-agent"
|
import { SocksProxyAgent } from "socks-proxy-agent"
|
||||||
import { ERROR_MESSAGES } from "../../constants"
|
import { ERROR_MESSAGES } from "../../constants"
|
||||||
|
type CheerioAPI = ReturnType<typeof load>
|
||||||
|
|
||||||
/** Constants */
|
/** Constants */
|
||||||
const TIKTOK_URL_REGEX =
|
const TIKTOK_URL_REGEX =
|
||||||
@ -59,10 +54,10 @@ const isValidUrl = (url: string): boolean => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const extractRequestForm = ($: CheerioAPI): RequestForm => {
|
const extractRequestForm = ($: CheerioAPI, url: string): RequestForm => {
|
||||||
const input = $("div > input").map((_, el) => $(el))
|
const input = $("div > input").map((_, el) => $(el))
|
||||||
return {
|
return {
|
||||||
[input.get(0).attr("name") || ""]: input.get(0).attr("value") || "",
|
[input.get(0).attr("name") || ""]: input.get(0).attr("value") || url,
|
||||||
[input.get(1).attr("name") || ""]: input.get(1).attr("value") || "",
|
[input.get(1).attr("name") || ""]: input.get(1).attr("value") || "",
|
||||||
[input.get(2).attr("name") || ""]: input.get(2).attr("value") || ""
|
[input.get(2).attr("name") || ""]: input.get(2).attr("value") || ""
|
||||||
}
|
}
|
||||||
@ -170,7 +165,7 @@ const getRequest = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const $ = load(data)
|
const $ = load(data)
|
||||||
const request = extractRequestForm($)
|
const request = extractRequestForm($, url)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
status: "success",
|
status: "success",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user