Skip to content

Commit

Permalink
Merge pull request #125 from zisra/primewire
Browse files Browse the repository at this point in the history
Fix febbox
  • Loading branch information
binaryoverload authored Mar 29, 2024
2 parents 234209e + fa30ed2 commit a5bf932
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/providers/embeds/febbox/qualities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ function mapToQuality(quality: FebboxQuality): FebboxQuality | null {
};
}

function removeBadUrlParams(url: string): string {
const urlObject = new URL(url);

const urlSearchParams = new URLSearchParams(urlObject.search);

const keysToKeep = ['KEY1', 'KEY2'];
for (const key of Array.from(urlSearchParams.keys())) {
if (!keysToKeep.includes(key)) {
urlSearchParams.delete(key);
}
}

return `${urlObject.origin}${urlObject.pathname}?${urlSearchParams.toString()}`;
}

export async function getStreamQualities(ctx: ScrapeContext, apiQuery: object) {
const mediaRes: { list: FebboxQuality[] } = (await sendRequest(ctx, apiQuery)).data;

Expand All @@ -32,7 +47,7 @@ export async function getStreamQualities(ctx: ScrapeContext, apiQuery: object) {
if (foundQuality) {
qualities[quality] = {
type: 'mp4',
url: foundQuality.path,
url: removeBadUrlParams(foundQuality.path),
};
}
});
Expand Down

0 comments on commit a5bf932

Please sign in to comment.