mirror of
https://github.com/imputnet/cobalt.git
synced 2025-06-28 09:28:29 +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;
|
break;
|
||||||
|
|
||||||
|
case "tiktok":
|
||||||
|
params = {
|
||||||
|
type: r.subtitles ? "remux" : "proxy"
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
|
||||||
case "ok":
|
case "ok":
|
||||||
case "vk":
|
case "vk":
|
||||||
case "tiktok":
|
|
||||||
case "xiaohongshu":
|
case "xiaohongshu":
|
||||||
params = { type: "proxy" };
|
params = { type: "proxy" };
|
||||||
break;
|
break;
|
||||||
|
@ -150,6 +150,7 @@ export default async function({ host, patternMatch, params, isSession, isApiKey
|
|||||||
isAudioOnly,
|
isAudioOnly,
|
||||||
h265: params.allowH265,
|
h265: params.allowH265,
|
||||||
alwaysProxy: params.alwaysProxy,
|
alwaysProxy: params.alwaysProxy,
|
||||||
|
subtitleLang,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import { extract, normalizeURL } from "../url.js";
|
|||||||
import { genericUserAgent } from "../../config.js";
|
import { genericUserAgent } from "../../config.js";
|
||||||
import { updateCookie } from "../cookie/manager.js";
|
import { updateCookie } from "../cookie/manager.js";
|
||||||
import { createStream } from "../../stream/manage.js";
|
import { createStream } from "../../stream/manage.js";
|
||||||
|
import { convertLanguageCode } from "../../misc/language-codes.js";
|
||||||
|
|
||||||
const shortDomain = "https://vt.tiktok.com/";
|
const shortDomain = "https://vt.tiktok.com/";
|
||||||
|
|
||||||
@ -97,8 +98,23 @@ export default async function(obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (video) {
|
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 {
|
return {
|
||||||
urls: video,
|
urls: video,
|
||||||
|
subtitles,
|
||||||
|
fileMetadata,
|
||||||
filename: videoFilename,
|
filename: videoFilename,
|
||||||
headers: { cookie }
|
headers: { cookie }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user