diff --git a/src/mw_constants.ts b/src/mw_constants.ts index ad176657..53a72033 100644 --- a/src/mw_constants.ts +++ b/src/mw_constants.ts @@ -1,3 +1,4 @@ export const CORS_PROXY_URL = "https://proxy-1.movie-web.workers.dev/?destination="; +export const OMDB_API_KEY = "aa0937c0"; export const DISCORD_LINK = "https://discord.gg/Jhqt4Xzpfb"; export const GITHUB_LINK = "https://github.com/JamesHawkinss/movie-web"; diff --git a/src/providers/list/gomostream/index.ts b/src/providers/list/gomostream/index.ts new file mode 100644 index 00000000..50eb041c --- /dev/null +++ b/src/providers/list/gomostream/index.ts @@ -0,0 +1,97 @@ +import { + MWMediaProvider, + MWMediaType, + MWPortableMedia, + MWMediaStream, + MWQuery, + MWMediaSeasons, + MWProviderMediaResult +} from "providers/types"; + +import { CORS_PROXY_URL, OMDB_API_KEY } from "mw_constants"; +import { unpack } from "unpacker"; + +export const gomostreamScraper: MWMediaProvider = { + id: "gomostream", + enabled: true, + type: [MWMediaType.MOVIE], + displayName: "gomostream", + + async getMediaFromPortable(media: MWPortableMedia): Promise { + const params = new URLSearchParams({ + apikey: OMDB_API_KEY, + i: media.mediaId, + type: media.mediaType + }); + + const res = await fetch( + `${CORS_PROXY_URL}http://www.omdbapi.com/?${encodeURIComponent(params.toString())}`, + ).then(d => d.json()) + + return { + ...media, + title: res.Title, + year: res.Year + } as MWProviderMediaResult; + }, + + async searchForMedia(query: MWQuery): Promise { + const term = query.searchQuery.toLowerCase(); + + const params = new URLSearchParams({ + apikey: OMDB_API_KEY, + s: term, + type: query.type + }); + const searchRes = await fetch( + `${CORS_PROXY_URL}http://www.omdbapi.com/?${encodeURIComponent(params.toString())}`, + ).then(d => d.json()) + + const results: MWProviderMediaResult[] = searchRes.Search.map((d: any) => ({ + title: d.Title, + year: d.Year, + mediaId: d.imdbID + } as MWProviderMediaResult)); + + return results; + }, + + async getStream(media: MWPortableMedia): Promise { + const type = media.mediaType === MWMediaType.SERIES ? 'show' : media.mediaType; + const res1 = await fetch(`${CORS_PROXY_URL}https://gomo.to/${type}/${media.mediaId}`).then((d) => d.text()); + if (res1 === "Movie not available." || res1 === "Episode not available.") throw new Error(res1); + + const tc = res1.match(/var tc = '(.+)';/)?.[1] || ""; + const _token = res1.match(/"_token": "(.+)",/)?.[1] || ""; + + const fd = new FormData() + fd.append('tokenCode', tc) + fd.append('_token', _token) + + const src = await fetch(`${CORS_PROXY_URL}https://gomo.to/decoding_v3.php`, { + method: "POST", + body: fd, + headers: { + 'x-token': `${tc.slice(5, 13).split("").reverse().join("")}13574199` + } + }).then((d) => d.json()); + + const embedUrl = src.find((url: string) => url.includes('gomo.to')); + const res2 = await fetch(`${CORS_PROXY_URL}${embedUrl}`).then((d) => d.text()); + + const res2DOM = new DOMParser().parseFromString(res2, "text/html"); + if (res2DOM.body.innerText === "File was deleted") throw new Error("File was deleted"); + + const script = res2DOM.querySelectorAll("script")[8].innerHTML; + const unpacked = unpack(script).split(''); + unpacked.splice(0, 43); + const index = unpacked.findIndex((e) => e === '"'); + const streamUrl = unpacked.slice(0, index).join(''); + + return { url: streamUrl, type: 'mp4', captions: [] }; + }, + + async getSeasonDataFromMedia(media: MWPortableMedia): Promise { + return {} as MWMediaSeasons; + } +}; diff --git a/src/providers/methods/providers.ts b/src/providers/methods/providers.ts index 5e9491a0..720b42c2 100644 --- a/src/providers/methods/providers.ts +++ b/src/providers/methods/providers.ts @@ -1,10 +1,12 @@ import { theFlixScraper } from "providers/list/theflix"; import { gDrivePlayerScraper } from "providers/list/gdriveplayer"; import { MWWrappedMediaProvider, WrapProvider } from "providers/wrapper"; +import { gomostreamScraper } from "providers/list/gomostream"; export const mediaProvidersUnchecked: MWWrappedMediaProvider[] = [ WrapProvider(theFlixScraper), WrapProvider(gDrivePlayerScraper), + WrapProvider(gomostreamScraper), ]; export const mediaProviders: MWWrappedMediaProvider[] =