From 91dcd8ec7b32433fc1e4e5335ac72146b0eee682 Mon Sep 17 00:00:00 2001 From: Ashley //// Date: Thu, 1 Feb 2024 10:06:22 +0000 Subject: [PATCH] fix reccomendations --- html/poketube.ejs | 102 +++++++++++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 38 deletions(-) diff --git a/html/poketube.ejs b/html/poketube.ejs index 20a013a..1f99980 100644 --- a/html/poketube.ejs +++ b/html/poketube.ejs @@ -1601,8 +1601,35 @@ Recommended Videos <% if (!f) { %> -<% k.Video.Recommendations?.Video?.forEach(x => { %>
<% if (!optout) { %><%- x.duration || "LIVE"%><% } %><% if (optout) { %><%- x.duration || "LIVE"%><% } %>
<% if (!optout) { %><%= x.Title %><% } %><% if (optout) { %><%= x.Title %><% } %>
<%=x.Channel.Name %>
<% if (universe) { %><%= x.uploadedAt.replace("Streamed ", " ") %>
<%= convert(x.views) %> views <% } %> <% if (!universe) { %><%= x.uploadedAt.replace("Streamed", " ") %> • <%= convert(x.views) %> views <% } %>
<% }) %><% } %> - +<% inv_vid?.recommendedVideos.forEach(x => { %> +
+ <% if (!optout) { %><%- turntomins(x.lengthSeconds) || "LIVE"%><% } %><% if (optout) { %><%- x.duration || "LIVE"%><% } %> +
+ <% if (!optout) { %> + + <%= x.title %> + + <% } %> + <% if (optout) { %> + + <%= x.title %> + + <% } %> +
+ + <%=x.author %> + +
+ + <%= convert(x.viewCount) %> views + +
+
+
+
+ <% }) %> + <% } %> + <% if (f) { %> <% tj.forEach(x => { %> @@ -1703,7 +1730,7 @@ Recommended Videos } - <% if (k.Video.Recommendations.Video) { %> + <% if (inv_vid?.recommendedVideos) { %> let checkbox = document.getElementById("continue"); @@ -1711,10 +1738,10 @@ checkbox.addEventListener('change', function(e) { if (checkbox.checked) { console.log("[AUTOPLAY] enabled"); document.getElementById('video').addEventListener('ended', autoplaynextvideo, false); - let url = window.location.hostname + "/watch?v=<%- k?.Video?.Recommendations?.Video[0]?.id%>"; + let url = window.location.hostname + "/watch?v=<%- inv_vid?.recommendedVideos[0].videoId %>"; function autoplaynextvideo(e) { - location.href = "/watch?v=<%- k.Video.Recommendations.Video[0].id%>&autoplay=<%-btoa("1f739d935676111cfff4b4693e3816e664797050" + k.Video.Recommendations.Video[0].id ) %>"; + location.href = "/watch?v=<%- inv_vid?.recommendedVideos[0].videoId%>&autoplay=<%-btoa("1f739d935676111cfff4b4693e3816e664797050" + inv_vid?.recommendedVideos[0].videoId) %>"; } } if (/[?&]autoplay=/.test(location.search)) { @@ -1725,7 +1752,7 @@ checkbox.addEventListener('change', function(e) { if (/[?&]autoplay=/.test(location.search)) { if (checkbox.checked) { - fetch("https://" + window.location.hostname + "/watch?v=<%- k.Video.Recommendations?.Video[0].id%>").then(() => {}) + fetch("https://" + window.location.hostname + "/watch?v=<%- inv_vid?.recommendedVideos[0].videoId%>").then(() => {}) } } }); @@ -1749,7 +1776,7 @@ checkbox.addEventListener('change', function(e) { if (/[?&]autoplay=/.test(location.search)) { checkbox.checked = true; console.log("[AUTOPLAY] enabled"); - let url = window.location.hostname + "/watch?v=<%- k.Video.Recommendations?.Video[0].id%>"; + let url = window.location.hostname + "/watch?v=<%- inv_vid?.recommendedVideos[0].videoId%>"; document.body.style.cursor = "wait"; // set cursor to "wait" before the fetch request starts fetch(url) .then(response => response.json()) @@ -1764,11 +1791,11 @@ if (/[?&]autoplay=/.test(location.search)) { document.getElementById('video').addEventListener('ended', autoplaynextvideo, false); if (/[?&]autoplay=/.test(location.search)) { if (checkbox.checked) { - fetch("https://" + window.location.hostname + "/watch?v=<%- k.Video.Recommendations?.Video[0].id%>").then(() => {}) + fetch("https://" + window.location.hostname + "/watch?v=<%- inv_vid?.recommendedVideos[0].videoId%>").then(() => {}) } } function autoplaynextvideo(e) { - location.href = "/watch?v=<%- k.Video.Recommendations?.Video[0].id%>&autoplay=<%-btoa("1f739d935676111cfff4b4693e3816e664797050" + k.Video.Recommendations.Video[0].id ) %>"; + location.href = "/watch?v=<%- inv_vid?.recommendedVideos[0].videoId%>&autoplay=<%-btoa("1f739d935676111cfff4b4693e3816e664797050" + inv_vid?.recommendedVideos[0].videoId) %>"; } } <% } %> @@ -2872,33 +2899,32 @@ More Epic options owo~ <% if (!f) { %> - <% k?.Video.Recommendations.Video.forEach(x => { %> -
- <% if (!optout) { %> - - <%=x.duration %> - <% } %> - <% if (optout) { %> - - <%=x.duration %> - <% } %> - -
- - <% if (!optout) { %> - <%= x.Title %> - <% } %> - <% if (optout) { %> - <%= x.Title %> - <% } %> -
- <%=x.Channel.Name %>
- <%= x.uploadedAt %>
-
-
-
- - <% }) %> + <% inv_vid?.recommendedVideos.forEach(x => { %> +
+ <% if (!optout) { %><%- turntomins(x.lengthSeconds) || "LIVE"%><% } %><% if (optout) { %><%- x.duration || "LIVE"%><% } %> +
+ <% if (!optout) { %> + + <%= x.title %> + + <% } %> + <% if (optout) { %> + + <%= x.title %> + + <% } %> +
+ + <%=x.author %> + +
+ + +
+
+
+
+ <% }) %> <% } %> <% if (f) { %> @@ -3044,7 +3070,7 @@ checkbox.addEventListener('change', function(e) { document.getElementById('video').addEventListener('ended',autoplaynextvideo,false); function autoplaynextvideo(e) { - location.href = "/watch?v=<%- k.Video.Recommendations.Video[0].id%>&autoplay=<%-btoa("1f739d935676111cfff4b4693e3816e664797050" + k.Video.Recommendations.Video[0].id ) %>" + location.href = "/watch?v=<%- inv_vid?.recommendedVideos[0].videoId%>&autoplay=<%-btoa("1f739d935676111cfff4b4693e3816e664797050" + inv_vid?.recommendedVideos[0].videoId) %>" } } @@ -3064,7 +3090,7 @@ if (/[?&]autoplay=/.test(location.search)) { document.getElementById('video').addEventListener('ended',autoplaynextvideo,false); function autoplaynextvideo(e) { - location.href = "/watch?v=<%- k.Video.Recommendations.Video[0].id%>&autoplay=<%-btoa("1f739d935676111cfff4b4693e3816e664797050" + k.Video.Recommendations.Video[0].id ) %>" + location.href = "/watch?v=<%- inv_vid?.recommendedVideos[0].videoId%>&autoplay=<%-btoa("1f739d935676111cfff4b4693e3816e664797050" + inv_vid?.recommendedVideos[0].videoId) %>" } } var anchor = document.getElementById("sub");