update dependencies, add shims for node-fetch v3

This commit is contained in:
Michael C
2021-09-20 01:43:19 -04:00
parent 803c3f2a29
commit 1dd534cce9
5 changed files with 126 additions and 126 deletions

View File

@@ -45,7 +45,7 @@ export async function getTotalStats(req: Request, res: Response): Promise<void>
function updateExtensionUsers() {
if (config.userCounterURL) {
fetch(`${config.userCounterURL}/api/v1/userCount`)
.then(res => res.json())
.then(res => res.json() as Record<string, any>)
.then(data => {
apiUsersCache = Math.max(apiUsersCache, data.userCount);
})
@@ -56,7 +56,7 @@ function updateExtensionUsers() {
const chromeExtensionUrl = "https://chrome.google.com/webstore/detail/sponsorblock-for-youtube/mnjggcdmjocbbbhaepdhchncahnbgone";
fetch(mozillaAddonsUrl)
.then(res => res.json())
.then(res => res.json() as Record<string, any>)
.then(data => {
firefoxUsersCache = data.average_daily_users;
fetch(chromeExtensionUrl)

View File

@@ -240,7 +240,7 @@ async function autoModerateSubmission(apiVideoInfo: APIVideoInfo,
&segments=${nbString.substring(0, nbString.length - 1)}`);
if (!response.ok) return false;
const nbPredictions = await response.json();
const nbPredictions = await response.json() as Record<string, any>;
let nbDecision = false;
let predictionIdx = 0; //Keep track because only sponsor categories were submitted
for (let i = 0; i < segments.length; i++) {

View File

@@ -30,17 +30,17 @@ export class YouTubeAPI {
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) {
const data = await result.json() as (Record<string, any>);
if (data.error as Record<string, string>) {
Logger.warn(`NewLeaf API Error for ${videoID}: ${data.error}`);
return { err: data.error, data: null };
}
DiskCache.set(cacheKey, JSON.stringify(data))
const apiResult = data as APIVideoData;
DiskCache.set(cacheKey, JSON.stringify(apiResult))
.catch((err: any) => Logger.warn(err))
.then(() => Logger.debug(`YouTube API: video information cache set for: ${videoID}`));
return { err: false, data };
return { err: false, data: apiResult };
} else {
return { err: result.statusText, data: null };
}