Support multiple newleaf urls

This commit is contained in:
Ajay Ramachandran
2021-06-03 11:38:21 -04:00
parent 1e5849f504
commit ec081cf0c5
7 changed files with 10 additions and 10 deletions

View File

@@ -21,15 +21,15 @@ export class YouTubeAPI {
}
}
if (!config.newLeafURL) return {err: "NewLeaf URL not found", data: null};
if (!config.newLeafURLs || config.newLeafURLs.length <= 0) return {err: "NewLeaf URL not found", data: null};
try {
const result = await fetch(config.newLeafURL + "/api/v1/videos/" + videoID, { method: "GET" });
const result = await fetch(config.newLeafURLs[Math.floor(Math.random() * config.newLeafURLs.length)] + "/api/v1/videos/" + videoID, { method: "GET" });
if (result.ok) {
const data = await result.json();
if (data.error) {
Logger.warn("CloudTube API Error: " + data.error)
Logger.warn("NewLeaf API Error: " + data.error)
return { err: data.error, data: null };
}