From 04d9b16a6bcab99b0aa25214f0ac16c3605d7602 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sun, 18 Nov 2018 17:28:22 -0600 Subject: [PATCH 1/3] Add fix for optional 'rvs' --- src/invidious/views/watch.ecr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 9dbd8834..16634948 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -152,7 +152,7 @@ <% end %> <% rvs.each do |rv| %> - <% if rv.has_key?("id") %> + <% if rv["id"]? %> "> <% if preferences && preferences.thin_mode %> <% else %> @@ -177,7 +177,7 @@ <% if !rvs.empty? && !plid && params[:continue] %> player.on('ended', function() { window.location.replace("/watch?v=" - + "<%= rvs[0]?.try &.["id"] %>" + + "<%= rvs.select { |rv| rv["id"]? }[0]? %>" + "&continue=1" <% if params[:listen] %> + "&listen=1" @@ -196,7 +196,7 @@ function continue_autoplay(target) { if (target.checked) { player.on('ended', function() { window.location.replace("/watch?v=" - + "<%= rvs[0]?.try &.["id"] %>" + + "<%= rvs.select { |rv| rv["id"]? }[0]? %>" + "&continue=1" <% if params[:listen] %> + "&listen=1" From 3418b82dc5f06062f93520e202399d596b9adcfe Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sun, 18 Nov 2018 17:47:40 -0600 Subject: [PATCH 2/3] Fix typo in autoplay --- src/invidious/views/watch.ecr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 16634948..5326faef 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -177,7 +177,7 @@ <% if !rvs.empty? && !plid && params[:continue] %> player.on('ended', function() { window.location.replace("/watch?v=" - + "<%= rvs.select { |rv| rv["id"]? }[0]? %>" + + "<%= rvs.select { |rv| rv["id"]? }[0]?.try &.["id"] %>" + "&continue=1" <% if params[:listen] %> + "&listen=1" @@ -196,7 +196,7 @@ function continue_autoplay(target) { if (target.checked) { player.on('ended', function() { window.location.replace("/watch?v=" - + "<%= rvs.select { |rv| rv["id"]? }[0]? %>" + + "<%= rvs.select { |rv| rv["id"]? }[0]?.try &.["id"] %>" + "&continue=1" <% if params[:listen] %> + "&listen=1" From 27488a22950ca7e723cef8c273aebbe3ee3ad4ee Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sun, 18 Nov 2018 17:57:31 -0600 Subject: [PATCH 3/3] Fix invalid passing of arguments to get_video --- src/invidious.cr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 69e90fcb..26d1d083 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -268,7 +268,7 @@ get "/watch" do |env| env.params.query.delete_all("listen") begin - video = get_video(id, PG_DB, proxies, params[:region]) + video = get_video(id, PG_DB, proxies, region: params[:region]) rescue ex : VideoRedirect next env.redirect "/watch?v=#{ex.message}" rescue ex @@ -409,7 +409,7 @@ get "/embed/:id" do |env| params = process_video_params(env.params.query, nil) begin - video = get_video(id, PG_DB, proxies, params[:region]) + video = get_video(id, PG_DB, proxies, region: params[:region]) rescue ex : VideoRedirect next env.redirect "/embed/#{ex.message}" rescue ex @@ -1987,7 +1987,7 @@ get "/api/v1/captions/:id" do |env| client = make_client(YT_URL) begin - video = get_video(id, PG_DB, proxies, region) + video = get_video(id, PG_DB, proxies, region: region) rescue ex : VideoRedirect next env.redirect "/api/v1/captions/#{ex.message}" rescue ex @@ -2219,7 +2219,7 @@ get "/api/v1/videos/:id" do |env| region = env.params.query["region"]? begin - video = get_video(id, PG_DB, proxies, region) + video = get_video(id, PG_DB, proxies, region: region) rescue ex : VideoRedirect next env.redirect "/api/v1/videos/#{ex.message}" rescue ex @@ -3105,7 +3105,7 @@ get "/api/manifest/dash/id/:id" do |env| client = make_client(YT_URL) begin - video = get_video(id, PG_DB, proxies, region) + video = get_video(id, PG_DB, proxies, region: region) rescue ex : VideoRedirect next env.redirect "/api/manifest/dash/id/#{ex.message}" rescue ex