fix: error when download images from musicaldown

This commit is contained in:
Tobi Saputra 2025-03-03 20:59:38 +07:00
parent fcc542f462
commit d92bb6942a
2 changed files with 43 additions and 28 deletions

View File

@ -1,7 +1,17 @@
export type TiktokUserSearchResponse = {
status: "success" | "error"
message?: string
result?: Result[]
result?: Array<{
uid: string
username: string
nickname: string
signature: string
followerCount: number
avatarThumb: string
isVerified: boolean
secUid: string
url: string
}>
page?: number
totalResults?: number
}
@ -17,3 +27,8 @@ export type Result = {
secUid: string
url: string
}
export interface IUserSearch {
saveSearch(searchTerm: string): void
getLastSearch(): string | null
}

View File

@ -138,32 +138,6 @@ export const MusicalDown = (
images.push($(v).find("img").attr("src"))
})
// Get Result Video
let i = 1
let videos = {}
$("div.row > div")
.map((_, el) => $(el))
.get(1)
.find("a")
.get()
.map((v: any) => {
if ($(v).attr("href") !== "#modal2") {
if (!isURL($(v).attr("href"))) return
videos[
$(v).attr("data-event").includes("hd")
? "videoHD"
: $(v).attr("data-event").includes("mp4")
? "videoSD"
: $(v).attr("data-event").includes("watermark")
? "videoWatermark"
: $(v).attr("href").includes("type=mp3") && "music"
] =
$(v).attr("href") != undefined
? $(v).attr("href")
: /downloadX\('([^']+)'\)/.exec($(v).attr("onclick"))[1]
i++
}
})
// Result
if (images.length !== 0) {
// Images or Slide Result
@ -176,7 +150,33 @@ export const MusicalDown = (
})
} else {
// Video Result
// const music = await getMusic(request.cookie)
// Get Result Video
let i = 1
let videos = {}
$("div.row > div")
.map((_, el) => $(el))
.get(1)
.find("a")
.get()
.map((v: any) => {
if ($(v).attr("href") !== "#modal2") {
if (!isURL($(v).attr("href"))) return
videos[
$(v).attr("data-event").includes("hd")
? "videoHD"
: $(v).attr("data-event").includes("mp4")
? "videoSD"
: $(v).attr("data-event").includes("watermark")
? "videoWatermark"
: $(v).attr("href").includes("type=mp3") && "music"
] =
$(v).attr("href") != undefined
? $(v).attr("href")
: /downloadX\('([^']+)'\)/.exec($(v).attr("onclick"))[1]
i++
}
})
if (Object.keys(videos).length === 0)
return resolve({
status: "success",