|
|
@ -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({ |
|
|
|
registerProvider({ |
|
|
|
id: "superstream", |
|
|
|
id: "superstream", |
|
|
|
displayName: "Superstream", |
|
|
|
displayName: "Superstream", |
|
|
@ -138,19 +148,7 @@ registerProvider({ |
|
|
|
const mediaRes = (await get(apiQuery)).data; |
|
|
|
const mediaRes = (await get(apiQuery)).data; |
|
|
|
progress(50); |
|
|
|
progress(50); |
|
|
|
|
|
|
|
|
|
|
|
const hdQuality = |
|
|
|
const hdQuality = getBestQuality(mediaRes.list); |
|
|
|
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 |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!hdQuality) throw new Error("No quality could be found."); |
|
|
|
if (!hdQuality) throw new Error("No quality could be found."); |
|
|
|
|
|
|
|
|
|
|
@ -210,19 +208,7 @@ registerProvider({ |
|
|
|
const mediaRes = (await get(apiQuery)).data; |
|
|
|
const mediaRes = (await get(apiQuery)).data; |
|
|
|
progress(66); |
|
|
|
progress(66); |
|
|
|
|
|
|
|
|
|
|
|
const hdQuality = |
|
|
|
const hdQuality = getBestQuality(mediaRes.list); |
|
|
|
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 |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!hdQuality) throw new Error("No quality could be found."); |
|
|
|
if (!hdQuality) throw new Error("No quality could be found."); |
|
|
|
|
|
|
|
|