services: clean up functions and improve readability

This commit is contained in:
wukko
2024-05-16 21:28:42 +06:00
parent 9eed3b5b67
commit c6f1184e55
12 changed files with 78 additions and 46 deletions

View File

@@ -29,13 +29,15 @@ export default async function (obj) {
}
}`
})
}).then((r) => { return r.status === 200 ? r.json() : false; }).catch(() => { return false });
}).then(r => r.status === 200 ? r.json() : false).catch(() => {});
if (!req_metadata) return { error: 'ErrorCouldntFetch' };
let clipMetadata = req_metadata.data.clip;
if (clipMetadata.durationSeconds > env.durationLimit) return { error: ['ErrorLengthLimit', env.durationLimit / 60] };
if (!clipMetadata.videoQualities || !clipMetadata.broadcaster) return { error: 'ErrorEmptyDownload' };
if (clipMetadata.durationSeconds > env.durationLimit)
return { error: ['ErrorLengthLimit', env.durationLimit / 60] };
if (!clipMetadata.videoQualities || !clipMetadata.broadcaster)
return { error: 'ErrorEmptyDownload' };
let req_token = await fetch(gqlURL, {
method: "POST",
@@ -54,7 +56,7 @@ export default async function (obj) {
}
}
])
}).then((r) => { return r.status === 200 ? r.json() : false; }).catch(() => { return false });
}).then(r => r.status === 200 ? r.json() : false).catch(() => {});
if (!req_token) return { error: 'ErrorCouldntFetch' };