services: clean up functions and improve readability
This commit is contained in:
@@ -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' };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user