This is a simple tool for downloading osu! beatmaps, beatmapsets and replays. This package provides the following features:
Add a new dependency to your project via npm:
npm install osu-downloader
This project relies on file system operations so it doesn't support browser environment. You need to use Node.js or rewrite it to support browser API by yourself.
import { Downloader, DownloadEntry } from 'osu-downloader'
const downloader = new Downloader({
rootPath: './cache',
/**
* Unlimited downloading.
* This is not safe as it may result to 429 error.
* You can also use fractional values (like 0.1, 0.2)
* if one second is too fast for your application.
*/
filesPerSecond: 0,
});
downloader.addSingleEntry(91);
await downloader.downloadSingle();
import { Downloader } from 'osu-downloader'
const downloader = new Downloader({
rootPath: './cache',
filesPerSecond: 2, // Limit to 2 files per second.
synchronous: true, // Download each file one by one.
});
const entries = [
new DownloadEntry({ id: '91' }),
new DownloadEntry({ id: 1228616 }),
'335628',
1626530,
];
downloader.addMultipleEntries(entries);
await downloader.downloadSingle(); // First file will be downloaded.
await downloader.downloadSingle(); // Second file will be downloaded.
await downloader.downloadAll(); // Rest of the files will be downloaded.
import { Downloader, DownloadEntry, DownloadTypes } from 'osu-downloader'
const downloader = new Downloader({
rootPath: './cache',
filesPerSecond: 2,
});
/**
* Adds a new entry for .osu file to the download query.
*/
downloader.addSingleEntry(new DownloadEntry({
id: '91',
save: false, // Don't save file on a disk.
}));
/**
* Adds a new entry for .osz file to the download query.
*/
downloader.addSingleEntry(new DownloadEntry({
id: 3,
customName: 'myfavouritebeatmapset.osz',
type: DownloadType.Set,
redownload: true,
}));
/**
* Adds multiple entries to the download query.
* You can combine different styles of writing and file types.
*/
downloader.addMultipleEntries([
/* Beatmapset with ID 773801. */
new DownloadEntry({
id: 773801;
type: DownloadType.Set;
}),
/* Non-existent osu! beatmaps will return status code -3 (Failed to download) */
new DownloadEntry({
id: 1337;
}),
/* Already downloaded files will return status code 1 (Already exists). */
new DownloadEntry({
id: 773801;
type: DownloadType.Set;
}),
/* This, however, should return status code 2 (Downloaded) as we have redownload flag. */
new DownloadEntry({
id: 773801;
type: DownloadType.Set;
redownload: true,
}),
/**
* Will download a replay file via custom URL.
* If there is no custom name then file will be named as MD5 hash of URL.
*/
new DownloadEntry({
url: 'https://your-replay-url',
type: DownloadType.Replay,
}),
]);
/**
* Print downloader progress to the console every 100ms.
*/
setInterval(() => {
console.log(downloader.progress);
}, 100);
/**
* Save results of downloading.
*/
const result0 = await downloader.downloadSingle(); // First file will be downloaded.
const result1 = await downloader.downloadSingle(); // Second file will be downloaded.
const results = await downloader.downloadAll(); // Rest of the files will be downloaded.
Auto-generated documentation is available here.
This project is being developed personally by me on pure enthusiasm. If you want to help with development or fix a problem, then feel free to create a new pull request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE for details.