mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-18 19:28:29 +00:00
change error type to make more sense
This commit is contained in:
parent
d7b4ee6c06
commit
beff9aaff6
@ -13,7 +13,7 @@ export default async function(obj) {
|
|||||||
.then(request => request.text())
|
.then(request => request.text())
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
|
||||||
if (!req) return { error: 'ErrorEmptyDownload' };
|
if (!req) return { error: 'ErrorCouldntFetch' };
|
||||||
|
|
||||||
let json;
|
let json;
|
||||||
try {
|
try {
|
||||||
@ -22,7 +22,7 @@ export default async function(obj) {
|
|||||||
const highestQuality = Object.keys(json.sources)[0];
|
const highestQuality = Object.keys(json.sources)[0];
|
||||||
const video = json.sources[highestQuality][0].src;
|
const video = json.sources[highestQuality][0].src;
|
||||||
if (!json.sources[highestQuality][0].type.includes('mp4')) {
|
if (!json.sources[highestQuality][0].type.includes('mp4')) {
|
||||||
return { error: 'ErrorEmptyDownload' };
|
return { error: 'ErrorCouldntFetch' };
|
||||||
}
|
}
|
||||||
|
|
||||||
let fileMetadata = {
|
let fileMetadata = {
|
||||||
@ -53,14 +53,14 @@ export default async function(obj) {
|
|||||||
.then(request => request.text())
|
.then(request => request.text())
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
|
||||||
if (!req) return { error: 'ErrorEmptyDownload' };
|
if (!req) return { error: 'ErrorCouldntFetch' };
|
||||||
|
|
||||||
const titleMatch = req.match(/"name"\s*:\s*"([^"]+)"/);
|
const titleMatch = req.match(/"name"\s*:\s*"([^"]+)"/);
|
||||||
const artistMatch = req.match(/"artist"\s*:\s*"([^"]+)"/);
|
const artistMatch = req.match(/"artist"\s*:\s*"([^"]+)"/);
|
||||||
const urlMatch = req.match(/"filename"\s*:\s*"([^"]+)"/);
|
const urlMatch = req.match(/"filename"\s*:\s*"([^"]+)"/);
|
||||||
|
|
||||||
if (!titleMatch || !artistMatch || !urlMatch) {
|
if (!titleMatch || !artistMatch || !urlMatch) {
|
||||||
return { error: 'ErrorEmptyDownload' };
|
return { error: 'ErrorCouldntFetch' };
|
||||||
}
|
}
|
||||||
|
|
||||||
const title = titleMatch[1];
|
const title = titleMatch[1];
|
||||||
|
Loading…
Reference in New Issue
Block a user