Gracefully handle missing playlists in Playlet backend (#670)
* Gracefully handle missing playlists in Playlet backend * Changelog
This commit is contained in:
1 parent
45a85f92b3
commit
19f304bd3e
2 files changed
+42
-39
No files matched your search
+3
-1
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
- Nothing worth mentioning yet.
|
### Fixed
|
||||||
|
|
||||||
|
- A bug preventing the removal of bookmarked private playlists
|
||||||
|
|
||||||
## [0.40.8] - 2025-06-22
|
## [0.40.8] - 2025-06-22
|
||||||
|
|
||||||
|
|||||||
@@ -417,23 +417,27 @@ namespace Invidious
|
|||||||
function DefaultHandler(context as object) as object
|
function DefaultHandler(context as object) as object
|
||||||
response = context.response
|
response = context.response
|
||||||
|
|
||||||
if response.StatusCode() = 200
|
if not response.IsSuccess()
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
json = response.Json()
|
json = response.Json()
|
||||||
|
if json = invalid
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
if IsArray(json)
|
if IsArray(json)
|
||||||
json = {
|
json = {
|
||||||
items: json
|
items: json
|
||||||
}
|
}
|
||||||
end if
|
end if
|
||||||
return json
|
return json
|
||||||
end if
|
|
||||||
return invalid
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function PlaylistHandler(context as object) as object
|
function PlaylistHandler(context as object) as object
|
||||||
response = context.response
|
response = context.response
|
||||||
|
|
||||||
statusCode = response.StatusCode()
|
if not response.IsSuccess()
|
||||||
if statusCode = 404
|
|
||||||
' Similar to VideoInfoHandler, we can return a valid response
|
' Similar to VideoInfoHandler, we can return a valid response
|
||||||
' in case of a deleted playlist.
|
' in case of a deleted playlist.
|
||||||
response.OverrideStatusCode(200)
|
response.OverrideStatusCode(200)
|
||||||
@@ -447,8 +451,11 @@ namespace Invidious
|
|||||||
}
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if statusCode = 200
|
|
||||||
json = response.Json()
|
json = response.Json()
|
||||||
|
if json = invalid
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
items: json.videos
|
items: json.videos
|
||||||
}
|
}
|
||||||
@@ -456,15 +463,12 @@ namespace Invidious
|
|||||||
result.continuation = json.continuation
|
result.continuation = json.continuation
|
||||||
end if
|
end if
|
||||||
return result
|
return result
|
||||||
end if
|
|
||||||
return invalid
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function ChannelVideosHandler(context as object) as object
|
function ChannelVideosHandler(context as object) as object
|
||||||
response = context.response
|
response = context.response
|
||||||
|
|
||||||
statusCode = response.StatusCode()
|
if not response.IsSuccess()
|
||||||
if statusCode = 404 or statusCode = 500
|
|
||||||
' Similar to VideoInfoHandler, we can return a valid response
|
' Similar to VideoInfoHandler, we can return a valid response
|
||||||
' in case of a deleted channel.
|
' in case of a deleted channel.
|
||||||
response.OverrideStatusCode(200)
|
response.OverrideStatusCode(200)
|
||||||
@@ -478,26 +482,26 @@ namespace Invidious
|
|||||||
}
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if response.StatusCode() = 200
|
|
||||||
json = response.Json()
|
json = response.Json()
|
||||||
|
if json = invalid
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
return {
|
return {
|
||||||
items: json.videos
|
items: json.videos
|
||||||
continuation: json.continuation
|
continuation: json.continuation
|
||||||
sortOptions: json.sortOptions
|
sortOptions: json.sortOptions
|
||||||
}
|
}
|
||||||
end if
|
|
||||||
return invalid
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function ChannelPlaylistsHandler(context as object) as object
|
function ChannelPlaylistsHandler(context as object) as object
|
||||||
response = context.response
|
response = context.response
|
||||||
|
|
||||||
if response.StatusCode() = 200
|
if not response.IsSuccess()
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
json = response.Json()
|
json = response.Json()
|
||||||
' Courses are not yet implemented in Invidious.
|
|
||||||
' In this case, Invidious returns 200, but the response is empty.
|
|
||||||
' https://github.com/iv-org/invidious/issues/5088
|
|
||||||
' https://github.com/iv-org/invidious/issues/5144
|
|
||||||
if json = invalid
|
if json = invalid
|
||||||
json = {
|
json = {
|
||||||
playlists: []
|
playlists: []
|
||||||
@@ -509,15 +513,12 @@ namespace Invidious
|
|||||||
continuation: json.continuation
|
continuation: json.continuation
|
||||||
sortOptions: json.sortOptions
|
sortOptions: json.sortOptions
|
||||||
}
|
}
|
||||||
end if
|
|
||||||
return invalid
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function VideoInfoHandler(context as object) as object
|
function VideoInfoHandler(context as object) as object
|
||||||
response = context.response
|
response = context.response
|
||||||
|
|
||||||
statusCode = response.StatusCode()
|
if not response.IsSuccess()
|
||||||
if statusCode >= 500 or statusCode = 404
|
|
||||||
' In some cases, such as a video became private, or a live stream ended,
|
' 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
|
' 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.
|
' with just a video id, which will allow us to show a valid thumbnail if possible.
|
||||||
@@ -533,22 +534,21 @@ namespace Invidious
|
|||||||
}
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if statusCode = 200
|
|
||||||
json = response.Json()
|
json = response.Json()
|
||||||
|
if json = invalid
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
json.type = "video"
|
json.type = "video"
|
||||||
return {
|
return {
|
||||||
items: [json]
|
items: [json]
|
||||||
}
|
}
|
||||||
end if
|
|
||||||
|
|
||||||
return invalid
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function PlaylistInfoHandler(context as object) as object
|
function PlaylistInfoHandler(context as object) as object
|
||||||
response = context.response
|
response = context.response
|
||||||
|
|
||||||
statusCode = response.StatusCode()
|
if not response.IsSuccess()
|
||||||
if statusCode = 404
|
|
||||||
' Similar to VideoInfoHandler, we can return a valid response
|
' Similar to VideoInfoHandler, we can return a valid response
|
||||||
' in case of a deleted playlist.
|
' in case of a deleted playlist.
|
||||||
response.OverrideStatusCode(200)
|
response.OverrideStatusCode(200)
|
||||||
@@ -561,21 +561,21 @@ namespace Invidious
|
|||||||
}
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if statusCode = 200
|
|
||||||
json = response.Json()
|
json = response.Json()
|
||||||
|
if json = invalid
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
json.type = "playlist"
|
json.type = "playlist"
|
||||||
return {
|
return {
|
||||||
items: [json]
|
items: [json]
|
||||||
}
|
}
|
||||||
end if
|
|
||||||
return invalid
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function ChannelInfoHandler(context as object) as object
|
function ChannelInfoHandler(context as object) as object
|
||||||
response = context.response
|
response = context.response
|
||||||
|
|
||||||
statusCode = response.StatusCode()
|
if not response.IsSuccess()
|
||||||
if statusCode = 404 or statusCode = 500
|
|
||||||
' Similar to VideoInfoHandler, we can return a valid response
|
' Similar to VideoInfoHandler, we can return a valid response
|
||||||
' in case of a deleted channel.
|
' in case of a deleted channel.
|
||||||
response.OverrideStatusCode(200)
|
response.OverrideStatusCode(200)
|
||||||
@@ -588,14 +588,15 @@ namespace Invidious
|
|||||||
}
|
}
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if statusCode = 200
|
|
||||||
json = response.Json()
|
json = response.Json()
|
||||||
|
if json = invalid
|
||||||
|
return invalid
|
||||||
|
end if
|
||||||
|
|
||||||
json.type = "channel"
|
json.type = "channel"
|
||||||
return {
|
return {
|
||||||
items: [json]
|
items: [json]
|
||||||
}
|
}
|
||||||
end if
|
|
||||||
return invalid
|
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function AuthFeedHandler(context as object) as object
|
function AuthFeedHandler(context as object) as object
|
||||||
@@ -604,7 +605,7 @@ namespace Invidious
|
|||||||
|
|
||||||
m.DeleteExpiredToken(response, authToken)
|
m.DeleteExpiredToken(response, authToken)
|
||||||
|
|
||||||
if response.StatusCode() <> 200
|
if not response.IsSuccess()
|
||||||
return invalid
|
return invalid
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@@ -640,7 +641,7 @@ namespace Invidious
|
|||||||
|
|
||||||
m.DeleteExpiredToken(response, authToken)
|
m.DeleteExpiredToken(response, authToken)
|
||||||
|
|
||||||
if response.StatusCode() <> 200
|
if not response.IsSuccess()
|
||||||
return invalid
|
return invalid
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user