Skip to content

Instantly share code, notes, and snippets.

@creuserr
Created June 1, 2024 05:19
Show Gist options
  • Save creuserr/28f9bdc3da7d5309dbb150d77a6a96e6 to your computer and use it in GitHub Desktop.
Save creuserr/28f9bdc3da7d5309dbb150d77a6a96e6 to your computer and use it in GitHub Desktop.
cloudcre: index.js template
async function getAudio(name, artist) {
// Place your audio API deployment here
const domain = "your-deployment.vercel.app";
// If you want to change the piped instance,
// go to https://github.com/TeamPiped/Piped/wiki/Instances
// and find a domain
const pipe = "ngn.tf";
const f = await fetch(`https://pipedapi.${pipe}/search?q=${encodeURIComponent(`${name} ${artist}`)}&filter=music_songs`);
const res = await f.json();
const id = res.items[0].url.substr(9, res.items[0].url.length);
return `https://${domain}/${id}/${name.trim().replaceAll(" ", "-")}.mp3`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment