mirror of
https://github.com/imputnet/cobalt.git
synced 2025-06-28 01:18:27 +00:00
api/vk: add support for subtitles
This commit is contained in:
parent
44f4ea32c6
commit
997b06ed0e
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user