diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d7da66c..307a00bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - `HTTP/0.9 when not allowed` errors by adding a retry to web requests +- Issue where a bookmarked video is no longer valid (such as a video made private, or a live stream that ended) ## [0.18.1] - 2024-01-02 diff --git a/playlet-lib/src/components/Services/Invidious/InvidiousService.bs b/playlet-lib/src/components/Services/Invidious/InvidiousService.bs index 04266418..aab29245 100644 --- a/playlet-lib/src/components/Services/Invidious/InvidiousService.bs +++ b/playlet-lib/src/components/Services/Invidious/InvidiousService.bs @@ -44,7 +44,7 @@ namespace Invidious m.endpoints = node.apiDefinitions - m.responseHanlders = { + m.responseHandlers = { DefaultHandler: m.DefaultHandler AuthFeedHandler: m.AuthFeedHandler PlaylistHandler: m.PlaylistHandler @@ -291,7 +291,7 @@ namespace Invidious response = request.Await() - responseHandler = endpoint.responseHandler <> invalid ? m.responseHanlders[endpoint.responseHandler] : m.responseHanlders["DefaultHandler"] + responseHandler = endpoint.responseHandler <> invalid ? m.responseHandlers[endpoint.responseHandler] : m.responseHandlers["DefaultHandler"] result = responseHandler(m, feedSource, response) @@ -351,13 +351,31 @@ namespace Invidious end function function VideoInfoHandler(m as object, feedSource as object, response as object) as object - if response.StatusCode() = 200 + statusCode = response.StatusCode() + if statusCode >= 500 + ' In some cases, such as a video became private, or a live stream ended, + ' Invidious returns a 500 error. We can in this case return a valid response + ' with just a video id, which will allow us to show a valid thumbnail if possible. + ' This is to makes it possible to load a bookmarked video and delete it even if + ' it is no longer valid. + ' TODO:P2 access to private property + response._statusCode = 200 + return { + items: [{ + "videoId": feedSource.pathParams.id + "type": "video" + }] + } + end if + + if statusCode = 200 json = response.Json() json.type = "video" return { items: [json] } end if + return invalid end function