This commit is contained in:
Jorrin 2024-04-11 19:44:19 +02:00
commit 356286dfaa
4 changed files with 58 additions and 65 deletions

View File

@ -14,7 +14,7 @@ import { vidsrcembedScraper } from '@/providers/embeds/vidsrc';
import { vTubeScraper } from '@/providers/embeds/vtube'; import { vTubeScraper } from '@/providers/embeds/vtube';
import { flixhqScraper } from '@/providers/sources/flixhq/index'; import { flixhqScraper } from '@/providers/sources/flixhq/index';
import { goMoviesScraper } from '@/providers/sources/gomovies/index'; import { goMoviesScraper } from '@/providers/sources/gomovies/index';
import { insertunitScraper } from '@/providers/sources/insertunit/insertunit'; import { insertunitScraper } from '@/providers/sources/insertunit';
import { kissAsianScraper } from '@/providers/sources/kissasian/index'; import { kissAsianScraper } from '@/providers/sources/kissasian/index';
import { lookmovieScraper } from '@/providers/sources/lookmovie'; import { lookmovieScraper } from '@/providers/sources/lookmovie';
import { remotestreamScraper } from '@/providers/sources/remotestream'; import { remotestreamScraper } from '@/providers/sources/remotestream';

View File

@ -1,12 +1,10 @@
import { Caption } from "@/providers/captions"; import { Caption, removeDuplicatedLanguages } from '@/providers/captions';
import { Subtitle } from "./types";
import { removeDuplicatedLanguages } from "@/providers/captions"; import { Subtitle } from './types';
export async function getCaptions(data: Subtitle[]) { export async function getCaptions(data: Subtitle[]) {
let captions: Caption[] = []; let captions: Caption[] = [];
let subtitle: Subtitle; for (const subtitle of data) {
for (subtitle of data) {
let language = ''; let language = '';
if (subtitle.name.includes('Рус')) { if (subtitle.name.includes('Рус')) {
@ -28,5 +26,5 @@ export async function getCaptions(data: Subtitle[]) {
}); });
} }
captions = removeDuplicatedLanguages(captions); captions = removeDuplicatedLanguages(captions);
return(captions) return captions;
} }

View File

@ -1,10 +1,10 @@
import { flags } from '@/entrypoint/utils/targets'; import { flags } from '@/entrypoint/utils/targets';
import { makeSourcerer } from '@/providers/base'; import { makeSourcerer } from '@/providers/base';
import { Caption, removeDuplicatedLanguages } from '@/providers/captions'; import { Caption } from '@/providers/captions';
import { NotFoundError } from '@/utils/errors'; import { NotFoundError } from '@/utils/errors';
import { getCaptions } from './captions';
import { Season, Subtitle } from './types'; import { getCaptions } from './captions';
import { Season } from './types';
const insertUnitBase = 'https://api.insertunit.ws/'; const insertUnitBase = 'https://api.insertunit.ws/';
@ -40,15 +40,10 @@ export const insertunitScraper = makeSourcerer({
if (!currentEpisode?.hls) throw new NotFoundError('No result found'); if (!currentEpisode?.hls) throw new NotFoundError('No result found');
let captions: Caption[] = [] let captions: Caption[] = [];
if (currentEpisode.cc != null) {
captions = await getCaptions(currentEpisode.cc)
}
ctx.progress(80);
if (currentEpisode.cc != null) { if (currentEpisode.cc != null) {
captions = await getCaptions(currentEpisode.cc);
} }
ctx.progress(95); ctx.progress(95);
@ -87,7 +82,7 @@ export const insertunitScraper = makeSourcerer({
if (subtitleJSONData != null && subtitleJSONData[1] != null) { if (subtitleJSONData != null && subtitleJSONData[1] != null) {
const subtitleData = JSON.parse(subtitleJSONData[1]); const subtitleData = JSON.parse(subtitleJSONData[1]);
captions = await getCaptions(subtitleData) captions = await getCaptions(subtitleData);
} }
ctx.progress(90); ctx.progress(90);

View File

@ -1,3 +1,8 @@
export interface Subtitle {
url: string;
name: string;
}
export interface Episode { export interface Episode {
episode: string; episode: string;
id: number; id: number;
@ -6,25 +11,20 @@ export interface Episode {
audio: { audio: {
names: string[]; names: string[];
order: number[]; order: number[];
} };
cc: Subtitle[]; cc: Subtitle[];
duration: number; duration: number;
title: string; title: string;
download: string; download: string;
sections: string[] sections: string[];
poster: string; poster: string;
preview: { preview: {
src: string; src: string;
} };
}
export interface Subtitle {
url: string;
name: string;
} }
export interface Season { export interface Season {
season: number, season: number;
blocked: boolean, blocked: boolean;
episodes: Episode[] episodes: Episode[];
} }