Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/providers/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ import {
} from './embeds/vidsrcsu';
import { viperScraper } from './embeds/viper';
import { voeScraper } from './embeds/voe';
import { vidkingEmbedScraper } from './embeds/vidking';
import { vidkingScraper } from './sources/vidking';
import { warezcdnembedHlsScraper } from './embeds/warezcdn/hls';
import { warezcdnembedMp4Scraper } from './embeds/warezcdn/mp4';
import { warezPlayerScraper } from './embeds/warezcdn/warezplayer';
Expand Down Expand Up @@ -143,6 +145,7 @@ export function gatherAllSources(): Array<Sourcerer> {
fullhdfilmizleScraper,
vidlinkScraper,
vidrockScraper,
vidkingScraper,
watchanimeworldScraper,
];
}
Expand Down Expand Up @@ -210,5 +213,6 @@ export function gatherAllEmbeds(): Array<Embed> {
droploadScraper,
supervideoScraper,
voeScraper,
vidkingEmbedScraper,
];
}
101 changes: 101 additions & 0 deletions src/providers/embeds/vidking.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { flags } from '@/entrypoint/utils/targets';
import { makeEmbed } from '@/providers/base';

const userAgent =
'Mozilla/5.0 (Linux; Android 11; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Mobile Safari/537.36';

export const vidkingEmbedScraper = makeEmbed({
id: 'vidking',
name: 'VidKing',
rank: 175,
flags: [flags.CORS_ALLOWED],
async scrape(ctx) {
const url = ctx.url;
const parsedUrl = new URL(url);
const origin = parsedUrl.origin;

const headers: Record<string, string> = {
'User-Agent': userAgent,
Referer: origin,
Origin: origin,
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.9',
};

const html = await ctx.proxiedFetcher<string>(url, { headers });

const m3u8Match = html.match(/["'](https?:\/\/[^"']+\.m3u8[^"']*)["']/i);
const sourceMatch = html.match(/src["']?\s*[:=]\s*["'](https?:\/\/[^"']+)["']/i);
const manifestMatch = html.match(/(https?:\/\/[^"']+\.m3u8[^"']*)/i);
const hlsMatch = html.match(/hls["']?\s*[:=]\s*["']([^"']+)["']/i);

let videoUrl = m3u8Match?.[1] || manifestMatch?.[1] || hlsMatch?.[1] || sourceMatch?.[1];

if (!videoUrl) {
const scriptMatch = html.match(/var\s+(?:source|video|url|hlsUrl|manifest|stream)\s*=\s*["']([^"']+)["']/i);
if (scriptMatch) {
videoUrl = scriptMatch[1];
}
}

if (!videoUrl) {
const jsonMatch = html.match(/\{[^}]*"(?:src|source|url|hls|manifest)"\s*:\s*"([^"]+)"/i);
if (jsonMatch) {
videoUrl = jsonMatch[1];
}
}

if (!videoUrl) {
throw new Error('No video URL found in VidKing embed');
}

if (videoUrl.startsWith('//')) {
videoUrl = `https:${videoUrl}`;
} else if (videoUrl.startsWith('/')) {
videoUrl = `${origin}${videoUrl}`;
}

const isHls = videoUrl.includes('.m3u8') || /\.m3u8[?#]/.test(videoUrl);

if (isHls) {
return {
stream: [
{
id: 'primary',
type: 'hls',
playlist: videoUrl,
flags: [flags.CORS_ALLOWED],
captions: [],
headers: {
Referer: origin,
Origin: origin,
'User-Agent': userAgent,
},
},
],
};
}

return {
stream: [
{
id: 'primary',
type: 'file',
flags: [flags.CORS_ALLOWED],
captions: [],
qualities: {
unknown: {
type: 'mp4',
url: videoUrl,
},
},
preferredHeaders: {
Referer: origin,
Origin: origin,
'User-Agent': userAgent,
},
},
],
};
},
});
30 changes: 30 additions & 0 deletions src/providers/sources/vidking.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { flags } from '@/entrypoint/utils/targets';
import { SourcererOutput, makeSourcerer } from '@/providers/base';
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';

const baseUrl = 'https://www.vidking.net';

async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext): Promise<SourcererOutput> {
const url =
ctx.media.type === 'movie'
? `${baseUrl}/embed/movie/${ctx.media.tmdbId}`
: `${baseUrl}/embed/tv/${ctx.media.tmdbId}/${ctx.media.season.number}/${ctx.media.episode.number}`;

return {
embeds: [
{
embedId: 'vidking',
url,
},
],
};
}

export const vidkingScraper = makeSourcerer({
id: 'vidking',
name: 'VidKing',
rank: 175,
flags: [flags.CORS_ALLOWED],
scrapeMovie: comboScraper,
scrapeShow: comboScraper,
});