osu-api-extended
Version: 
Advanced osu! api wrapper cover all V2 and V1 endpoints, and provide useful tools
97 lines (96 loc) • 2.94 kB
TypeScript
import { IDefaultParams } from "../../types";
import { BeatmapsDownloadResponse } from "../../types/v2/beatmaps_download";
type params = ({
    type: 'difficulty';
    id: number;
    host: 'osu' | 'osu_direct_mirror' | 'catboy';
    file_path: string;
    overwrite?: boolean;
    progress_log_fn?: (host: string, progress: number) => void;
} | {
    type: 'set';
    id: number;
    host: 'osu' | 'beatconnect' | 'nerinyan' | 'osu_direct_mirror' | 'sayobot' | 'gatari' | 'ripple' | 'catboy' | 'mino' | 'akatsuki';
    file_path: string;
    no_video?: boolean;
    overwrite?: boolean;
    progress_log_fn?: (host: string, progress: number) => void;
});
/**
 * `async` Downloads a beatmap or beatmap set by given ID. (Supports different hosts)
 *
 *  
 *
 * ### Available hosts
 * - For `type:'difficulty'`: osu, osu_direct_mirror, catboy
 * - For `type:'set'`: osu, beatconnect, nerinyan, osu_direct_mirror, sayobot, gatari, ripple, catboy
 *
 *  
 *
 * ### Global Parameters
 * - `params.type` - Type of the beatmap.
 * - `params.id` - ID of the beatmap or beatmap set.
 * - `params.host` - Host of the download source.
 * - `params.file_path` - Path to the save location.
 * - `params.overwrite` - Whether to overwrite the file if it already exists.
 *
 *  
 *
 * ### Parameters for `params.type:'set'`
 * - `params.no_video?` - Whether to include video in the download.
 * - `params.progress_log_fn?` - Callback function to send progress.
 *
 *  
 *
 * ### Usage Example
 * ```js
 * const { auth, v2, tools } = require('osu-api-extended');
 *
 * async function main() {
 *   try {
 *     // only for downloading sets from osu host
 *     await auth.login({
 *       type: 'lazer',
 *       login: login,
 *       password: password,
 *       cachedTokenPath: './test.json' // path to the file your auth token will be saved (to prevent osu!api spam)
 *     });
 *
 *
 *     const progress_update = (...args) => {
 *       console.log(args);
 *     };
 *     const set_id = 320118;
 *
 *
 *     const result = await v2.beatmaps.download({
 *       type: 'set',
 *       host: 'gatari',
 *       id: set_id,
 *       file_path: `./cache/${set_id}.osz`,
 *       progress_log_fn: progress_update
 *     });
 *     // or
 *     const result = await tools.download_beatmaps({
 *       type: 'set',
 *       host: 'gatari',
 *       id: set_id,
 *       file_path: `./cache/${set_id}.osz`,
 *       progress_log_fn: progress_update
 *     });
 *
 *     console.log(result);
 *   } catch (error) {
 *     console.log(error);
 *   };
 * };
 *
 * main();
 * ```
 *
 *  
 *
 * [See documentation](https://github.com/cyperdark/osu-api-extended/wiki/v2.beatmaps.download_v3)
 */
export declare const beatmaps_download: <T extends params>(params: T, addons?: IDefaultParams) => Promise<BeatmapsDownloadResponse>;
export {};