mirror of
https://github.com/p-stream/providers.git
synced 2026-03-11 17:55:36 +00:00
parent
8504278157
commit
e66b7a2982
2 changed files with 0 additions and 62 deletions
|
|
@ -1,11 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>Dev CLI Browser Mode</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script type="module" src="index.ts"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
import { makeProviders, makeStandardFetcher, targets } from '../../../lib/index.js';
|
|
||||||
|
|
||||||
async function scrape(proxy: string, type: 'embed' | 'source', input: any) {
|
|
||||||
// Set up proxy if provided
|
|
||||||
let fetcher = makeStandardFetcher(fetch);
|
|
||||||
if (proxy) {
|
|
||||||
fetcher = makeStandardFetcher(async (url: string, options?: RequestInit) => {
|
|
||||||
const response = await fetch(proxy, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
url,
|
|
||||||
options,
|
|
||||||
}),
|
|
||||||
mode: 'no-cors',
|
|
||||||
});
|
|
||||||
const data = await response.json();
|
|
||||||
return new Response(data.body, {
|
|
||||||
status: data.status,
|
|
||||||
statusText: data.statusText,
|
|
||||||
headers: data.headers,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const providers = makeProviders({
|
|
||||||
fetcher,
|
|
||||||
target: targets.ANY,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (type === 'embed') {
|
|
||||||
return providers.runEmbedScraper({
|
|
||||||
disableOpensubtitles: true,
|
|
||||||
url: input.url,
|
|
||||||
id: input.id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (type === 'source') {
|
|
||||||
return providers.runSourceScraper({
|
|
||||||
disableOpensubtitles: true,
|
|
||||||
media: input.media,
|
|
||||||
id: input.id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error('Invalid scrape type');
|
|
||||||
}
|
|
||||||
|
|
||||||
(window as any).scrape = scrape;
|
|
||||||
Loading…
Reference in a new issue