Improve error messages on unplayable videos
This commit is contained in:
1 parent
956249393d
commit
8252a102b5
3 files changed
+45
-2
No files matched your search
@@ -210,9 +210,37 @@ namespace InnertubeService
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
if playabilityStatus["status"] <> "OK"
|
if playabilityStatus["status"] <> "OK"
|
||||||
|
errorMessage = ""
|
||||||
|
if IsString(playabilityStatus["reason"])
|
||||||
|
errorMessage = playabilityStatus["reason"]
|
||||||
|
end if
|
||||||
|
|
||||||
|
subreason = ObjectUtils.Dig(playabilityStatus, ["errorScreen", "playerErrorMessageRenderer", "subreason"])
|
||||||
|
if IsAssociativeArray(subreason)
|
||||||
|
subreasonText = ""
|
||||||
|
runs = subreason["runs"]
|
||||||
|
if IsArray(runs)
|
||||||
|
for each rn in runs
|
||||||
|
text = rn["text"]
|
||||||
|
if IsString(text)
|
||||||
|
subreasonText += text
|
||||||
|
end if
|
||||||
|
end for
|
||||||
|
end if
|
||||||
|
subreason = subreasonText
|
||||||
|
end if
|
||||||
|
|
||||||
|
if IsString(subreason)
|
||||||
|
errorMessage += `\n` + subreason
|
||||||
|
end if
|
||||||
|
|
||||||
|
if errorMessage = ""
|
||||||
|
errorMessage = "Video not available"
|
||||||
|
end if
|
||||||
|
|
||||||
return {
|
return {
|
||||||
Success: false
|
Success: false
|
||||||
Error: playabilityStatus["reason"]
|
Error: errorMessage
|
||||||
}
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,20 @@ export class YoutubeJs {
|
|||||||
console.log('[YTJS] info:', info);
|
console.log('[YTJS] info:', info);
|
||||||
|
|
||||||
if (info.playability_status.status !== 'OK') {
|
if (info.playability_status.status !== 'OK') {
|
||||||
throw new Error(`Video not available: ${info.playability_status.reason}`);
|
let errorMessage = "";
|
||||||
|
if (info.playability_status.reason) {
|
||||||
|
errorMessage = info.playability_status.reason;
|
||||||
|
}
|
||||||
|
if (info.playability_status.error_screen) {
|
||||||
|
if (info.playability_status.error_screen.hasKey('subreason')) {
|
||||||
|
const subreason = info.playability_status.error_screen.subreason;
|
||||||
|
if (subreason?.text && typeof subreason.text === 'string') {
|
||||||
|
errorMessage += `\n` + subreason.text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate a video object that is similar to Invidious format.
|
// Populate a video object that is similar to Invidious format.
|
||||||
|
|||||||
@@ -115,6 +115,8 @@
|
|||||||
videoStartAtTimestamp = timestamp;
|
videoStartAtTimestamp = timestamp;
|
||||||
}
|
}
|
||||||
videoModal.show();
|
videoModal.show();
|
||||||
|
} catch (error) {
|
||||||
|
alert(error);
|
||||||
} finally {
|
} finally {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user