From 30c92ce1b73ee07d913c0bd83701614f20992893 Mon Sep 17 00:00:00 2001 From: saltycrys <73420320+saltycrys@users.noreply.github.com> Date: Tue, 8 Dec 2020 02:28:44 +0100 Subject: [PATCH 1/3] Add embed link to watch page --- src/invidious/routes/watch.cr | 8 ++++++++ src/invidious/views/watch.ecr | 3 +++ 2 files changed, 11 insertions(+) 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..fe970c54 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -89,6 +89,9 @@ <%= translate(locale, "Watch on YouTube") %> +

<% if params.annotations %> From 680dc1f962365d20ba0e11362ae3c18d993618ed Mon Sep 17 00:00:00 2001 From: saltycrys <73420320+saltycrys@users.noreply.github.com> Date: Tue, 8 Dec 2020 02:30:48 +0100 Subject: [PATCH 2/3] Shuffle URL params The `list` and `index` params are the most important and come first now. --- assets/js/embed.js | 9 +++++---- assets/js/watch.js | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) 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); }); } From d42539949e9fe76df146c540d9c3c173fb8d61d4 Mon Sep 17 00:00:00 2001 From: saltycrys <73420320+saltycrys@users.noreply.github.com> Date: Tue, 8 Dec 2020 19:10:29 +0100 Subject: [PATCH 3/3] Add YT embed link to watch page --- src/invidious/views/watch.ecr | 1 + 1 file changed, 1 insertion(+) diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index fe970c54..786a88b6 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -88,6 +88,7 @@

<%= translate(locale, "Watch on YouTube") %> + (<%= translate(locale, "Embed") %>)