From e2270065bcdfc0e73d314dfee0a6af434ab43027 Mon Sep 17 00:00:00 2001 From: prassamin Date: Sun, 8 Dec 2024 04:21:37 +0600 Subject: [PATCH] Fix: Handle Tiktok Music URLs in v2(sssTik) --- src/types/downloader/ssstik.ts | 7 ++++--- src/utils/downloader/ssstik.ts | 11 ++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/types/downloader/ssstik.ts b/src/types/downloader/ssstik.ts index 898ea56..09bbe22 100644 --- a/src/types/downloader/ssstik.ts +++ b/src/types/downloader/ssstik.ts @@ -8,13 +8,14 @@ export type SSSTikResponse = { status: "success" | "error" message?: string result?: { - type: "image" | "video" + type: "image" | "video" | "music" desc?: string - author: Author - statistics: Statistics + author?: Author + statistics?: Statistics images?: string[] video?: string music?: string + direct?: string } } diff --git a/src/utils/downloader/ssstik.ts b/src/utils/downloader/ssstik.ts index e8173e8..1d18b7e 100644 --- a/src/utils/downloader/ssstik.ts +++ b/src/utils/downloader/ssstik.ts @@ -5,7 +5,7 @@ import { Author, Statistics, SSSTikFetchTT, - SSSTikResponse + SSSTikResponse, } from "../../types/downloader/ssstik" import { _ssstikapi, _ssstikurl } from "../../constants/api" import { HttpsProxyAgent } from "https-proxy-agent" @@ -132,6 +132,7 @@ export const SSSTik = (url: string, proxy?: string): Promise => // Video & Music Result const video = $("a.without_watermark").attr("href") const music = $("a.music").attr("href") + const direct = $("a.music_direct").attr("href") // Images / Slide Result const images: string[] = [] @@ -168,7 +169,15 @@ export const SSSTik = (url: string, proxy?: string): Promise => if (music) { result.music = music } + } else if (music) { + // Music Result + result = { + type: "music", + music, + direct: direct || "", + } } + resolve({ status: "success", result }) } catch (err) { resolve({ status: "error", message: err.message })