Added Base URL Declaration

This commit is contained in:
MemeCornucopia
2024-01-28 14:27:07 -05:00
parent 5edd540a50
commit d6624efc5a
3 changed files with 13 additions and 9 deletions

View File

@@ -2,13 +2,13 @@ import { load } from 'cheerio';
import { ScrapeContext } from '@/utils/context'; import { ScrapeContext } from '@/utils/context';
import { EmbedsResult } from './type'; import { EmbedsResult, baseUrl, baseUrl2 } from './type';
export async function getEmbeds(ctx: ScrapeContext, id: string): Promise<EmbedsResult> { export async function getEmbeds(ctx: ScrapeContext, id: string): Promise<EmbedsResult> {
const data = await ctx.fetcher.full(`/${id}`, { const data = await ctx.fetcher.full(`/${id}`, {
baseUrl: 'https://ww1.goojara.to', baseUrl: baseUrl2,
headers: { headers: {
Referer: 'https://www.goojara.to/', Referer: baseUrl,
}, },
readHeaders: ['Set-Cookie'], readHeaders: ['Set-Cookie'],
method: 'GET', method: 'GET',
@@ -23,7 +23,7 @@ export async function getEmbeds(ctx: ScrapeContext, id: string): Promise<EmbedsR
const embedRedirectURLs = $('a') const embedRedirectURLs = $('a')
.map((index, element) => $(element).attr('href')) .map((index, element) => $(element).attr('href'))
.get() .get()
.filter((href) => href && href.includes('https://ww1.goojara.to/go.php')); .filter((href) => href && href.includes(`${baseUrl2}/go.php`));
const embedPages = await Promise.all( const embedPages = await Promise.all(
embedRedirectURLs.map( embedRedirectURLs.map(
@@ -32,7 +32,7 @@ export async function getEmbeds(ctx: ScrapeContext, id: string): Promise<EmbedsR
.full(url, { .full(url, {
headers: { headers: {
cookie: `aGooz=${aGoozCookie}; ${RandomCookieName}=${RandomCookieValue};`, cookie: `aGooz=${aGoozCookie}; ${RandomCookieName}=${RandomCookieValue};`,
Referer: 'https://ww1.goojara.to/eJwD5z', Referer: baseUrl2,
}, },
method: 'GET', method: 'GET',
}) })

View File

@@ -1,3 +1,7 @@
export const baseUrl = 'https://www.goojara.to';
export const baseUrl2 = 'https://ww1.goojara.to';
export type EmbedsResult = { embedId: string; url: string }[]; export type EmbedsResult = { embedId: string; url: string }[];
export interface Result { export interface Result {

View File

@@ -7,7 +7,7 @@ import { ScrapeContext } from '@/utils/context';
import { NotFoundError } from '@/utils/errors'; import { NotFoundError } from '@/utils/errors';
import { getEmbeds } from './getEmbeds'; import { getEmbeds } from './getEmbeds';
import { EmbedsResult, Result } from './type'; import { EmbedsResult, Result, baseUrl } from './type';
let data; let data;
@@ -23,7 +23,7 @@ export async function searchAndFindMedia(
media: MovieMedia | ShowMedia, media: MovieMedia | ShowMedia,
): Promise<Result | undefined> { ): Promise<Result | undefined> {
data = await ctx.fetcher<string>(`/xhrr.php`, { data = await ctx.fetcher<string>(`/xhrr.php`, {
baseUrl: 'https://www.goojara.to', baseUrl,
headers: headersData, headers: headersData,
method: 'POST', method: 'POST',
body: new URLSearchParams({ q: media.title }), body: new URLSearchParams({ q: media.title }),
@@ -66,7 +66,7 @@ export async function scrapeIds(
id = result.slug; id = result.slug;
} else if (media.type === 'show') { } else if (media.type === 'show') {
data = await ctx.fetcher<string>(`/${result.slug}`, { data = await ctx.fetcher<string>(`/${result.slug}`, {
baseUrl: 'https://www.goojara.to', baseUrl,
headers: headersData, headers: headersData,
method: 'GET', method: 'GET',
}); });
@@ -78,7 +78,7 @@ export async function scrapeIds(
if (!dataId) throw NotFoundError; if (!dataId) throw NotFoundError;
data = await ctx.fetcher<string>(`/xhrc.php`, { data = await ctx.fetcher<string>(`/xhrc.php`, {
baseUrl: 'https://ww1.goojara.to', baseUrl,
headers: headersData, headers: headersData,
method: 'POST', method: 'POST',
body: new URLSearchParams({ s: media.season.number.toString(), t: dataId }), body: new URLSearchParams({ s: media.season.number.toString(), t: dataId }),