Merge pull request #122 from JipFr/v3-superstream

Slight improvements in superstream scraper
This commit is contained in:
mrjvs 2023-01-22 23:09:10 +01:00 committed by GitHub
commit 1579e23dba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 29 deletions

View File

@ -3,8 +3,8 @@ import { initializeScraperStore } from "./helpers/register";
// providers
import "./providers/gdriveplayer";
import "./providers/flixhq";
import "./providers/superstream";
import "./providers/gomostream";
import "./providers/superstream/superstream";
// embeds
// -- nothing here yet

View File

@ -98,6 +98,16 @@ const get = (data: object, altApi = false) => {
});
};
// Find best resolution
const getBestQuality = (list: any[]) => {
return (
list.find((quality: any) => quality.quality === "1080p" && quality.path) ??
list.find((quality: any) => quality.quality === "720p" && quality.path) ??
list.find((quality: any) => quality.quality === "480p" && quality.path) ??
list.find((quality: any) => quality.quality === "360p" && quality.path)
);
};
registerProvider({
id: "superstream",
displayName: "Superstream",
@ -138,24 +148,10 @@ registerProvider({
const mediaRes = (await get(apiQuery)).data;
progress(50);
const hdQuality =
mediaRes.list.find(
(quality: any) => quality.quality === "1080p" && quality.path
) ??
mediaRes.list.find(
(quality: any) => quality.quality === "720p" && quality.path
) ??
mediaRes.list.find(
(quality: any) => quality.quality === "480p" && quality.path
) ??
mediaRes.list.find(
(quality: any) => quality.quality === "360p" && quality.path
);
const hdQuality = getBestQuality(mediaRes.list);
if (!hdQuality) throw new Error("No quality could be found.");
console.log(hdQuality);
// const subtitleApiQuery = {
// fid: hdQuality.fid,
// uid: "",
@ -210,19 +206,7 @@ registerProvider({
const mediaRes = (await get(apiQuery)).data;
progress(66);
const hdQuality =
mediaRes.list.find(
(quality: any) => quality.quality === "1080p" && quality.path
) ??
mediaRes.list.find(
(quality: any) => quality.quality === "720p" && quality.path
) ??
mediaRes.list.find(
(quality: any) => quality.quality === "480p" && quality.path
) ??
mediaRes.list.find(
(quality: any) => quality.quality === "360p" && quality.path
);
const hdQuality = getBestQuality(mediaRes.list);
if (!hdQuality) throw new Error("No quality could be found.");