fix: use correct url (#13)

This commit is contained in:
Irfan
2021-12-02 13:53:10 +05:30
committed by GitHub
parent 136cbd00de
commit b6f0639ce2
2 changed files with 7 additions and 9 deletions

View File

@@ -13,17 +13,15 @@ export async function getSubtitles({
lang: 'en' | 'de' | 'fr' | void,
}) {
const { data } = await axios.get(
`https://youtube.com/get_video_info?video_id=${videoID}`
`https://youtube.com/watch?v=${videoID}`
);
const decodedData = decodeURIComponent(data);
// * ensure we have access to captions data
if (!decodedData.includes('captionTracks'))
if (!data.includes('captionTracks'))
throw new Error(`Could not find captions for video: ${videoID}`);
const regex = /({"captionTracks":.*isTranslatable":(true|false)}])/;
const [match] = regex.exec(decodedData);
const [match] = regex.exec(data);
const { captionTracks } = JSON.parse(`${match}}`);
const subtitle =