diff --git a/providers/autoEmbed/stream.ts b/providers/autoEmbed/stream.ts index 3ab896f..4e86c47 100644 --- a/providers/autoEmbed/stream.ts +++ b/providers/autoEmbed/stream.ts @@ -1,4 +1,4 @@ -import { Stream, ProviderContext, TextTrackType, TextTracks } from "../types"; +import { Stream, ProviderContext, TextTracks } from "../types"; export const getStream = async ({ link: id, @@ -87,8 +87,8 @@ export async function getRiveStream( uri: sub?.file, title: sub?.label || "Undefined", type: sub?.file?.endsWith(".vtt") - ? TextTrackType.VTT - : TextTrackType.SUBRIP, + ? "text/vtt" + : "application/x-subrip", }); }); } diff --git a/providers/flixhq/stream.ts b/providers/flixhq/stream.ts index 3b1c713..157a0b8 100644 --- a/providers/flixhq/stream.ts +++ b/providers/flixhq/stream.ts @@ -1,4 +1,4 @@ -import { ProviderContext, Stream, TextTrackType } from "../types"; +import { ProviderContext, Stream } from "../types"; export const getStream = async function ({ link: id, @@ -33,7 +33,7 @@ export const getStream = async function ({ subtitles.push({ language: sub?.lang?.slice(0, 2) as any, uri: sub?.url, - type: TextTrackType.VTT, + type: "text/vtt", title: sub?.lang, }); }); diff --git a/providers/getBaseUrl.ts b/providers/getBaseUrl.ts index 265504a..d94cd33 100644 --- a/providers/getBaseUrl.ts +++ b/providers/getBaseUrl.ts @@ -1,35 +1,29 @@ -import { cacheStorageService } from '../storage'; - // 1 hour const expireTime = 60 * 60 * 1000; export const getBaseUrl = async (providerValue: string) => { try { - let baseUrl = ''; - const cacheKey = 'CacheBaseUrl' + providerValue; - const timeKey = 'baseUrlTime' + providerValue; - - const cachedUrl = cacheStorageService.getString(cacheKey); - const cachedTime = cacheStorageService.getObject(timeKey); - - if ( - cachedUrl && - cachedTime && - Date.now() - cachedTime < expireTime - ) { - baseUrl = cachedUrl; - } else { - const baseUrlRes = await fetch( - 'https://himanshu8443.github.io/providers/modflix.json', - ); - const baseUrlData = await baseUrlRes.json(); - baseUrl = baseUrlData[providerValue].url; - cacheStorageService.setString(cacheKey, baseUrl); - cacheStorageService.setObject(timeKey, Date.now()); - } + let baseUrl = ""; + const cacheKey = "CacheBaseUrl" + providerValue; + const timeKey = "baseUrlTime" + providerValue; + + // const cachedUrl = cacheStorageService.getString(cacheKey); + // const cachedTime = cacheStorageService.getObject(timeKey); + + // if (cachedUrl && cachedTime && Date.now() - cachedTime < expireTime) { + // baseUrl = cachedUrl; + // } else { + const baseUrlRes = await fetch( + "https://himanshu8443.github.io/providers/modflix.json" + ); + const baseUrlData = await baseUrlRes.json(); + baseUrl = baseUrlData[providerValue].url; + // cacheStorageService.setString(cacheKey, baseUrl); + // cacheStorageService.setObject(timeKey, Date.now()); + // } return baseUrl; } catch (error) { console.error(`Error fetching baseUrl: ${providerValue}`, error); - return ''; + return ""; } }; diff --git a/providers/hiAnime/stream.ts b/providers/hiAnime/stream.ts index 01e38a5..b091fc2 100644 --- a/providers/hiAnime/stream.ts +++ b/providers/hiAnime/stream.ts @@ -1,4 +1,4 @@ -import { Stream, ProviderContext, TextTracks, TextTrackType } from "../types"; +import { Stream, ProviderContext, TextTracks } from "../types"; export const getStream = async function ({ link: id, @@ -26,8 +26,8 @@ export const getStream = async function ({ uri: sub?.url, title: sub?.lang || "Undefined", type: sub?.url?.endsWith(".vtt") - ? TextTrackType.VTT - : TextTrackType.SUBRIP, + ? "text/vtt" + : "application/x-subrip", }); }); res.data?.sources.forEach((source: any) => { diff --git a/providers/kissKh/stream.ts b/providers/kissKh/stream.ts index 4fe59b1..cb0446d 100644 --- a/providers/kissKh/stream.ts +++ b/providers/kissKh/stream.ts @@ -1,4 +1,4 @@ -import { Stream, ProviderContext, TextTrackType, TextTracks } from "../types"; +import { Stream, ProviderContext, TextTracks } from "../types"; export const getStream = async function ({ link: id, @@ -22,9 +22,7 @@ export const getStream = async function ({ subtitles.push({ title: sub?.label, language: sub?.land, - type: sub?.src?.includes(".vtt") - ? TextTrackType.VTT - : TextTrackType.SUBRIP, + type: sub?.src?.includes(".vtt") ? "text/vtt" : "application/x-subrip", uri: sub?.src, }); }); diff --git a/providers/luxMovies/episodes.ts b/providers/luxMovies/episodes.ts index 256e9d9..627f882 100644 --- a/providers/luxMovies/episodes.ts +++ b/providers/luxMovies/episodes.ts @@ -17,7 +17,7 @@ export const getEpisodes = async function ({ const episodes: EpisodeLink[] = []; container.find("h4").each((index, element) => { const el = $(element); - const title = el.text().replaceAll("-", "").replaceAll(":", ""); + const title = el.text().replace(/-/g, "").replace(/:/g, ""); const link = el .next("p") .find( diff --git a/providers/moviesApi/stream.ts b/providers/moviesApi/stream.ts index 5da8eed..93ef997 100644 --- a/providers/moviesApi/stream.ts +++ b/providers/moviesApi/stream.ts @@ -1,4 +1,4 @@ -import {Stream, ProviderContext, TextTrackType, TextTracks} from '../types'; +import { Stream, ProviderContext, TextTracks } from "../types"; export const mpGetStream = async function ({ link: id, @@ -10,12 +10,12 @@ export const mpGetStream = async function ({ providerContext: ProviderContext; }): Promise { try { - const {getBaseUrl, cheerio} = providerContext; + const { getBaseUrl, cheerio } = providerContext; const streams: Stream[] = []; - const {season, episode, tmdbId} = JSON.parse(id); - const baseUrl = await getBaseUrl('moviesapi'); + const { season, episode, tmdbId } = JSON.parse(id); + const baseUrl = await getBaseUrl("moviesapi"); const link = - type === 'movie' + type === "movie" ? `${baseUrl}/movie/${tmdbId}` : `${baseUrl}/tv/${tmdbId}-${season}-${episode}`; const res = await fetch(link, { @@ -25,69 +25,67 @@ export const mpGetStream = async function ({ }); const baseData = await res.text(); const $ = cheerio.load(baseData); - const embededUrl = $('iframe').attr('src') || ''; + const embededUrl = $("iframe").attr("src") || ""; const response = await fetch(embededUrl, { - credentials: 'omit', + credentials: "omit", headers: { - 'User-Agent': - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0', + "User-Agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0", Accept: - 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8', - 'Accept-Language': 'en-US,en;q=0.5', - 'Alt-Used': 'w1.moviesapi.club', - 'Upgrade-Insecure-Requests': '1', - 'Sec-Fetch-Dest': 'document', - 'Sec-Fetch-Mode': 'navigate', - 'Sec-Fetch-Site': 'none', - 'Sec-Fetch-User': '?1', - Pragma: 'no-cache', - 'Cache-Control': 'no-cache', + "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", + "Accept-Language": "en-US,en;q=0.5", + "Alt-Used": "w1.moviesapi.club", + "Upgrade-Insecure-Requests": "1", + "Sec-Fetch-Dest": "document", + "Sec-Fetch-Mode": "navigate", + "Sec-Fetch-Site": "none", + "Sec-Fetch-User": "?1", + Pragma: "no-cache", + "Cache-Control": "no-cache", referer: baseUrl, }, referrer: baseUrl, - method: 'GET', - mode: 'cors', + method: "GET", + mode: "cors", }); const data2 = await response.text(); // Extract the encrypted content const contents = - data2.match(/const\s+Encrypted\s*=\s*['"]({.*})['"]/)?.[1] || ''; + data2.match(/const\s+Encrypted\s*=\s*['"]({.*})['"]/)?.[1] || ""; if (embededUrl) { const res2 = await fetch( - 'https://ext.8man.me/api/decrypt?passphrase==JV[t}{trEV=Ilh5', + "https://ext.8man.me/api/decrypt?passphrase==JV[t}{trEV=Ilh5", { - method: 'POST', + method: "POST", body: contents, - }, + } ); const finalData = await res2.json(); const subtitle: TextTracks = finalData?.subtitles?.map((sub: any) => ({ - title: sub?.label || 'Unknown', + title: sub?.label || "Unknown", language: sub?.label as string, - type: sub?.file?.includes('.vtt') - ? TextTrackType.VTT - : TextTrackType.SUBRIP, + type: sub?.file?.includes(".vtt") ? "text/vtt" : "application/x-subrip", uri: sub?.file, })); streams.push({ - server: 'vidstreaming ', - type: 'm3u8', + server: "vidstreaming ", + type: "m3u8", subtitles: subtitle, link: finalData?.videoUrl, headers: { - 'User-Agent': - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0', + "User-Agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0", Referer: baseUrl, Origin: baseUrl, - Accept: '*/*', - 'Accept-Language': 'en-US,en;q=0.5', - 'Sec-Fetch-Dest': 'empty', - 'Sec-Fetch-Mode': 'cors', - 'Sec-Fetch-Site': 'cross-site', - Pragma: 'no-cache', - 'Cache-Control': 'no-cache', + Accept: "*/*", + "Accept-Language": "en-US,en;q=0.5", + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "cross-site", + Pragma: "no-cache", + "Cache-Control": "no-cache", }, }); } diff --git a/providers/providerContext.ts b/providers/providerContext.ts index 1c30e85..752075e 100644 --- a/providers/providerContext.ts +++ b/providers/providerContext.ts @@ -1,13 +1,13 @@ -import axios from 'axios'; -import {getBaseUrl} from './getBaseUrl'; -import {headers} from './headers'; -import * as cheerio from 'cheerio'; -import {hubcloudExtracter} from './hubcloudExtractor'; -import {gofileExtracter} from './gofileExtracter'; -import {superVideoExtractor} from './superVideoExtractor'; -import {gdFlixExtracter} from './gdflixExtractor'; -import {ProviderContext} from './types'; -import Aes from 'react-native-aes-crypto'; +import axios from "axios"; +import { getBaseUrl } from "./getBaseUrl"; +import { headers } from "./headers"; +import * as cheerio from "cheerio"; +import { hubcloudExtracter } from "./hubcloudExtractor"; +import { gofileExtracter } from "./gofileExtracter"; +import { superVideoExtractor } from "./superVideoExtractor"; +import { gdFlixExtracter } from "./gdflixExtractor"; +import { ProviderContext } from "./types"; +import Aes from "react-native-aes-crypto"; /** * Context for provider functions. diff --git a/providers/types.ts b/providers/types.ts index bbd0b26..21bc866 100644 --- a/providers/types.ts +++ b/providers/types.ts @@ -1,6 +1,6 @@ -import {AxiosStatic} from 'axios'; -import * as cheerio from 'cheerio'; -import {Content} from '../zustand/contentStore'; +import { AxiosStatic } from "axios"; +import * as cheerio from "cheerio"; +import { Content } from "../zustand/contentStore"; // getPosts export interface Post { @@ -10,16 +10,10 @@ export interface Post { provider?: string; } -export declare enum TextTrackType { - SUBRIP = 'application/x-subrip', - TTML = 'application/ttml+xml', - VTT = 'text/vtt', -} - export type TextTracks = { title: string; - language: ISO639_1; - type: TextTrackType; + language: string; + type: "application/x-subrip" | "application/ttml+xml" | "text/vtt"; uri: string; }[]; @@ -28,7 +22,7 @@ export interface Stream { server: string; link: string; type: string; - quality?: '360' | '480' | '720' | '1080' | '2160'; + quality?: "360" | "480" | "720" | "1080" | "2160"; subtitles?: TextTracks; headers?: any; } @@ -58,7 +52,7 @@ export interface Link { directLinks?: { title: string; link: string; - type?: 'movie' | 'series'; + type?: "movie" | "series"; }[]; } @@ -112,7 +106,7 @@ export interface ProviderType { providerContext, }: { link: string; - provider: Content['provider']; + provider: Content["provider"]; providerContext: ProviderContext; }) => Promise; GetSearchPosts: ({ @@ -146,188 +140,3 @@ export type ProviderContext = { gdFlixExtracter: (link: string, signal: AbortSignal) => Promise; }; }; - -export type ISO639_1 = - | 'aa' - | 'ab' - | 'ae' - | 'af' - | 'ak' - | 'am' - | 'an' - | 'ar' - | 'as' - | 'av' - | 'ay' - | 'az' - | 'ba' - | 'be' - | 'bg' - | 'bi' - | 'bm' - | 'bn' - | 'bo' - | 'br' - | 'bs' - | 'ca' - | 'ce' - | 'ch' - | 'co' - | 'cr' - | 'cs' - | 'cu' - | 'cv' - | 'cy' - | 'da' - | 'de' - | 'dv' - | 'dz' - | 'ee' - | 'el' - | 'en' - | 'eo' - | 'es' - | 'et' - | 'eu' - | 'fa' - | 'ff' - | 'fi' - | 'fj' - | 'fo' - | 'fr' - | 'fy' - | 'ga' - | 'gd' - | 'gl' - | 'gn' - | 'gu' - | 'gv' - | 'ha' - | 'he' - | 'hi' - | 'ho' - | 'hr' - | 'ht' - | 'hu' - | 'hy' - | 'hz' - | 'ia' - | 'id' - | 'ie' - | 'ig' - | 'ii' - | 'ik' - | 'io' - | 'is' - | 'it' - | 'iu' - | 'ja' - | 'jv' - | 'ka' - | 'kg' - | 'ki' - | 'kj' - | 'kk' - | 'kl' - | 'km' - | 'kn' - | 'ko' - | 'kr' - | 'ks' - | 'ku' - | 'kv' - | 'kw' - | 'ky' - | 'la' - | 'lb' - | 'lg' - | 'li' - | 'ln' - | 'lo' - | 'lt' - | 'lu' - | 'lv' - | 'mg' - | 'mh' - | 'mi' - | 'mk' - | 'ml' - | 'mn' - | 'mr' - | 'ms' - | 'mt' - | 'my' - | 'na' - | 'nb' - | 'nd' - | 'ne' - | 'ng' - | 'nl' - | 'nn' - | 'no' - | 'nr' - | 'nv' - | 'ny' - | 'oc' - | 'oj' - | 'om' - | 'or' - | 'os' - | 'pa' - | 'pi' - | 'pl' - | 'ps' - | 'pt' - | 'qu' - | 'rm' - | 'rn' - | 'ro' - | 'ru' - | 'rw' - | 'sa' - | 'sc' - | 'sd' - | 'se' - | 'sg' - | 'si' - | 'sk' - | 'sl' - | 'sm' - | 'sn' - | 'so' - | 'sq' - | 'sr' - | 'ss' - | 'st' - | 'su' - | 'sv' - | 'sw' - | 'ta' - | 'te' - | 'tg' - | 'th' - | 'ti' - | 'tk' - | 'tl' - | 'tn' - | 'to' - | 'tr' - | 'ts' - | 'tt' - | 'tw' - | 'ty' - | 'ug' - | 'uk' - | 'ur' - | 'uz' - | 've' - | 'vi' - | 'vo' - | 'wa' - | 'wo' - | 'xh' - | 'yi' - | 'yo' - | 'za' - | 'zh' - | 'zu'; diff --git a/providers/vega/episodes.ts b/providers/vega/episodes.ts index 256e9d9..627f882 100644 --- a/providers/vega/episodes.ts +++ b/providers/vega/episodes.ts @@ -17,7 +17,7 @@ export const getEpisodes = async function ({ const episodes: EpisodeLink[] = []; container.find("h4").each((index, element) => { const el = $(element); - const title = el.text().replaceAll("-", "").replaceAll(":", ""); + const title = el.text().replace(/-/g, "").replace(/:/g, ""); const link = el .next("p") .find(