mirror of
https://github.com/imputnet/cobalt.git
synced 2025-06-27 17:08:28 +00:00
api/tiktok: add support for subtitles
This commit is contained in:
parent
aff2d22edc
commit
630e4a6e0d
@ -169,9 +169,14 @@ export default function({
|
||||
}
|
||||
break;
|
||||
|
||||
case "tiktok":
|
||||
params = {
|
||||
type: r.subtitles ? "remux" : "proxy"
|
||||
};
|
||||
break;
|
||||
|
||||
case "ok":
|
||||
case "vk":
|
||||
case "tiktok":
|
||||
case "xiaohongshu":
|
||||
params = { type: "proxy" };
|
||||
break;
|
||||
|
@ -150,6 +150,7 @@ export default async function({ host, patternMatch, params, isSession, isApiKey
|
||||
isAudioOnly,
|
||||
h265: params.allowH265,
|
||||
alwaysProxy: params.alwaysProxy,
|
||||
subtitleLang,
|
||||
});
|
||||
break;
|
||||
|
||||
|
@ -4,6 +4,7 @@ import { extract, normalizeURL } from "../url.js";
|
||||
import { genericUserAgent } from "../../config.js";
|
||||
import { updateCookie } from "../cookie/manager.js";
|
||||
import { createStream } from "../../stream/manage.js";
|
||||
import { convertLanguageCode } from "../../misc/language-codes.js";
|
||||
|
||||
const shortDomain = "https://vt.tiktok.com/";
|
||||
|
||||
@ -97,8 +98,23 @@ export default async function(obj) {
|
||||
}
|
||||
|
||||
if (video) {
|
||||
let subtitles, fileMetadata;
|
||||
if (obj.subtitleLang && detail?.video?.subtitleInfos?.length) {
|
||||
const langCode = convertLanguageCode(obj.subtitleLang);
|
||||
const subtitle = detail?.video?.subtitleInfos.find(
|
||||
s => s.LanguageCodeName.startsWith(langCode) && s.Format === "webvtt"
|
||||
)
|
||||
if (subtitle) {
|
||||
subtitles = subtitle.Url;
|
||||
fileMetadata = {
|
||||
sublanguage: langCode,
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
urls: video,
|
||||
subtitles,
|
||||
fileMetadata,
|
||||
filename: videoFilename,
|
||||
headers: { cookie }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user