mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 07:42:23 +02:00
YT: try only once
Avoid triggering 429 ban, by not trying second time
This commit is contained in:
@@ -76,7 +76,9 @@ var YouTubeClient = GObject.registerClass({
|
|||||||
this.initAsyncState = InitAsyncState.DONE;
|
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--) {
|
while(tries--) {
|
||||||
debug(`obtaining YouTube video info: ${videoId}`);
|
debug(`obtaining YouTube video info: ${videoId}`);
|
||||||
this.downloadingVideoId = videoId;
|
this.downloadingVideoId = videoId;
|
||||||
@@ -84,13 +86,10 @@ var YouTubeClient = GObject.registerClass({
|
|||||||
let result = await this._getInfoPromise(videoId).catch(debug);
|
let result = await this._getInfoPromise(videoId).catch(debug);
|
||||||
|
|
||||||
if(!result || !result.data) {
|
if(!result || !result.data) {
|
||||||
if(result && result.isAborted) {
|
if(result && result.isAborted)
|
||||||
debug(new Error('download aborted'));
|
debug(new Error('download aborted'));
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
debug(`failed, remaining tries: ${tries}`);
|
break;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
const info = result.data;
|
const info = result.data;
|
||||||
|
|
||||||
@@ -134,7 +133,7 @@ var YouTubeClient = GObject.registerClass({
|
|||||||
break;
|
break;
|
||||||
else if(!result || !result.data) {
|
else if(!result || !result.data) {
|
||||||
debug(new Error('could not download embed body'));
|
debug(new Error('could not download embed body'));
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ytPath = result.data.match(/(?<=jsUrl\":\").*?(?=\")/gs)[0];
|
const ytPath = result.data.match(/(?<=jsUrl\":\").*?(?=\")/gs)[0];
|
||||||
@@ -163,7 +162,7 @@ var YouTubeClient = GObject.registerClass({
|
|||||||
break;
|
break;
|
||||||
else if(!result || !result.data) {
|
else if(!result || !result.data) {
|
||||||
debug(new Error('could not download player body'));
|
debug(new Error('could not download player body'));
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
actions = YTDL.sig.extractActions(result.data);
|
actions = YTDL.sig.extractActions(result.data);
|
||||||
|
Reference in New Issue
Block a user