Removed test comment changed search url

This commit is contained in:
MemeCornucopia
2023-11-21 19:36:42 -05:00
parent 36d70fa6fd
commit e962bb410f
3 changed files with 3550 additions and 7 deletions

3535
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -9,7 +9,6 @@ async function universalScraper(ctx: ShowContext | MovieContext): Promise<Source
if (!lookmovieData) throw new NotFoundError('Media not found');
ctx.progress(30);
//test
const videoUrl = await scrape(ctx.media, lookmovieData);
if (!videoUrl) throw new NotFoundError('No video found');

View File

@@ -8,12 +8,21 @@ import { Result } from './type';
import { getVideoUrl } from './video';
export async function searchAndFindMedia(media: MovieMedia | ShowMedia): Promise<Result | undefined> {
const searchRes = await fetch(
`https://lookmovie2.to/api/v1/${media.type}s/do-search/?q=${encodeURIComponent(media.title)}`,
).then((d) => d.json());
if (media.type === "show") {
const searchRes = await fetch(`https://lmscript.xyz/v1/shows?filters[q]=${encodeURIComponent(media.title)}`).then((d) => d.json());
const results = searchRes.result;
const result = results.find((res: Result) => compareMedia(media, res.title, Number(res.year)));
return result;
} else if (media.type === "movie") {
const searchRes = await fetch(`https://lmscript.xyz/v1/movies?filters[q]=${encodeURIComponent(media.title)}`).then((d) => d.json());
const results = searchRes.items;
const result = results.find((res: Result) => compareMedia(media, res.title, Number(res.year)));
return result;
}
}
export async function scrape(media: MovieMedia | ShowMedia, result: Result) {