From 6b038a288c7eab22bfc079b2c1c4b3eaa8c4af99 Mon Sep 17 00:00:00 2001 From: teddyHV11 Date: Thu, 11 Apr 2024 03:57:42 +0300 Subject: [PATCH 1/4] Clarity fixes --- src/providers/sources/insertunit/captions.ts | 3 +-- src/providers/sources/insertunit/insertunit.ts | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/providers/sources/insertunit/captions.ts b/src/providers/sources/insertunit/captions.ts index 92ac7d9..74fa166 100644 --- a/src/providers/sources/insertunit/captions.ts +++ b/src/providers/sources/insertunit/captions.ts @@ -5,8 +5,7 @@ import { removeDuplicatedLanguages } from "@/providers/captions"; export async function getCaptions(data: Subtitle[]) { let captions: Caption[] = []; - let subtitle: Subtitle; - for (subtitle of data) { + for (const subtitle of data) { let language = ''; if (subtitle.name.includes('Рус')) { diff --git a/src/providers/sources/insertunit/insertunit.ts b/src/providers/sources/insertunit/insertunit.ts index 3cecf52..104deff 100644 --- a/src/providers/sources/insertunit/insertunit.ts +++ b/src/providers/sources/insertunit/insertunit.ts @@ -46,11 +46,6 @@ export const insertunitScraper = makeSourcerer({ captions = await getCaptions(currentEpisode.cc) } - ctx.progress(80); - - if (currentEpisode.cc != null) { - } - ctx.progress(95); return { From 8796b39a6312696238ec57e34ed2c9db14ec62ea Mon Sep 17 00:00:00 2001 From: teddyHV11 Date: Thu, 11 Apr 2024 04:18:38 +0300 Subject: [PATCH 2/4] Fix prettier errors --- src/providers/sources/insertunit/captions.ts | 51 +++++++++---------- .../sources/insertunit/insertunit.ts | 14 ++--- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/providers/sources/insertunit/captions.ts b/src/providers/sources/insertunit/captions.ts index 74fa166..881c9c2 100644 --- a/src/providers/sources/insertunit/captions.ts +++ b/src/providers/sources/insertunit/captions.ts @@ -1,31 +1,30 @@ -import { Caption } from "@/providers/captions"; -import { Subtitle } from "./types"; +import { Caption, removeDuplicatedLanguages } from '@/providers/captions'; -import { removeDuplicatedLanguages } from "@/providers/captions"; +import { Subtitle } from './types'; export async function getCaptions(data: Subtitle[]) { - let captions: Caption[] = []; - for (const subtitle of data) { - let language = ''; + 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, - }); + if (subtitle.name.includes('Рус')) { + language = 'ru'; + } else if (subtitle.name.includes('Укр')) { + language = 'uk'; + } else if (subtitle.name.includes('Eng')) { + language = 'en'; + } else { + continue; } - captions = removeDuplicatedLanguages(captions); - return(captions) -} \ No newline at end of file + + captions.push({ + id: subtitle.url, + url: subtitle.url, + language, + type: 'vtt', + hasCorsRestrictions: false, + }); + } + captions = removeDuplicatedLanguages(captions); + return captions; +} diff --git a/src/providers/sources/insertunit/insertunit.ts b/src/providers/sources/insertunit/insertunit.ts index 104deff..9a54866 100644 --- a/src/providers/sources/insertunit/insertunit.ts +++ b/src/providers/sources/insertunit/insertunit.ts @@ -1,10 +1,10 @@ import { flags } from '@/entrypoint/utils/targets'; import { makeSourcerer } from '@/providers/base'; -import { Caption, removeDuplicatedLanguages } from '@/providers/captions'; +import { Caption } from '@/providers/captions'; 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/'; @@ -39,11 +39,11 @@ export const insertunitScraper = makeSourcerer({ ); if (!currentEpisode?.hls) throw new NotFoundError('No result found'); - - let captions: Caption[] = [] + + let captions: Caption[] = []; if (currentEpisode.cc != null) { - captions = await getCaptions(currentEpisode.cc) + captions = await getCaptions(currentEpisode.cc); } ctx.progress(95); @@ -82,7 +82,7 @@ export const insertunitScraper = makeSourcerer({ if (subtitleJSONData != null && subtitleJSONData[1] != null) { const subtitleData = JSON.parse(subtitleJSONData[1]); - captions = await getCaptions(subtitleData) + captions = await getCaptions(subtitleData); } ctx.progress(90); From 8281c3141aa04c4444ec44ad120527e827e3cf72 Mon Sep 17 00:00:00 2001 From: teddyHV11 Date: Thu, 11 Apr 2024 06:31:53 +0300 Subject: [PATCH 3/4] Rename insertunit.ts to index.ts --- src/providers/all.ts | 2 +- src/providers/sources/insertunit/{insertunit.ts => index.ts} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/providers/sources/insertunit/{insertunit.ts => index.ts} (100%) diff --git a/src/providers/all.ts b/src/providers/all.ts index 675aa36..887290d 100644 --- a/src/providers/all.ts +++ b/src/providers/all.ts @@ -14,7 +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/insertunit'; +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'; diff --git a/src/providers/sources/insertunit/insertunit.ts b/src/providers/sources/insertunit/index.ts similarity index 100% rename from src/providers/sources/insertunit/insertunit.ts rename to src/providers/sources/insertunit/index.ts From 6a0ac52908f178306faf41f29273e1bae6bedf6a Mon Sep 17 00:00:00 2001 From: teddyHV11 Date: Thu, 11 Apr 2024 17:49:32 +0300 Subject: [PATCH 4/4] Fix prettier errors --- src/providers/sources/insertunit/types.ts | 50 +++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/providers/sources/insertunit/types.ts b/src/providers/sources/insertunit/types.ts index 282c3c4..587ae36 100644 --- a/src/providers/sources/insertunit/types.ts +++ b/src/providers/sources/insertunit/types.ts @@ -1,30 +1,30 @@ -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 Subtitle { + url: string; + name: string; } -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[] -} \ No newline at end of file + season: number; + blocked: boolean; + episodes: Episode[]; +}