Skip to content

mykeels/get-random-music

Repository files navigation

Get Random Music

Downloads a random 15 second music file from https://tones.wolfram.com/generate.

Usage

As a shell script:

npx get-random-music

Or in JavaScript:

const fs = require("fs");
const path = require("path");
const downloadRandomMusic = require("get-random-music");

const outPath = path.join(__dirname, "random-music.mp3");
const outStream = fs.createWriteStream(outPath);
const downloadStream = await downloadRandomMusic().then((res) => res.data);
await new Promise((resolve, reject) => {
  downloadStream.pipe(outStream);
  downloadStream.on("error", (error) => {
    console.error(error);
    downloadStream.close();
    reject();
  });
  downloadStream.on("close", () => {
    console.log("Complete");
    resolve();
  });
});

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published