From 3daa94dee16d2cd7cc8279b4738262eb51e0665f Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Fri, 10 Jan 2025 16:33:21 -0500 Subject: [PATCH] A couple of fixes --- CHANGELOG.md | 2 + .../Invidious/InvidiousToContentNode.bs | 6 ++ .../PlayletInvidiousBackendRouter.bs | 57 +++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49fca56d..919be2de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Web app tech refresh +- Web app "Open in Invidious" when built-in backend is selected +- Playlist continuation showing invalid items at the end of playlists ## [0.35.5] - 2025-01-09 diff --git a/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs b/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs index 85415233..9f71411f 100644 --- a/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs +++ b/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs @@ -82,6 +82,12 @@ namespace InvidiousContent childCount = node.getChildCount() newNodes = [] for each video in item.videos + ' TODO:P1 sometimes we're parsing "recommended playlists" that + ' show up in the end of the playlist. We should ignore them, + ' until the parsing is fixed. + if ValidString(video.type) = "playlist" + continue for + end if video.type = "video" videoNode = ToVideoContentNode(invalid, video, instance) if videoNode <> invalid diff --git a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs index 976f37b9..2999e457 100644 --- a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs +++ b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs @@ -385,6 +385,8 @@ namespace Http return m.GetPlaylist(context) else if route.StartsWith("/playlet-invidious-backend/api/v1/channels/") return m.GetChannel(context) + else if route.StartsWith("/playlet-invidious-backend/channel") + return m.RedirectChannel(context) end if return false @@ -529,6 +531,61 @@ namespace Http return false end function + + @get("/playlet-invidious-backend/watch") + function RedirectWatch(context as object) as boolean + request = context.request + response = context.response + + videoId = request.query.v + if StringUtils.IsNullOrEmpty(videoId) + response.Json({ + "error": "Missing 'v' query parameter" + }) + response.http_code = 400 + return true + end if + + response.Redirect(`https://redirect.invidious.io/watch?v=${videoId}`) + return true + end function + + @get("/playlet-invidious-backend/playlist") + function RedirectPlaylist(context as object) as boolean + request = context.request + response = context.response + + playlistId = request.query.list + if StringUtils.IsNullOrEmpty(playlistId) + response.Json({ + "error": "Missing 'list' query parameter" + }) + response.http_code = 400 + return true + end if + + response.Redirect(`https://redirect.invidious.io/playlist?list=${playlistId}`) + return true + end function + + function RedirectChannel(context as object) as boolean + request = context.request + response = context.response + route = request.route + + channelId = route.Mid("/playlet-invidious-backend/channel/".Len()) + if StringUtils.IsNullOrEmpty(channelId) + response.Json({ + "error": "Missing 'channelId' path parameter" + }) + response.http_code = 400 + return true + end if + + response.Redirect(`https://redirect.invidious.io/channel/${channelId}`) + return true + end function + end class end namespace