mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 15:41:45 +00:00
refactor: update text track types and clean up imports across multiple stream providers
This commit is contained in:
@@ -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",
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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<number>(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<number>(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 "";
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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<Stream[]> {
|
||||
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",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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<Info>;
|
||||
GetSearchPosts: ({
|
||||
@@ -146,188 +140,3 @@ export type ProviderContext = {
|
||||
gdFlixExtracter: (link: string, signal: AbortSignal) => Promise<Stream[]>;
|
||||
};
|
||||
};
|
||||
|
||||
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';
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user