diff --git a/package-lock.json b/package-lock.json index b83b8d1..cbf14a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@movie-web/providers", - "version": "1.1.2", + "version": "1.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@movie-web/providers", - "version": "1.1.2", + "version": "1.1.4", "license": "MIT", "dependencies": { "cheerio": "^1.0.0-rc.12", @@ -3040,7 +3040,8 @@ }, "node_modules/json5": { "version": "2.2.3", - "license": "MIT", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "bin": { "json5": "lib/cli.js" }, diff --git a/package.json b/package.json index 5c4d1ee..c8187c1 100644 --- a/package.json +++ b/package.json @@ -79,8 +79,8 @@ "cheerio": "^1.0.0-rc.12", "crypto-js": "^4.1.1", "form-data": "^4.0.0", - "json5": "^2.2.3", "iso-639-1": "^3.1.0", + "json5": "^2.2.3", "nanoid": "^3.3.6", "node-fetch": "^2.7.0", "unpacker": "^1.0.1" diff --git a/src/main/targets.ts b/src/main/targets.ts index 26b0391..eb791c2 100644 --- a/src/main/targets.ts +++ b/src/main/targets.ts @@ -1,5 +1,6 @@ export const flags = { NO_CORS: 'no-cors', + IP_LOCKED: 'ip-locked', } as const; export type Flags = (typeof flags)[keyof typeof flags]; diff --git a/src/providers/sources/lookmovie/index.ts b/src/providers/sources/lookmovie/index.ts index ea552b5..b673cfc 100644 --- a/src/providers/sources/lookmovie/index.ts +++ b/src/providers/sources/lookmovie/index.ts @@ -1,3 +1,4 @@ +import { flags } from '@/main/targets'; import { SourcererOutput, makeSourcerer } from '@/providers/base'; import { NotFoundError } from '@/utils/errors'; @@ -19,7 +20,7 @@ async function universalScraper(ctx: ShowContext | MovieContext): Promise { if (media.type === 'show') { - const searchRes = await ctx.fetcher(`/v1/shows?filters[q]=${media.title}`, { + const searchRes = await ctx.fetcher(`/v1/shows`, { baseUrl: 'https://lmscript.xyz', + query: { 'filters[q]': media.title }, }); const results = searchRes.items; @@ -21,8 +22,9 @@ export async function searchAndFindMedia( return result; } if (media.type === 'movie') { - const searchRes = await ctx.fetcher(`/v1/movies?filters[q]=${media.title}`, { + const searchRes = await ctx.fetcher(`/v1/movies`, { baseUrl: 'https://lmscript.xyz', + query: { 'filters[q]': media.title }, }); const results = searchRes.items; @@ -37,15 +39,16 @@ export async function scrape(ctx: ScrapeContext, media: MovieMedia | ShowMedia, if (media.type === 'movie') { id = result.id_movie; } else if (media.type === 'show') { - const data = await ctx.fetcher(`/v1/shows?expand=episodes&id=${result.id_show}`, { + const data = await ctx.fetcher(`/v1/shows`, { baseUrl: 'https://lmscript.xyz', + query: { expand: 'episodes', id: result.id_show }, }); - const episodeObj = data.episodes?.find((v: any) => { + const episode = data.episodes?.find((v: episodeObj) => { return Number(v.season) === Number(media.season.number) && Number(v.episode) === Number(media.episode.number); }); - if (episodeObj) id = episodeObj.id; + if (episode) id = episode.id; } // Check ID diff --git a/src/providers/sources/lookmovie/video.ts b/src/providers/sources/lookmovie/video.ts index a5003a7..fc05b9b 100644 --- a/src/providers/sources/lookmovie/video.ts +++ b/src/providers/sources/lookmovie/video.ts @@ -1,22 +1,29 @@ import { MovieMedia, ShowMedia } from '@/main/media'; import { ScrapeContext } from '@/utils/context'; +import { StreamsDataResult } from './type'; + export async function getVideoSources(ctx: ScrapeContext, id: any, media: MovieMedia | ShowMedia): Promise { // Fetch video sources let path = ''; if (media.type === 'show') { - path = `/v1/episodes/view?expand=streams&id=${id}`; + path = `/v1/episodes/view`; } else if (media.type === 'movie') { - path = `/v1/movies/view?expand=streams&id=${id}`; + path = `/v1/movies/view`; } - const data = await ctx.fetcher(path, { + const data = await ctx.fetcher(path, { baseUrl: 'https://lmscript.xyz', + query: { expand: 'streams', id }, }); return data; } -export async function getVideoUrl(ctx: ScrapeContext, id: any, media: MovieMedia | ShowMedia): Promise { +export async function getVideoUrl( + ctx: ScrapeContext, + id: string, + media: MovieMedia | ShowMedia, +): Promise { // Get sources const data = await getVideoSources(ctx, id, media); const videoSources = data.streams;