add headers

This commit is contained in:
Jorrin
2024-01-10 21:21:47 +01:00
parent 1dc7c879af
commit 7697c76721
2 changed files with 24 additions and 0 deletions

View File

@@ -4,6 +4,9 @@ import { flags } from '@/entrypoint/utils/targets';
import { makeEmbed } from '@/providers/base';
import { Caption, getCaptionTypeFromUrl, labelToLanguageCode } from '@/providers/captions';
const origin = 'https://rabbitstream.net';
const referer = 'https://rabbitstream.net/';
const { AES, enc } = crypto;
interface StreamRes {
@@ -126,6 +129,10 @@ export const upcloudScraper = makeEmbed({
playlist: sources.file,
flags: [flags.CORS_ALLOWED],
captions,
preferredHeaders: {
Referer: referer,
Origin: origin,
},
},
],
};

View File

@@ -4,6 +4,9 @@ import { NotFoundError } from '@/utils/errors';
const remotestreamBase = atob('aHR0cHM6Ly9mc2IuOG1ldDNkdGpmcmNxY2hjb25xcGtsd3hzeGIyb2N1bWMuc3RyZWFt');
const origin = 'https://remotestre.am';
const referer = 'https://remotestre.am/';
export const remotestreamScraper = makeSourcerer({
id: 'remotestream',
name: 'Remote Stream',
@@ -19,6 +22,9 @@ export const remotestreamScraper = makeSourcerer({
const streamRes = await ctx.fetcher.full(playlistLink, {
method: 'HEAD',
readHeaders: ['content-type'],
headers: {
Referer: referer,
},
});
if (!streamRes.headers.get('content-type')?.toLowerCase().includes('application/x-mpegurl'))
throw new NotFoundError('No watchable item found');
@@ -33,6 +39,10 @@ export const remotestreamScraper = makeSourcerer({
playlist: playlistLink,
type: 'hls',
flags: [flags.CORS_ALLOWED],
preferredHeaders: {
Referer: referer,
Origin: origin,
},
},
],
};
@@ -44,6 +54,9 @@ export const remotestreamScraper = makeSourcerer({
const streamRes = await ctx.fetcher.full(playlistLink, {
method: 'HEAD',
readHeaders: ['content-type'],
headers: {
Referer: referer,
},
});
if (!streamRes.headers.get('content-type')?.toLowerCase().includes('application/x-mpegurl'))
throw new NotFoundError('No watchable item found');
@@ -58,6 +71,10 @@ export const remotestreamScraper = makeSourcerer({
playlist: playlistLink,
type: 'hls',
flags: [flags.CORS_ALLOWED],
preferredHeaders: {
Referer: referer,
Origin: origin,
},
},
],
};