diff --git a/src/providers/all.ts b/src/providers/all.ts index 31dbe566..c7fb7f8d 100644 --- a/src/providers/all.ts +++ b/src/providers/all.ts @@ -74,6 +74,7 @@ import { cinehdplusScraper } from './sources/cinehdplus-es'; import { coitusScraper } from './sources/coitus'; import { cuevana3Scraper } from './sources/cuevana3'; import { debridScraper } from './sources/debrid'; +import { diziyouScraper } from './sources/diziyou'; import { embedsuScraper } from './sources/embedsu'; import { fullhdfilmizleScraper } from './sources/fullhdfilmizle'; import { hdRezkaScraper } from './sources/hdrezka'; @@ -138,6 +139,7 @@ export function gatherAllSources(): Array { debridScraper, cinehdplusScraper, fullhdfilmizleScraper, + diziyouScraper, ]; } diff --git a/src/providers/sources/diziyou/helpers.ts b/src/providers/sources/diziyou/helpers.ts new file mode 100644 index 00000000..787f8df7 --- /dev/null +++ b/src/providers/sources/diziyou/helpers.ts @@ -0,0 +1,13 @@ +export function urlifyTitle(title: string): string { + return title + .toString() + .normalize('NFD') + .replace(/[\u0300-\u036f]/g, '') + .toLowerCase() + .trim() + .replace(/\s+/g, '-') + .replace(/[^\w-]+/g, '') + .replace(/--+/g, '-') + .replace(/^-+/, '') + .replace(/-+$/, ''); +} diff --git a/src/providers/sources/diziyou/index.ts b/src/providers/sources/diziyou/index.ts new file mode 100644 index 00000000..42d77211 --- /dev/null +++ b/src/providers/sources/diziyou/index.ts @@ -0,0 +1,127 @@ +/* eslint-disable no-console */ +import { flags } from '@/entrypoint/utils/targets'; +import { SourcererOutput, makeSourcerer } from '@/providers/base'; +import { Caption } from '@/providers/captions'; +import { ShowScrapeContext } from '@/utils/context'; +import { NotFoundError } from '@/utils/errors'; + +import { urlifyTitle } from './helpers'; + +const baseUrl = 'https://www.diziyou.one'; + +const headers = { + Referer: baseUrl, + Accept: 'application/json, text/javascript, */*; q=0.01', + 'User-Agent': + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', +}; + +async function scrapeShow(ctx: ShowScrapeContext): Promise { + if (!ctx.media.title) { + throw new NotFoundError('Media title is not provided'); + } + + const urlTitle = urlifyTitle(ctx.media.title); + const showPage = await ctx.proxiedFetcher.full(`/${urlTitle}/`, { + baseUrl, + headers, + }); + + if (showPage.statusCode === 404) { + throw new NotFoundError('Media not found'); + } + + ctx.progress(30); + + const mediaUrl = `/${urlTitle}-${ctx.media.season.number}-sezon-${ctx.media.episode.number}-bolum/`; + const mediaPage = await ctx.proxiedFetcher.full(mediaUrl, { + baseUrl, + headers, + }); + if (mediaPage.statusCode !== 200) { + throw new NotFoundError('Episode not found'); + } + + // If there is no turkish dubbed + if (!mediaPage.body.includes('id="turkceDublaj"')) { + throw new NotFoundError('Dubbed version not found'); + } + if (!mediaPage.body.includes('