mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-18 11:18:28 +00:00
cleanup: move processing into different functions
This commit is contained in:
parent
3e83e1ec36
commit
2de4cd6a30
@ -1,9 +1,7 @@
|
||||
import { genericUserAgent } from "../../config.js";
|
||||
import { cleanString } from "../../sub/utils.js";
|
||||
|
||||
export default async function(obj) {
|
||||
// handle video downloads
|
||||
if (obj.type == 'portal') {
|
||||
async function video(obj) {
|
||||
let req = await fetch(`https://www.newgrounds.com/portal/video/${obj.id}`, {
|
||||
headers: {
|
||||
'User-Agent': genericUserAgent,
|
||||
@ -41,10 +39,9 @@ export default async function(obj) {
|
||||
},
|
||||
fileMetadata,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// handle audio downloads
|
||||
if (obj.type == 'audio') {
|
||||
async function music(obj) {
|
||||
let req = await fetch(`https://www.newgrounds.com/audio/listen/${obj.id}`, {
|
||||
headers: {
|
||||
'User-Agent': genericUserAgent,
|
||||
@ -82,5 +79,17 @@ export default async function(obj) {
|
||||
fileMetadata,
|
||||
isAudioOnly: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default async function(obj) {
|
||||
// handle video downloads
|
||||
if (obj.type == 'portal') {
|
||||
return video(obj);
|
||||
}
|
||||
|
||||
// handle audio downloads
|
||||
if (obj.type == 'audio') {
|
||||
return music(obj);
|
||||
}
|
||||
return { error: 'ErrorUnsupported' };
|
||||
}
|
Loading…
Reference in New Issue
Block a user