diff --git a/src/backend/embeds/mp4upload.ts b/src/backend/embeds/mp4upload.ts new file mode 100644 index 00000000..3902e20b --- /dev/null +++ b/src/backend/embeds/mp4upload.ts @@ -0,0 +1,32 @@ +import { MWEmbedType } from "@/backend/helpers/embed"; +import { registerEmbedScraper } from "@/backend/helpers/register"; +import { MWStreamQuality, MWStreamType } from "@/backend/helpers/streams"; + +import { proxiedFetch } from "../helpers/fetch"; + +registerEmbedScraper({ + id: "mp4upload", + displayName: "mp4upload", + for: MWEmbedType.MP4UPLOAD, + rank: 170, + async getStream({ url }) { + const embed = await proxiedFetch(url); + + const playerSrcRegex = + /(?<=player\.src\()\s*{\s*type:\s*"[^"]+",\s*src:\s*"([^"]+)"\s*}\s*(?=\);)/s; + + const playerSrc = embed.match(playerSrcRegex); + + const streamUrl = playerSrc[1]; + + if (!streamUrl) throw new Error("Stream url not found"); + + return { + embedId: MWEmbedType.MP4UPLOAD, + streamUrl, + quality: MWStreamQuality.Q1080P, + captions: [], + type: MWStreamType.MP4, + }; + }, +}); diff --git a/src/backend/index.ts b/src/backend/index.ts index 065f1c62..a2beaa2a 100644 --- a/src/backend/index.ts +++ b/src/backend/index.ts @@ -17,5 +17,6 @@ import "./embeds/streamm4u"; import "./embeds/playm4u"; import "./embeds/upcloud"; import "./embeds/streamsb"; +import "./embeds/mp4upload"; initializeScraperStore();