From d9b35b7fb8b89c69de45988956e117e96546d70c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Tue, 16 Mar 2021 19:45:33 +0100 Subject: [PATCH] YT: try only once Avoid triggering 429 ban, by not trying second time --- src/youtube.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/youtube.js b/src/youtube.js index ef84c17b..5307b02c 100644 --- a/src/youtube.js +++ b/src/youtube.js @@ -76,7 +76,9 @@ var YouTubeClient = GObject.registerClass({ this.initAsyncState = InitAsyncState.DONE; } - let tries = 2; + /* Too many tries might trigger 429 ban, + * leave while with break as a "goto" replacement */ + let tries = 1; while(tries--) { debug(`obtaining YouTube video info: ${videoId}`); this.downloadingVideoId = videoId; @@ -84,13 +86,10 @@ var YouTubeClient = GObject.registerClass({ let result = await this._getInfoPromise(videoId).catch(debug); if(!result || !result.data) { - if(result && result.isAborted) { + if(result && result.isAborted) debug(new Error('download aborted')); - break; - } - debug(`failed, remaining tries: ${tries}`); - continue; + break; } const info = result.data; @@ -134,7 +133,7 @@ var YouTubeClient = GObject.registerClass({ break; else if(!result || !result.data) { debug(new Error('could not download embed body')); - continue; + break; } const ytPath = result.data.match(/(?<=jsUrl\":\").*?(?=\")/gs)[0]; @@ -163,7 +162,7 @@ var YouTubeClient = GObject.registerClass({ break; else if(!result || !result.data) { debug(new Error('could not download player body')); - continue; + break; } actions = YTDL.sig.extractActions(result.data);