20 Commits

Author SHA1 Message Date
Jorrin
025b6821e6 Merge pull request #146 from infvortx/dev
Add Insertunit provider
2024-04-11 19:46:21 +02:00
Jorrin
356286dfaa Merge branch 'dev' of https://github.com/infvortx/providers-dev into pr/146 2024-04-11 19:44:19 +02:00
Jorrin
534b53f9b9 Merge branch 'dev' into pr/146 2024-04-11 19:44:06 +02:00
teddyHV11
2553909e8d Merge branch 'dev' of https://github.com/infvortx/providers-dev into dev 2024-04-11 17:49:33 +03:00
teddyHV11
6a0ac52908 Fix prettier errors 2024-04-11 17:49:32 +03:00
Jorrin
0ede244c2b Merge branch 'dev' into dev 2024-04-11 15:48:11 +02:00
teddyHV11
8281c3141a Rename insertunit.ts to index.ts 2024-04-11 06:31:53 +03:00
teddyHV11
8796b39a63 Fix prettier errors 2024-04-11 04:18:38 +03:00
teddyHV11
6b038a288c Clarity fixes 2024-04-11 03:57:42 +03:00
teddyHV11
5d6b93385e Types adjustment, extract captions to a function 2024-04-10 07:24:53 +03:00
teddyHV11
5b836a4839 Fix mistake done with captions
Swap languages and type's place
2024-04-09 17:44:41 +03:00
infvortx
082d2754be Merge branch 'movie-web:dev' into dev 2024-04-09 09:49:32 +03:00
teddyHV11
921c35b3ed Add caption scraping + types 2024-04-09 07:16:41 +03:00
Jorrin
fbbb671967 Merge branch 'dev' into dev 2024-04-08 16:09:37 +02:00
teddyHV11
7dc5a5ac83 Fix series scraping
Series scraping was off for some series, this fixes it + also adds support for episodes that are in multiple parts (continuation of each other) as the provider returns them as a single file in episode ranges.
2024-04-07 15:33:04 +03:00
teddyHV11
73facc0184 Merge branch 'dev' of https://github.com/infvortx/providers-dev into dev 2024-04-07 11:54:37 +03:00
teddyHV11
68fe85065f Updated provider name 2024-04-07 11:54:34 +03:00
infvortx
8a711265cb Update insertunit.ts 2024-04-07 11:48:04 +03:00
infvortx
a58ea29ae5 Merge branch 'movie-web:dev' into dev 2024-04-07 10:53:44 +03:00
teddyHV11
d99a22d734 Add insertunit 2024-04-07 10:53:09 +03:00
4 changed files with 165 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ import { vidsrcembedScraper } from '@/providers/embeds/vidsrc';
import { vTubeScraper } from '@/providers/embeds/vtube';
import { flixhqScraper } from '@/providers/sources/flixhq/index';
import { goMoviesScraper } from '@/providers/sources/gomovies/index';
import { insertunitScraper } from '@/providers/sources/insertunit';
import { kissAsianScraper } from '@/providers/sources/kissasian/index';
import { lookmovieScraper } from '@/providers/sources/lookmovie';
import { remotestreamScraper } from '@/providers/sources/remotestream';
@@ -59,6 +60,7 @@ export function gatherAllSources(): Array<Sourcerer> {
goojaraScraper,
hdRezkaScraper,
primewireScraper,
insertunitScraper,
soaperTvScraper,
];
}

View File

@@ -0,0 +1,30 @@
import { Caption, removeDuplicatedLanguages } from '@/providers/captions';
import { Subtitle } from './types';
export async function getCaptions(data: Subtitle[]) {
let captions: Caption[] = [];
for (const subtitle of data) {
let language = '';
if (subtitle.name.includes('Рус')) {
language = 'ru';
} else if (subtitle.name.includes('Укр')) {
language = 'uk';
} else if (subtitle.name.includes('Eng')) {
language = 'en';
} else {
continue;
}
captions.push({
id: subtitle.url,
url: subtitle.url,
language,
type: 'vtt',
hasCorsRestrictions: false,
});
}
captions = removeDuplicatedLanguages(captions);
return captions;
}

View File

@@ -0,0 +1,103 @@
import { flags } from '@/entrypoint/utils/targets';
import { makeSourcerer } from '@/providers/base';
import { Caption } from '@/providers/captions';
import { NotFoundError } from '@/utils/errors';
import { getCaptions } from './captions';
import { Season } from './types';
const insertUnitBase = 'https://api.insertunit.ws/';
export const insertunitScraper = makeSourcerer({
id: 'insertunit',
name: 'Insertunit',
disabled: false,
rank: 60,
flags: [flags.CORS_ALLOWED],
async scrapeShow(ctx) {
const playerData = await ctx.fetcher<string>(`/embed/imdb/${ctx.media.imdbId}`, {
baseUrl: insertUnitBase,
});
ctx.progress(30);
const seasonDataJSONregex = /seasons:(.*)/;
const seasonData = seasonDataJSONregex.exec(playerData);
if (seasonData === null || seasonData[1] === null) {
throw new NotFoundError('No result found');
}
ctx.progress(60);
const seasonTable: Season[] = JSON.parse(seasonData[1]) as Season[];
const currentSeason = seasonTable.find(
(seasonElement) => seasonElement.season === ctx.media.season.number && !seasonElement.blocked,
);
const currentEpisode = currentSeason?.episodes.find((episodeElement) =>
episodeElement.episode.includes(ctx.media.episode.number.toString()),
);
if (!currentEpisode?.hls) throw new NotFoundError('No result found');
let captions: Caption[] = [];
if (currentEpisode.cc != null) {
captions = await getCaptions(currentEpisode.cc);
}
ctx.progress(95);
return {
embeds: [],
stream: [
{
id: 'primary',
playlist: currentEpisode.hls,
type: 'hls',
flags: [flags.CORS_ALLOWED],
captions,
},
],
};
},
async scrapeMovie(ctx) {
const playerData = await ctx.fetcher<string>(`/embed/imdb/${ctx.media.imdbId}`, {
baseUrl: insertUnitBase,
});
ctx.progress(35);
const streamRegex = /hls: "([^"]*)/;
const streamData = streamRegex.exec(playerData);
if (streamData === null || streamData[1] === null) {
throw new NotFoundError('No result found');
}
ctx.progress(75);
const subtitleRegex = /cc: (.*)/;
const subtitleJSONData = subtitleRegex.exec(playerData);
let captions: Caption[] = [];
if (subtitleJSONData != null && subtitleJSONData[1] != null) {
const subtitleData = JSON.parse(subtitleJSONData[1]);
captions = await getCaptions(subtitleData);
}
ctx.progress(90);
return {
embeds: [],
stream: [
{
id: 'primary',
type: 'hls',
playlist: streamData[1],
flags: [flags.CORS_ALLOWED],
captions,
},
],
};
},
});

View File

@@ -0,0 +1,30 @@
export interface Subtitle {
url: string;
name: string;
}
export interface Episode {
episode: string;
id: number;
videoKey: string;
hls: string;
audio: {
names: string[];
order: number[];
};
cc: Subtitle[];
duration: number;
title: string;
download: string;
sections: string[];
poster: string;
preview: {
src: string;
};
}
export interface Season {
season: number;
blocked: boolean;
episodes: Episode[];
}