mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-29 16:07:40 +01:00
chore(superstream): improve import, move quality finding to its own function
This commit is contained in:
parent
7a2865313d
commit
fa9785bf69
2 changed files with 13 additions and 27 deletions
|
@ -3,7 +3,7 @@ import { initializeScraperStore } from "./helpers/register";
|
|||
// providers
|
||||
import "./providers/gdriveplayer";
|
||||
import "./providers/flixhq";
|
||||
import "./providers/superstream/superstream";
|
||||
import "./providers/superstream";
|
||||
|
||||
// embeds
|
||||
// -- nothing here yet
|
||||
|
|
|
@ -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,19 +148,7 @@ 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.");
|
||||
|
||||
|
@ -210,19 +208,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.");
|
||||
|
Loading…
Reference in a new issue