From 7ce501f1831090dbaa888726679cde8214f4c01a Mon Sep 17 00:00:00 2001 From: Kelvin K <kelvin@futo.org> Date: Tue, 18 Jun 2024 19:00:25 +0200 Subject: [PATCH] Fallback to legacy playlist if old version --- YoutubeConfig.json | 2 +- YoutubeScript.js | 48 ++++++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/YoutubeConfig.json b/YoutubeConfig.json index 1c85234..96c7199 100644 --- a/YoutubeConfig.json +++ b/YoutubeConfig.json @@ -7,7 +7,7 @@ "sourceUrl": "https://plugins.grayjay.app/Youtube/YoutubeConfig.json", "repositoryUrl": "https://futo.org", "scriptUrl": "./YoutubeScript.js", - "version": 180, + "version": 181, "iconUrl": "./youtube.png", "id": "35ae969a-a7db-11ed-afa1-0242ac120002", diff --git a/YoutubeScript.js b/YoutubeScript.js index 5836ab0..2233cf2 100644 --- a/YoutubeScript.js +++ b/YoutubeScript.js @@ -1206,31 +1206,33 @@ source.getPlaylist = function (url) { }); } - //TODO: Make a proper pager - /* - while (continuationToken) { - const newData = validateContinuation(()=>requestBrowse({ - continuation: continuationToken - }, USE_MOBILE_PAGES, true)); - - if (newData.length < 1) { - break; - } + //Fallback for old apps + if(!bridge.buildVersion || bridge.buildVersion < 244) { + log("Using legacy remote playlist (all videos first page)"); + while (continuationToken) { + const newData = validateContinuation(()=>requestBrowse({ + continuation: continuationToken + }, USE_MOBILE_PAGES, true)); + + if (newData.length < 1) { + break; + } - continuationToken = null; - for(let playlistRenderer of newData) { - switchKey(playlistRenderer, { - playlistVideoRenderer(renderer) { - const video = extractPlaylistVideoRenderer_Video(renderer); - if(video) - videos.push(video); - }, - continuationItemRenderer(continueRenderer) { - continuationToken = continueRenderer?.continuationEndpoint?.continuationCommand?.token; - } - }); + continuationToken = null; + for(let playlistRenderer of newData) { + switchKey(playlistRenderer, { + playlistVideoRenderer(renderer) { + const video = extractPlaylistVideoRenderer_Video(renderer); + if(video) + videos.push(video); + }, + continuationItemRenderer(continueRenderer) { + continuationToken = continueRenderer?.continuationEndpoint?.continuationCommand?.token; + } + }); + } } - }*/ + } let thumbnail = null; if(videos && videos.length > 0 && -- GitLab