fix: always move errors up and external urls down
This commit is contained in:
parent
a96d015a0c
commit
ddc8133c5b
2 changed files with 55 additions and 51 deletions
|
|
@ -69,6 +69,14 @@ export class StreamResolver {
|
|||
await Promise.all(sourcePromises);
|
||||
|
||||
urlResults.sort((a, b) => {
|
||||
if (a.error || b.error) {
|
||||
return a.isExternal ? -1 : 1;
|
||||
}
|
||||
|
||||
if (a.isExternal || b.isExternal) {
|
||||
return a.isExternal ? 1 : -1;
|
||||
}
|
||||
|
||||
const heightComparison = (b.meta?.height ?? 0) - (a.meta?.height ?? 0);
|
||||
if (heightComparison !== 0) {
|
||||
return heightComparison;
|
||||
|
|
@ -79,10 +87,6 @@ export class StreamResolver {
|
|||
return bytesComparison;
|
||||
}
|
||||
|
||||
if (a.isExternal || b.isExternal) {
|
||||
return a.isExternal ? 1 : -1;
|
||||
}
|
||||
|
||||
return a.label.localeCompare(b.label);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -30,21 +30,48 @@ exports[`resolve adds error info 2`] = `
|
|||
"streams": [
|
||||
{
|
||||
"behaviorHints": {
|
||||
"bingeGroup": "webstreamr-hostercom",
|
||||
"notWebReady": true,
|
||||
},
|
||||
"externalUrl": "https://example5.com/",
|
||||
"name": "WebStreamr 🇩🇪",
|
||||
"title": "🔗 working1",
|
||||
"url": "https://working2.com/",
|
||||
"title": "🔗 hoster.com
|
||||
❌ Request failed with status 418 (I'm a tea pot). Request-id: test.",
|
||||
},
|
||||
{
|
||||
"behaviorHints": {
|
||||
"bingeGroup": "webstreamr-hostercom",
|
||||
"notWebReady": true,
|
||||
},
|
||||
"externalUrl": "https://example4.com/",
|
||||
"name": "WebStreamr 🇩🇪",
|
||||
"title": "🔗 working2",
|
||||
"url": "https://working1.com/",
|
||||
"title": "🔗 hoster.com
|
||||
❌ Remote server has issues. We can't fix this, please try later again.",
|
||||
},
|
||||
{
|
||||
"behaviorHints": {
|
||||
"notWebReady": true,
|
||||
},
|
||||
"externalUrl": "https://example3.com/",
|
||||
"name": "WebStreamr 🇩🇪",
|
||||
"title": "🔗 hoster.com
|
||||
⏳ Request queue is full. Please try again later or consider self-hosting.",
|
||||
},
|
||||
{
|
||||
"behaviorHints": {
|
||||
"notWebReady": true,
|
||||
},
|
||||
"externalUrl": "https://example2.com/",
|
||||
"name": "WebStreamr 🇩🇪",
|
||||
"title": "🔗 hoster.com
|
||||
🐢 Request timed out.",
|
||||
},
|
||||
{
|
||||
"behaviorHints": {
|
||||
"notWebReady": true,
|
||||
},
|
||||
"externalUrl": "https://example2.com/",
|
||||
"name": "WebStreamr 🇩🇪",
|
||||
"title": "🔗 hoster.com
|
||||
❌ Request failed. Request-id: test.",
|
||||
},
|
||||
{
|
||||
"behaviorHints": {
|
||||
|
|
@ -53,34 +80,7 @@ exports[`resolve adds error info 2`] = `
|
|||
"externalUrl": "https://example.com/",
|
||||
"name": "WebStreamr 🇩🇪",
|
||||
"title": "🔗 hoster.com
|
||||
⚠️ Request was blocked. Reason: cloudflare_challenge",
|
||||
},
|
||||
{
|
||||
"behaviorHints": {
|
||||
"notWebReady": true,
|
||||
},
|
||||
"externalUrl": "https://example.com/",
|
||||
"name": "WebStreamr 🇩🇪",
|
||||
"title": "🔗 hoster.com
|
||||
⚠️ Request was blocked. Reason: cloudflare_censor",
|
||||
},
|
||||
{
|
||||
"behaviorHints": {
|
||||
"notWebReady": true,
|
||||
},
|
||||
"externalUrl": "https://example.com/",
|
||||
"name": "WebStreamr 🇩🇪",
|
||||
"title": "🔗 hoster.com
|
||||
⚠️ MediaFlow Proxy authentication failed. Please set the correct password.",
|
||||
},
|
||||
{
|
||||
"behaviorHints": {
|
||||
"notWebReady": true,
|
||||
},
|
||||
"externalUrl": "https://example.com/",
|
||||
"name": "WebStreamr 🇩🇪",
|
||||
"title": "🔗 hoster.com
|
||||
⚠️ Request was blocked. Reason: unknown",
|
||||
🚦 Too many recent timeouts. Please try again later.",
|
||||
},
|
||||
{
|
||||
"behaviorHints": {
|
||||
|
|
@ -98,52 +98,52 @@ exports[`resolve adds error info 2`] = `
|
|||
"externalUrl": "https://example.com/",
|
||||
"name": "WebStreamr 🇩🇪",
|
||||
"title": "🔗 hoster.com
|
||||
🚦 Too many recent timeouts. Please try again later.",
|
||||
⚠️ Request was blocked. Reason: unknown",
|
||||
},
|
||||
{
|
||||
"behaviorHints": {
|
||||
"notWebReady": true,
|
||||
},
|
||||
"externalUrl": "https://example2.com/",
|
||||
"externalUrl": "https://example.com/",
|
||||
"name": "WebStreamr 🇩🇪",
|
||||
"title": "🔗 hoster.com
|
||||
❌ Request failed. Request-id: test.",
|
||||
⚠️ MediaFlow Proxy authentication failed. Please set the correct password.",
|
||||
},
|
||||
{
|
||||
"behaviorHints": {
|
||||
"notWebReady": true,
|
||||
},
|
||||
"externalUrl": "https://example2.com/",
|
||||
"externalUrl": "https://example.com/",
|
||||
"name": "WebStreamr 🇩🇪",
|
||||
"title": "🔗 hoster.com
|
||||
🐢 Request timed out.",
|
||||
⚠️ Request was blocked. Reason: cloudflare_censor",
|
||||
},
|
||||
{
|
||||
"behaviorHints": {
|
||||
"notWebReady": true,
|
||||
},
|
||||
"externalUrl": "https://example3.com/",
|
||||
"externalUrl": "https://example.com/",
|
||||
"name": "WebStreamr 🇩🇪",
|
||||
"title": "🔗 hoster.com
|
||||
⏳ Request queue is full. Please try again later or consider self-hosting.",
|
||||
⚠️ Request was blocked. Reason: cloudflare_challenge",
|
||||
},
|
||||
{
|
||||
"behaviorHints": {
|
||||
"bingeGroup": "webstreamr-hostercom",
|
||||
"notWebReady": true,
|
||||
},
|
||||
"externalUrl": "https://example4.com/",
|
||||
"name": "WebStreamr 🇩🇪",
|
||||
"title": "🔗 hoster.com
|
||||
❌ Remote server has issues. We can't fix this, please try later again.",
|
||||
"title": "🔗 working1",
|
||||
"url": "https://working2.com/",
|
||||
},
|
||||
{
|
||||
"behaviorHints": {
|
||||
"bingeGroup": "webstreamr-hostercom",
|
||||
"notWebReady": true,
|
||||
},
|
||||
"externalUrl": "https://example5.com/",
|
||||
"name": "WebStreamr 🇩🇪",
|
||||
"title": "🔗 hoster.com
|
||||
❌ Request failed with status 418 (I'm a tea pot). Request-id: test.",
|
||||
"title": "🔗 working2",
|
||||
"url": "https://working1.com/",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue