diff --git a/assets/js/embed.js b/assets/js/embed.js index 99d2fc53..9d0be0ea 100644 --- a/assets/js/embed.js +++ b/assets/js/embed.js @@ -31,6 +31,11 @@ function get_playlist(plid, retries) { player.on('ended', function () { var url = new URL('https://example.com/embed/' + xhr.response.nextVideo); + url.searchParams.set('list', plid); + if (!plid.startsWith('RD')) { + url.searchParams.set('index', xhr.response.index); + } + if (video_data.params.autoplay || video_data.params.continue_autoplay) { url.searchParams.set('autoplay', '1'); } @@ -47,10 +52,6 @@ function get_playlist(plid, retries) { url.searchParams.set('local', video_data.params.local); } - url.searchParams.set('list', plid); - if (!plid.startsWith('RD')) { - url.searchParams.set('index', xhr.response.index); - } location.assign(url.pathname + url.search); }); } diff --git a/assets/js/watch.js b/assets/js/watch.js index e9ad2ddc..05530f3d 100644 --- a/assets/js/watch.js +++ b/assets/js/watch.js @@ -154,6 +154,11 @@ function get_playlist(plid, retries) { player.on('ended', function () { var url = new URL('https://example.com/watch?v=' + xhr.response.nextVideo); + url.searchParams.set('list', plid); + if (!plid.startsWith('RD')) { + url.searchParams.set('index', xhr.response.index); + } + if (video_data.params.autoplay || video_data.params.continue_autoplay) { url.searchParams.set('autoplay', '1'); } @@ -170,10 +175,6 @@ function get_playlist(plid, retries) { url.searchParams.set('local', video_data.params.local); } - url.searchParams.set('list', plid); - if (!plid.startsWith('RD')) { - url.searchParams.set('index', xhr.response.index); - } location.assign(url.pathname + url.search); }); } diff --git a/src/invidious/routes/watch.cr b/src/invidious/routes/watch.cr index 7018d0a4..9c3ef755 100644 --- a/src/invidious/routes/watch.cr +++ b/src/invidious/routes/watch.cr @@ -28,6 +28,14 @@ class Invidious::Routes::Watch < Invidious::Routes::BaseRoute return env.redirect "/" end + embed_link = "/embed/#{id}" + if env.params.query.size > 1 + embed_params = env.params.query.dup + embed_params.delete_all("v") + embed_link += "?" + embed_link += embed_params.to_s + end + plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "") continuation = process_continuation(PG_DB, env.params.query, plid, id) diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 9a1e6c32..786a88b6 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -88,7 +88,11 @@