diff --git a/src/vidsrcto.js b/src/vidsrcto.js index 808fe3e..a584ce7 100644 --- a/src/vidsrcto.js +++ b/src/vidsrcto.js @@ -109,8 +109,19 @@ async function episode(data_id) { } export async function getmovie(id) { + let resp = await (await fetch(`https://vidsrc.to/embed/movie/${id}`)).text(); - let data_id = (/data-id="(.*?)"/g).exec(resp)[1]; + + // Validate the response content + console.log(resp); + + const match = (/data-id="(.*?)"/g).exec(resp); + + if (!match) { + throw new Error('Failed to extract data-id from response'); + } + + let data_id = match[1]; return episode(data_id); }