Spaces:
Sleeping
Sleeping
Update public/script.js
Browse files- public/script.js +13 -18
public/script.js
CHANGED
|
@@ -125,16 +125,13 @@ async function fetchVideoDataById(videoId) {
|
|
| 125 |
return fetchNextValidVideoData(url, 1, 1);
|
| 126 |
}
|
| 127 |
|
| 128 |
-
async function fetchNextValidVideoData(
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
return
|
| 135 |
-
} else {
|
| 136 |
-
return fetchVideoData(shiftIndex(index, direction), direction);
|
| 137 |
-
}
|
| 138 |
}
|
| 139 |
|
| 140 |
function videoIsValid(video) {
|
|
@@ -538,16 +535,14 @@ activityCheck = setInterval(() => {
|
|
| 538 |
}, 250);
|
| 539 |
|
| 540 |
async function getTags() {
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
if (!response.ok) {
|
| 545 |
-
console.error("API Blocked
|
| 546 |
-
return [];
|
| 547 |
}
|
| 548 |
-
|
| 549 |
-
const tags = await response.json();
|
| 550 |
-
return tags;
|
| 551 |
}
|
| 552 |
|
| 553 |
function putTagsInForm(tags) {
|
|
|
|
| 125 |
return fetchNextValidVideoData(url, 1, 1);
|
| 126 |
}
|
| 127 |
|
| 128 |
+
async function fetchNextValidVideoData(tags, page) {
|
| 129 |
+
const baseUrl = `https://www.sakugabooru.com/post.json?limit=1&page=${page}&tags=${tags}`;
|
| 130 |
+
const url = "https://corsproxy.io/?" + encodeURIComponent(baseUrl);
|
| 131 |
+
|
| 132 |
+
const response = await fetch(url);
|
| 133 |
+
if (!response.ok) return null;
|
| 134 |
+
return await response.json();
|
|
|
|
|
|
|
|
|
|
| 135 |
}
|
| 136 |
|
| 137 |
function videoIsValid(video) {
|
|
|
|
| 535 |
}, 250);
|
| 536 |
|
| 537 |
async function getTags() {
|
| 538 |
+
// We use a public cors-anywhere proxy to bypass the block
|
| 539 |
+
const url = "https://corsproxy.io/?https://www.sakugabooru.com/tag.json?limit=1500&order=count";
|
| 540 |
+
const response = await fetch(url);
|
| 541 |
if (!response.ok) {
|
| 542 |
+
console.error("API Blocked even through proxy:", response.status);
|
| 543 |
+
return [];
|
| 544 |
}
|
| 545 |
+
return await response.json();
|
|
|
|
|
|
|
| 546 |
}
|
| 547 |
|
| 548 |
function putTagsInForm(tags) {
|