febbox use actual qualities

This commit is contained in:
2023-09-29 22:44:59 -05:00
parent 2f289d93d0
commit 7feaf9256f
4 changed files with 15 additions and 13 deletions

View File

@@ -1,9 +1,12 @@
import { flags } from '@/main/targets'; import { flags } from '@/main/targets';
import { makeEmbed } from '@/providers/base'; import { makeEmbed } from '@/providers/base';
import { StreamFile } from '@/providers/streams';
import { NotFoundError } from '@/utils/errors'; import { NotFoundError } from '@/utils/errors';
const febBoxBase = `https://www.febbox.com`; const febBoxBase = `https://www.febbox.com`;
const allowedQualities = ['360', '480', '720', '1080'];
export const febBoxScraper = makeEmbed({ export const febBoxScraper = makeEmbed({
id: 'febBox', id: 'febBox',
name: 'FebBox', name: 'FebBox',
@@ -40,18 +43,22 @@ export const febBoxScraper = makeEmbed({
const sourcesMatch = player?.match(/var sources = (\[[^\]]+\]);/); const sourcesMatch = player?.match(/var sources = (\[[^\]]+\]);/);
const qualities = sourcesMatch ? JSON.parse(sourcesMatch[0].replace('var sources = ', '').replace(';', '')) : null; const qualities = sourcesMatch ? JSON.parse(sourcesMatch[0].replace('var sources = ', '').replace(';', '')) : null;
if (!qualities) throw new NotFoundError('no result found'); const embedQualities: Record<string, StreamFile> = {};
qualities.forEach((quality: { file: string; label: string }) => {
if (allowedQualities.includes(quality.label.replace('P', ''))) {
embedQualities[quality.label.replace('p', '')] = {
type: 'mp4',
url: quality.file,
};
}
});
return { return {
stream: { stream: {
type: 'file', type: 'file',
flags: [flags.NO_CORS], flags: [flags.NO_CORS],
qualities: { qualities: embedQualities,
'360': {
type: 'mp4',
url: qualities[0].file,
},
},
}, },
}; };
}, },

View File

@@ -1,6 +1,3 @@
// https://www.febbox.com/file/file_share_list?share_key=${id}&pwd= > data.file_list[0].fid
// https://www.febbox.com/file/player FORM: {hare_key} > "parse js"
import { load } from 'cheerio'; import { load } from 'cheerio';
import { flags } from '@/main/targets'; import { flags } from '@/main/targets';

View File

@@ -3,7 +3,7 @@ import { ScrapeContext } from '@/utils/context';
import { sendRequest } from './sendRequest'; import { sendRequest } from './sendRequest';
import { allowedQualities } from '.'; const allowedQualities = ['360', '480', '720', '1080'];
export async function getStreamQualities(ctx: ScrapeContext, apiQuery: object) { export async function getStreamQualities(ctx: ScrapeContext, apiQuery: object) {
const mediaRes: { list: { path: string; real_quality: string }[] } = (await sendRequest(ctx, apiQuery)).data; const mediaRes: { list: { path: string; real_quality: string }[] } = (await sendRequest(ctx, apiQuery)).data;

View File

@@ -6,8 +6,6 @@ import { NotFoundError } from '@/utils/errors';
import { getStreamQualities } from './getStreamQualities'; import { getStreamQualities } from './getStreamQualities';
import { sendRequest } from './sendRequest'; import { sendRequest } from './sendRequest';
export const allowedQualities = ['360', '480', '720', '1080'];
export const superStreamScraper = makeSourcerer({ export const superStreamScraper = makeSourcerer({
id: 'superstream', id: 'superstream',
name: 'Superstream', name: 'Superstream',