mirror of
https://github.com/p-stream/providers.git
synced 2026-03-11 17:55:36 +00:00
update vidify
This commit is contained in:
parent
b5ec1e08fb
commit
8af4345b70
2 changed files with 49 additions and 52 deletions
|
|
@ -1,11 +1,59 @@
|
|||
/* eslint-disable no-console */
|
||||
import { flags } from '@/entrypoint/utils/targets';
|
||||
import { NotFoundError } from '@/utils/errors';
|
||||
import { findFirstM3U8Url } from '@/utils/m3u8';
|
||||
import { createM3U8ProxyUrl } from '@/utils/proxy';
|
||||
|
||||
import { EmbedOutput, makeEmbed } from '../base';
|
||||
|
||||
// Do not do this. This is very lazy!
|
||||
const M3U8_URL_REGEX = /https?:\/\/[^\s"'<>]+?\.m3u8[^\s"'<>]*/i;
|
||||
|
||||
function extractFromString(input: string): string | null {
|
||||
const match = input.match(M3U8_URL_REGEX);
|
||||
return match ? match[0] : null;
|
||||
}
|
||||
|
||||
function findFirstM3U8Url(input: unknown): string | null {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(input);
|
||||
const visited = new Set<unknown>();
|
||||
|
||||
function dfs(node: unknown): string | null {
|
||||
if (node == null) return null;
|
||||
if (visited.has(node)) return null;
|
||||
// Only mark objects/arrays as visited to avoid blocking primitives
|
||||
if (typeof node === 'object') visited.add(node);
|
||||
|
||||
if (typeof node === 'string') {
|
||||
return extractFromString(node);
|
||||
}
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
for (const element of node) {
|
||||
const found = dfs(element);
|
||||
if (found) return found;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof node === 'object') {
|
||||
for (const value of Object.values(node as Record<string, unknown>)) {
|
||||
if (typeof value === 'string') {
|
||||
const foundInString = extractFromString(value);
|
||||
if (foundInString) return foundInString;
|
||||
} else {
|
||||
const found = dfs(value);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return dfs(input);
|
||||
}
|
||||
|
||||
const baseUrl = 'api.vidify.top';
|
||||
const headers = {
|
||||
referer: 'https://player.vidify.top/',
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
/**
|
||||
* Utilities for extracting HLS playlist URLs from arbitrary data structures.
|
||||
*/
|
||||
|
||||
const M3U8_URL_REGEX = /https?:\/\/[^\s"'<>]+?\.m3u8[^\s"'<>]*/i;
|
||||
|
||||
function extractFromString(input: string): string | null {
|
||||
const match = input.match(M3U8_URL_REGEX);
|
||||
return match ? match[0] : null;
|
||||
}
|
||||
|
||||
export function findFirstM3U8Url(input: unknown): string | null {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(input);
|
||||
const visited = new Set<unknown>();
|
||||
|
||||
function dfs(node: unknown): string | null {
|
||||
if (node == null) return null;
|
||||
if (visited.has(node)) return null;
|
||||
// Only mark objects/arrays as visited to avoid blocking primitives
|
||||
if (typeof node === 'object') visited.add(node);
|
||||
|
||||
if (typeof node === 'string') {
|
||||
return extractFromString(node);
|
||||
}
|
||||
|
||||
if (Array.isArray(node)) {
|
||||
for (const element of node) {
|
||||
const found = dfs(element);
|
||||
if (found) return found;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof node === 'object') {
|
||||
for (const value of Object.values(node as Record<string, unknown>)) {
|
||||
if (typeof value === 'string') {
|
||||
const foundInString = extractFromString(value);
|
||||
if (foundInString) return foundInString;
|
||||
} else {
|
||||
const found = dfs(value);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return dfs(input);
|
||||
}
|
||||
Loading…
Reference in a new issue