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;
|
break;
|
||||||
|
|
||||||
|
case "vk":
|
||||||
case "tiktok":
|
case "tiktok":
|
||||||
params = {
|
params = {
|
||||||
type: r.subtitles ? "remux" : "proxy"
|
type: r.subtitles ? "remux" : "proxy"
|
||||||
@ -176,7 +177,6 @@ export default function({
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "ok":
|
case "ok":
|
||||||
case "vk":
|
|
||||||
case "xiaohongshu":
|
case "xiaohongshu":
|
||||||
params = { type: "proxy" };
|
params = { type: "proxy" };
|
||||||
break;
|
break;
|
||||||
|
@ -92,7 +92,8 @@ export default async function({ host, patternMatch, params, isSession, isApiKey
|
|||||||
ownerId: patternMatch.ownerId,
|
ownerId: patternMatch.ownerId,
|
||||||
videoId: patternMatch.videoId,
|
videoId: patternMatch.videoId,
|
||||||
accessKey: patternMatch.accessKey,
|
accessKey: patternMatch.accessKey,
|
||||||
quality: params.videoQuality
|
quality: params.videoQuality,
|
||||||
|
subtitleLang,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ const getVideo = async (ownerId, videoId, accessKey) => {
|
|||||||
return video;
|
return video;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function ({ ownerId, videoId, accessKey, quality }) {
|
export default async function ({ ownerId, videoId, accessKey, quality, subtitleLang }) {
|
||||||
const token = await getToken();
|
const token = await getToken();
|
||||||
if (!token) return { error: "fetch.fail" };
|
if (!token) return { error: "fetch.fail" };
|
||||||
|
|
||||||
@ -125,8 +125,20 @@ export default async function ({ ownerId, videoId, accessKey, quality }) {
|
|||||||
title: video.title.trim(),
|
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 {
|
return {
|
||||||
urls: url,
|
urls: url,
|
||||||
|
subtitles,
|
||||||
fileMetadata,
|
fileMetadata,
|
||||||
filenameAttributes: {
|
filenameAttributes: {
|
||||||
service: "vk",
|
service: "vk",
|
||||||
|
Loading…
Reference in New Issue
Block a user