From d5194d21e81113224ec92056c51bb2746b9bf172 Mon Sep 17 00:00:00 2001 From: TPN Date: Wed, 5 Jun 2024 16:07:58 +0530 Subject: [PATCH 1/5] add ee3 source --- src/providers/all.ts | 2 + src/providers/sources/ee3/common.ts | 7 +++ src/providers/sources/ee3/index.ts | 97 +++++++++++++++++++++++++++++ src/providers/sources/ee3/types.ts | 26 ++++++++ src/providers/sources/ee3/utils.ts | 40 ++++++++++++ 5 files changed, 172 insertions(+) create mode 100644 src/providers/sources/ee3/common.ts create mode 100644 src/providers/sources/ee3/index.ts create mode 100644 src/providers/sources/ee3/types.ts create mode 100644 src/providers/sources/ee3/utils.ts diff --git a/src/providers/all.ts b/src/providers/all.ts index 33af334..c66387f 100644 --- a/src/providers/all.ts +++ b/src/providers/all.ts @@ -12,6 +12,7 @@ import { upcloudScraper } from '@/providers/embeds/upcloud'; import { upstreamScraper } from '@/providers/embeds/upstream'; import { vidsrcembedScraper } from '@/providers/embeds/vidsrc'; import { vTubeScraper } from '@/providers/embeds/vtube'; +import { ee3Scraper } from '@/providers/sources/ee3'; import { flixhqScraper } from '@/providers/sources/flixhq/index'; import { goMoviesScraper } from '@/providers/sources/gomovies/index'; import { insertunitScraper } from '@/providers/sources/insertunit'; @@ -79,6 +80,7 @@ export function gatherAllSources(): Array { nitesScraper, soaperTvScraper, tugaflixScraper, + ee3Scraper, ]; } diff --git a/src/providers/sources/ee3/common.ts b/src/providers/sources/ee3/common.ts new file mode 100644 index 0000000..1b88847 --- /dev/null +++ b/src/providers/sources/ee3/common.ts @@ -0,0 +1,7 @@ +export const useAltEndpoint: boolean = false; + +export const baseUrl = useAltEndpoint ? 'https://rips.cc' : 'https://ee3.me'; + +export const username = ''; + +export const password = ''; diff --git a/src/providers/sources/ee3/index.ts b/src/providers/sources/ee3/index.ts new file mode 100644 index 0000000..4424386 --- /dev/null +++ b/src/providers/sources/ee3/index.ts @@ -0,0 +1,97 @@ +import { flags } from '@/entrypoint/utils/targets'; +import { SourcererOutput, makeSourcerer } from '@/providers/base'; +import { Caption } from '@/providers/captions'; +import { compareMedia } from '@/utils/compare'; +import { MovieScrapeContext } from '@/utils/context'; +import { makeCookieHeader } from '@/utils/cookie'; +import { NotFoundError } from '@/utils/errors'; + +import { baseUrl, password, username } from './common'; +import { itemDetails, renewResponse } from './types'; +import { login, parseSearch } from './utils'; + +// this source only has movies +async function comboScraper(ctx: MovieScrapeContext): Promise { + const pass = await login(username, password, ctx); + if (!pass) throw new Error('Login failed'); + + const search = parseSearch( + await ctx.proxiedFetcher('/get', { + baseUrl, + method: 'POST', + body: new URLSearchParams({ query: ctx.media.title, action: 'search' }), + headers: { + cookie: makeCookieHeader({ PHPSESSID: pass }), + }, + }), + ); + + const id = search.find((v) => v && compareMedia(ctx.media, v.title, v.year))?.id; + if (!id) throw new NotFoundError('No watchable item found'); + + const details: itemDetails = JSON.parse( + await ctx.proxiedFetcher('/get', { + baseUrl, + method: 'POST', + body: new URLSearchParams({ id, action: 'get_movie_info' }), + headers: { + cookie: makeCookieHeader({ PHPSESSID: pass }), + }, + }), + ); + if (!details.message.video) throw new Error('Failed to get the stream'); + + const keyParams: renewResponse = JSON.parse( + await ctx.proxiedFetcher('/renew', { + baseUrl, + method: 'POST', + headers: { + cookie: makeCookieHeader({ PHPSESSID: pass }), + }, + }), + ); + if (!keyParams.k) throw new Error('Failed to get the key'); + + const server = details.message.server === '1' ? 'https://vid.ee3.me/vid/' : 'https://vault.rips.cc/video/'; + const k = keyParams.k; + const url = `${server}${details.message.video}?${new URLSearchParams({ k })}`; + const captions: Caption[] = []; + + // this how they actually deal with subtitles + if (details.message.subs?.toLowerCase() === 'yes' && details.message.imdbID) { + captions.push({ + id: `https://rips.cc/subs/${details.message.imdbID}.vtt`, + url: `https://rips.cc/subs/${details.message.imdbID}.vtt`, + type: 'vtt', + hasCorsRestrictions: false, + language: 'en', + }); + } + + return { + embeds: [], + stream: [ + { + id: 'primary', + type: 'file', + flags: [flags.CORS_ALLOWED], + captions, + qualities: { + // should be unknown, but all the videos are 720p + 720: { + type: 'mp4', + url, + }, + }, + }, + ], + }; +} + +export const ee3Scraper = makeSourcerer({ + id: 'ee3', + name: 'EE3', + rank: 111, + flags: [flags.CORS_ALLOWED], + scrapeMovie: comboScraper, +}); diff --git a/src/providers/sources/ee3/types.ts b/src/providers/sources/ee3/types.ts new file mode 100644 index 0000000..c9b2534 --- /dev/null +++ b/src/providers/sources/ee3/types.ts @@ -0,0 +1,26 @@ +export interface itemDetails { + status: number; + message: { + id: string; + imdbID: string; + title: string; + video: string; + server: string; + year: string; + image: string; + glow: string; + rating: string; + watch_count: string; + datetime?: string | null; + requested_by?: string | null; + subs?: string | null; + time?: string | null; + duration?: string | null; + }; +} + +export interface renewResponse { + k: string; + msg?: string | null; + status: number | string | null; +} diff --git a/src/providers/sources/ee3/utils.ts b/src/providers/sources/ee3/utils.ts new file mode 100644 index 0000000..c032bfa --- /dev/null +++ b/src/providers/sources/ee3/utils.ts @@ -0,0 +1,40 @@ +import { load } from 'cheerio'; + +import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context'; +import { parseSetCookie } from '@/utils/cookie'; + +import { baseUrl } from './common'; + +export async function login( + user: string, + pass: string, + ctx: ShowScrapeContext | MovieScrapeContext, +): Promise { + const req = await ctx.proxiedFetcher.full('/login', { + baseUrl, + method: 'POST', + body: new URLSearchParams({ user, pass, action: 'login' }), + readHeaders: ['Set-Cookie'], + }); + + const cookies = parseSetCookie(req.headers.get('Set-Cookie') || ''); + + return cookies.PHPSESSID.value; +} + +export function parseSearch(body: string): { title: string; year: number; id: string }[] { + const result: { title: string; year: number; id: string }[] = []; + + const $ = load(body); + $('div').each((_, element) => { + const title = $(element).find('.title').text().trim(); + const year = parseInt($(element).find('.details span').first().text().trim(), 10); + const id = $(element).find('.control-buttons').attr('data-id'); + + if (title && year && id) { + result.push({ title, year, id }); + } + }); + + return result; +} From f0bfccaa6fa4d618c5e50d68f1c4301bd5bca17f Mon Sep 17 00:00:00 2001 From: TPN Date: Wed, 5 Jun 2024 16:17:20 +0530 Subject: [PATCH 2/5] hardset cookie --- src/providers/sources/ee3/utils.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/providers/sources/ee3/utils.ts b/src/providers/sources/ee3/utils.ts index c032bfa..d77f280 100644 --- a/src/providers/sources/ee3/utils.ts +++ b/src/providers/sources/ee3/utils.ts @@ -10,14 +10,20 @@ export async function login( pass: string, ctx: ShowScrapeContext | MovieScrapeContext, ): Promise { - const req = await ctx.proxiedFetcher.full('/login', { - baseUrl, - method: 'POST', - body: new URLSearchParams({ user, pass, action: 'login' }), - readHeaders: ['Set-Cookie'], - }); + 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 cookies = parseSetCookie(req.headers.get('Set-Cookie') || ''); + const cookies = parseSetCookie( + req?.headers.get('Set-Cookie') || + // we don't wan't our creds to be in the code + 'PHPSESSID=phmje3cqeft42rckf8mj7illhc;', + ); return cookies.PHPSESSID.value; } From 1bc744d48de0c399839c8fab9c3b56f0a14fd740 Mon Sep 17 00:00:00 2001 From: TPN Date: Fri, 14 Jun 2024 23:53:53 +0530 Subject: [PATCH 3/5] fix eslint issues on all.ts --- src/providers/all.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/providers/all.ts b/src/providers/all.ts index 6ec31bf..ea8810e 100644 --- a/src/providers/all.ts +++ b/src/providers/all.ts @@ -12,6 +12,7 @@ import { upcloudScraper } from '@/providers/embeds/upcloud'; import { upstreamScraper } from '@/providers/embeds/upstream'; import { vidsrcembedScraper } from '@/providers/embeds/vidsrc'; import { vTubeScraper } from '@/providers/embeds/vtube'; +import { autoembedScraper } from '@/providers/sources/autoembed'; import { ee3Scraper } from '@/providers/sources/ee3'; import { flixhqScraper } from '@/providers/sources/flixhq/index'; import { goMoviesScraper } from '@/providers/sources/gomovies/index'; @@ -62,8 +63,6 @@ import { soaperTvScraper } from './sources/soapertv'; import { vidSrcToScraper } from './sources/vidsrcto'; import { warezcdnScraper } from './sources/warezcdn'; -import { autoembedScraper } from '@/providers/sources/autoembed'; - export function gatherAllSources(): Array { // all sources are gathered here return [ From 34b2fb74ae90113a423d845f106183d07d9fbe64 Mon Sep 17 00:00:00 2001 From: TPN Date: Tue, 16 Jul 2024 07:55:31 +0000 Subject: [PATCH 4/5] 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 }[] { From dacd7176711e2b1a83fabacbdb4550e9624bb91c Mon Sep 17 00:00:00 2001 From: TPN Date: Tue, 16 Jul 2024 08:04:14 +0000 Subject: [PATCH 5/5] Oops WHY ARE THE ACTIONS NOT WORKING --- src/providers/all.ts | 2 +- src/providers/sources/nepu/index.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/providers/all.ts b/src/providers/all.ts index 2421a75..ebaaebf 100644 --- a/src/providers/all.ts +++ b/src/providers/all.ts @@ -15,8 +15,8 @@ import { vidsrcembedScraper } from '@/providers/embeds/vidsrc'; import { vTubeScraper } from '@/providers/embeds/vtube'; import { astraScraper, novaScraper } from '@/providers/embeds/whvx'; import { autoembedScraper } from '@/providers/sources/autoembed'; -import { ee3Scraper } from '@/providers/sources/ee3'; import { catflixScraper } from '@/providers/sources/catflix'; +import { ee3Scraper } from '@/providers/sources/ee3'; import { flixhqScraper } from '@/providers/sources/flixhq/index'; import { goMoviesScraper } from '@/providers/sources/gomovies/index'; import { insertunitScraper } from '@/providers/sources/insertunit'; diff --git a/src/providers/sources/nepu/index.ts b/src/providers/sources/nepu/index.ts index f3be5a1..8f3a094 100644 --- a/src/providers/sources/nepu/index.ts +++ b/src/providers/sources/nepu/index.ts @@ -1,6 +1,5 @@ import { load } from 'cheerio'; -import { flags } from '@/entrypoint/utils/targets'; import { SourcererOutput, makeSourcerer } from '@/providers/base'; import { compareTitle } from '@/utils/compare'; import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';