This commit is contained in:
bytedream 2025-04-04 00:01:21 +02:00
parent 8d575241fe
commit 8a13dea681
4 changed files with 16 additions and 12 deletions

View File

@ -1,5 +1,5 @@
import {getMatch, type Match, MatchMediaType} from '~/lib/match';
import {Other, Redirect} from '~/lib/settings';
import { getMatch, type Match, MatchMediaType } from '~/lib/match';
import { Other, Redirect } from '~/lib/settings';
async function main() {
let match: Match | null;

View File

@ -1,6 +1,6 @@
import {matches, MatchMediaType} from '~/lib/match';
import { matches, MatchMediaType } from '~/lib/match';
import Hls from 'hls.js';
import {UrlReferer} from '~/lib/settings';
import { UrlReferer } from '~/lib/settings';
async function playNative(url: string, domain: string, videoElem: HTMLVideoElement) {
await UrlReferer.set(new URL(url).hostname, domain);

View File

@ -1,6 +1,6 @@
import { unpack } from './util/userspace';
import { Hosters, Redirect, TmpHost } from './settings';
import {lastPathSegment} from "~/lib/util/extract";
import { lastPathSegment } from '~/lib/util/extract';
export interface Match {
name: string;
@ -10,12 +10,16 @@ export interface Match {
regex: RegExp[];
notice?: string;
match(match: RegExpMatchArray): Promise<string | {[MatchMediaType.Hls]: string} | {[MatchMediaType.Native]: string} | null>;
match(
match: RegExpMatchArray
): Promise<
string | { [MatchMediaType.Hls]: string } | { [MatchMediaType.Native]: string } | null
>;
}
export enum MatchMediaType {
Hls = 'hls',
Native = 'native',
Native = 'native'
}
export const Doodstream: Match = {
@ -134,7 +138,7 @@ export const LoadX: Match = {
const videoSource: string = responseJson['videoSource'];
// extension of extracted url is '.txt', so we have to manually specify that it's a hls
return {[MatchMediaType.Hls]: videoSource.replace('\\/', '/')};
return { [MatchMediaType.Hls]: videoSource.replace('\\/', '/') };
}
};

View File

@ -1,6 +1,6 @@
export function lastPathSegment(path: string): string {
while (path.endsWith('/')) {
path = path.slice(0, -1);
}
return path.substring(path.lastIndexOf('/') + 1);
while (path.endsWith('/')) {
path = path.slice(0, -1);
}
return path.substring(path.lastIndexOf('/') + 1);
}