mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-18 19:28:29 +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 { genericUserAgent } from "../../config.js";
|
||||||
import { cleanString } from "../../sub/utils.js";
|
import { cleanString } from "../../sub/utils.js";
|
||||||
|
|
||||||
export default async function(obj) {
|
async function video(obj) {
|
||||||
// handle video downloads
|
|
||||||
if (obj.type == 'portal') {
|
|
||||||
let req = await fetch(`https://www.newgrounds.com/portal/video/${obj.id}`, {
|
let req = await fetch(`https://www.newgrounds.com/portal/video/${obj.id}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': genericUserAgent,
|
'User-Agent': genericUserAgent,
|
||||||
@ -41,10 +39,9 @@ export default async function(obj) {
|
|||||||
},
|
},
|
||||||
fileMetadata,
|
fileMetadata,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle audio downloads
|
async function music(obj) {
|
||||||
if (obj.type == 'audio') {
|
|
||||||
let req = await fetch(`https://www.newgrounds.com/audio/listen/${obj.id}`, {
|
let req = await fetch(`https://www.newgrounds.com/audio/listen/${obj.id}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': genericUserAgent,
|
'User-Agent': genericUserAgent,
|
||||||
@ -82,5 +79,17 @@ export default async function(obj) {
|
|||||||
fileMetadata,
|
fileMetadata,
|
||||||
isAudioOnly: true
|
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