From 34b2fb74ae90113a423d845f106183d07d9fbe64 Mon Sep 17 00:00:00 2001 From: TPN Date: Tue, 16 Jul 2024 07:55:31 +0000 Subject: [PATCH] Update login --- src/providers/sources/ee3/common.ts | 4 ++-- src/providers/sources/ee3/types.ts | 5 +++++ src/providers/sources/ee3/utils.ts | 26 +++++++++++++------------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/providers/sources/ee3/common.ts b/src/providers/sources/ee3/common.ts index 1b88847..f1201cc 100644 --- a/src/providers/sources/ee3/common.ts +++ b/src/providers/sources/ee3/common.ts @@ -2,6 +2,6 @@ export const useAltEndpoint: boolean = false; export const baseUrl = useAltEndpoint ? 'https://rips.cc' : 'https://ee3.me'; -export const username = ''; +export const username = '_sf_'; -export const password = ''; +export const password = 'defonotscraping'; diff --git a/src/providers/sources/ee3/types.ts b/src/providers/sources/ee3/types.ts index c9b2534..6728c9c 100644 --- a/src/providers/sources/ee3/types.ts +++ b/src/providers/sources/ee3/types.ts @@ -24,3 +24,8 @@ export interface renewResponse { msg?: string | null; status: number | string | null; } + +export interface loginResponse { + status: number; + message: string; +} diff --git a/src/providers/sources/ee3/utils.ts b/src/providers/sources/ee3/utils.ts index d77f280..a797977 100644 --- a/src/providers/sources/ee3/utils.ts +++ b/src/providers/sources/ee3/utils.ts @@ -4,28 +4,28 @@ import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context'; import { parseSetCookie } from '@/utils/cookie'; import { baseUrl } from './common'; +import { loginResponse } from './types'; export async function login( user: string, pass: string, ctx: ShowScrapeContext | MovieScrapeContext, ): Promise { - let req; - if (user && pass) - req = await ctx.proxiedFetcher.full('/login', { - baseUrl, - method: 'POST', - body: new URLSearchParams({ user, pass, action: 'login' }), - readHeaders: ['Set-Cookie'], - }); + const req = await ctx.proxiedFetcher.full('/login', { + baseUrl, + method: 'POST', + body: new URLSearchParams({ user, pass, action: 'login' }), + readHeaders: ['Set-Cookie'], + }); + const res: loginResponse = JSON.parse(req.body); - const cookies = parseSetCookie( - req?.headers.get('Set-Cookie') || - // we don't wan't our creds to be in the code - 'PHPSESSID=phmje3cqeft42rckf8mj7illhc;', + const cookie = parseSetCookie( + // It retruns a cookie even when the login failed + // I have the backup cookie here just in case + res.status === 1 ? (req.headers.get('Set-Cookie') ?? '') : 'PHPSESSID=mk2p73c77qc28o5i5120843ruu;', ); - return cookies.PHPSESSID.value; + return cookie.PHPSESSID.value; } export function parseSearch(body: string): { title: string; year: number; id: string }[] {