mirror of
https://github.com/imputnet/cobalt.git
synced 2025-12-17 13:38:52 +00:00
processing: pass URL object instead of string
This commit is contained in:
@@ -39,17 +39,18 @@ export default async function(obj) {
|
||||
if (!clientId) return { error: 'ErrorSoundCloudNoClientId' };
|
||||
|
||||
let link;
|
||||
if (obj.shortLink && !obj.author && !obj.song) {
|
||||
if (obj.url.hostname === 'on.soundcloud.com' && obj.shortLink) {
|
||||
link = await fetch(`https://on.soundcloud.com/${obj.shortLink}/`, { redirect: "manual" }).then((r) => {
|
||||
if (r.status === 302 && r.headers.get("location").startsWith("https://soundcloud.com/")) {
|
||||
return r.headers.get("location").split('?', 1)[0]
|
||||
}
|
||||
return false
|
||||
}).catch(() => { return false });
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
if (!link && obj.author && obj.song) {
|
||||
link = `https://soundcloud.com/${obj.author}/${obj.song}${obj.accessKey ? `/s-${obj.accessKey}` : ''}`
|
||||
}
|
||||
|
||||
if (!link) return { error: 'ErrorCouldntFetch' };
|
||||
|
||||
let json = await fetch(`https://api-v2.soundcloud.com/resolve?url=${link}&client_id=${clientId}`).then((r) => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import psl from "psl";
|
||||
import { genericUserAgent } from "../../config.js";
|
||||
|
||||
export default async function(obj) {
|
||||
const { subdomain } = psl.parse(obj.url);
|
||||
const { subdomain } = psl.parse(obj.url.hostname);
|
||||
if (subdomain?.includes('.'))
|
||||
return { error: 'ErrorBrokenLink' }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user