api/vk: add support for subtitles

This commit is contained in:
wukko 2025-06-24 17:06:19 +06:00
parent 44f4ea32c6
commit 997b06ed0e
No known key found for this signature in database
GPG Key ID: 3E30B3F26C7B4AA2
3 changed files with 16 additions and 3 deletions

View File

@ -169,6 +169,7 @@ export default function({
}
break;
case "vk":
case "tiktok":
params = {
type: r.subtitles ? "remux" : "proxy"
@ -176,7 +177,6 @@ export default function({
break;
case "ok":
case "vk":
case "xiaohongshu":
params = { type: "proxy" };
break;

View File

@ -92,7 +92,8 @@ export default async function({ host, patternMatch, params, isSession, isApiKey
ownerId: patternMatch.ownerId,
videoId: patternMatch.videoId,
accessKey: patternMatch.accessKey,
quality: params.videoQuality
quality: params.videoQuality,
subtitleLang,
});
break;

View File

@ -76,7 +76,7 @@ const getVideo = async (ownerId, videoId, accessKey) => {
return video;
}
export default async function ({ ownerId, videoId, accessKey, quality }) {
export default async function ({ ownerId, videoId, accessKey, quality, subtitleLang }) {
const token = await getToken();
if (!token) return { error: "fetch.fail" };
@ -125,8 +125,20 @@ export default async function ({ ownerId, videoId, accessKey, quality }) {
title: video.title.trim(),
}
let subtitles;
if (subtitleLang && video.subtitles?.length) {
const subtitle = video.subtitles.find(
s => !s.is_auto && s.lang.startsWith(subtitleLang)
);
if (subtitle) {
subtitles = subtitle.url;
fileMetadata.sublanguage = subtitleLang;
}
}
return {
urls: url,
subtitles,
fileMetadata,
filenameAttributes: {
service: "vk",