Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for bookmarked invalid videos #255

Merged
merged 4 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 21 additions & 3 deletions playlet-lib/src/components/Services/Invidious/InvidiousService.bs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace Invidious

m.endpoints = node.apiDefinitions

m.responseHanlders = {
m.responseHandlers = {
DefaultHandler: m.DefaultHandler
AuthFeedHandler: m.AuthFeedHandler
PlaylistHandler: m.PlaylistHandler
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down