From 81668fe9e7b15f3a50965874add3c1d2f9126f2e Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 29 Dec 2023 18:33:58 +0100 Subject: [PATCH 1/4] Fix febbox qualities --- src/providers/embeds/febbox/qualities.ts | 34 ++++++++++++++++-------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/providers/embeds/febbox/qualities.ts b/src/providers/embeds/febbox/qualities.ts index 54f8866..1a59177 100644 --- a/src/providers/embeds/febbox/qualities.ts +++ b/src/providers/embeds/febbox/qualities.ts @@ -4,24 +4,36 @@ import { ScrapeContext } from '@/utils/context'; const allowedQualities = ['360', '480', '720', '1080', '4k']; -export async function getStreamQualities(ctx: ScrapeContext, apiQuery: object) { - const mediaRes: { list: { path: string; quality: string; fid?: number }[] } = (await sendRequest(ctx, apiQuery)).data; +interface FebboxQuality { + path: string; + real_quality: string; + fid?: number; +} - const qualityMap = mediaRes.list - .filter((file) => allowedQualities.includes(file.quality.replace('p', ''))) - .map((file) => ({ - url: file.path, - quality: file.quality.replace('p', ''), - })); +function mapToQuality(quality: FebboxQuality): FebboxQuality | null { + console.log(quality); + const q = quality.real_quality.replace('p', '').toLowerCase(); + if (!allowedQualities.includes(q)) return null; + return { + real_quality: q, + path: quality.path, + fid: quality.fid, + }; +} + +export async function getStreamQualities(ctx: ScrapeContext, apiQuery: object) { + const mediaRes: { list: FebboxQuality[] } = (await sendRequest(ctx, apiQuery)).data; + + const qualityMap = mediaRes.list.map((v) => mapToQuality(v)).filter((v): v is FebboxQuality => !!v); const qualities: Record = {}; allowedQualities.forEach((quality) => { - const foundQuality = qualityMap.find((q) => q.quality === quality); - if (foundQuality && foundQuality.url) { + const foundQuality = qualityMap.find((q) => q.real_quality === quality); + if (foundQuality && foundQuality.path) { qualities[quality] = { type: 'mp4', - url: foundQuality.url, + url: foundQuality.path, }; } }); From 9b7314321ec2cf023ab82e4bbf1c83daf0cc5464 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 29 Dec 2023 20:32:24 +0100 Subject: [PATCH 2/4] Fix 4k for febbox --- package.json | 2 +- src/providers/embeds/febbox/qualities.ts | 5 ++--- src/runners/runner.ts | 12 ++++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index cbf5a5f..4b91441 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@movie-web/providers", - "version": "2.0.0", + "version": "2.0.1", "description": "Package that contains all the providers of movie-web", "main": "./lib/index.umd.js", "types": "./lib/index.d.ts", diff --git a/src/providers/embeds/febbox/qualities.ts b/src/providers/embeds/febbox/qualities.ts index 1a59177..b55dd72 100644 --- a/src/providers/embeds/febbox/qualities.ts +++ b/src/providers/embeds/febbox/qualities.ts @@ -11,7 +11,6 @@ interface FebboxQuality { } function mapToQuality(quality: FebboxQuality): FebboxQuality | null { - console.log(quality); const q = quality.real_quality.replace('p', '').toLowerCase(); if (!allowedQualities.includes(q)) return null; return { @@ -29,8 +28,8 @@ export async function getStreamQualities(ctx: ScrapeContext, apiQuery: object) { const qualities: Record = {}; allowedQualities.forEach((quality) => { - const foundQuality = qualityMap.find((q) => q.real_quality === quality); - if (foundQuality && foundQuality.path) { + const foundQuality = qualityMap.find((q) => q.real_quality === quality && q.path); + if (foundQuality) { qualities[quality] = { type: 'mp4', url: foundQuality.path, diff --git a/src/runners/runner.ts b/src/runners/runner.ts index 1774213..69a816f 100644 --- a/src/runners/runner.ts +++ b/src/runners/runner.ts @@ -116,9 +116,13 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt }; } - if (output.embeds.length > 0) { + // run embed scrapers on listed embeds + const sortedEmbeds = output.embeds; + sortedEmbeds.sort((a, b) => embedIds.indexOf(a.embedId) - embedIds.indexOf(b.embedId)); + + if (sortedEmbeds.length > 0) { ops.events?.discoverEmbeds?.({ - embeds: output.embeds.map((v, i) => ({ + embeds: sortedEmbeds.map((v, i) => ({ id: [s.id, i].join('-'), embedScraperId: v.embedId, })), @@ -126,10 +130,6 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt }); } - // run embed scrapers on listed embeds - const sortedEmbeds = output.embeds; - sortedEmbeds.sort((a, b) => embedIds.indexOf(a.embedId) - embedIds.indexOf(b.embedId)); - for (const ind in sortedEmbeds) { if (!Object.prototype.hasOwnProperty.call(sortedEmbeds, ind)) continue; const e = sortedEmbeds[ind]; From 3c072f0d1192b815c16cce0f010f366dc9c96b9e Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 29 Dec 2023 20:46:03 +0100 Subject: [PATCH 3/4] Update docs --- .docs/content/1.get-started/4.changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.docs/content/1.get-started/4.changelog.md b/.docs/content/1.get-started/4.changelog.md index 90dce1b..8e65d9e 100644 --- a/.docs/content/1.get-started/4.changelog.md +++ b/.docs/content/1.get-started/4.changelog.md @@ -2,6 +2,10 @@ title: 'Changelog' --- +# Version 2.0.1 +- Fixed issue where febbox-mp4 would not show all qualities +- Fixed issue where discoverEmbeds event would not show the embeds in the right order + # Version 2.0.0 ::alert{type="warning"} From ac3dfb98e12527f969256ef59c25db6306f15d0b Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 29 Dec 2023 21:01:18 +0100 Subject: [PATCH 4/4] Update src/runners/runner.ts Co-authored-by: Jip Frijlink --- src/runners/runner.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/runners/runner.ts b/src/runners/runner.ts index 69a816f..eaf6285 100644 --- a/src/runners/runner.ts +++ b/src/runners/runner.ts @@ -117,8 +117,7 @@ export async function runAllProviders(list: ProviderList, ops: ProviderRunnerOpt } // run embed scrapers on listed embeds - const sortedEmbeds = output.embeds; - sortedEmbeds.sort((a, b) => embedIds.indexOf(a.embedId) - embedIds.indexOf(b.embedId)); + const sortedEmbeds = output.embeds.sort((a, b) => embedIds.indexOf(a.embedId) - embedIds.indexOf(b.embedId)); if (sortedEmbeds.length > 0) { ops.events?.discoverEmbeds?.({