Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/misa198/scdl-core-js
Module for SoundCloud to download and get info tracks and playlists. Support Typescript and Javascript.
https://github.com/misa198/scdl-core-js
nodejs scdl soundcloud soundcloud-api soundcloud-downloader typescript
Last synced: 5 days ago
JSON representation
Module for SoundCloud to download and get info tracks and playlists. Support Typescript and Javascript.
- Host: GitHub
- URL: https://github.com/misa198/scdl-core-js
- Owner: misa198
- License: mit
- Created: 2021-05-22T10:38:00.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-28T08:38:04.000Z (over 2 years ago)
- Last Synced: 2024-10-29T22:30:52.880Z (7 days ago)
- Topics: nodejs, scdl, soundcloud, soundcloud-api, soundcloud-downloader, typescript
- Language: TypeScript
- Homepage: https://misa198.github.io/scdl-core-js/
- Size: 4.42 MB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# scdl-core
- Module for SoundCloud to download and get info tracks and playlists.
- Support Typescript and Javascript.![](https://img.shields.io/badge/Author-misa198-green)
![](https://camo.githubusercontent.com/832d01092b0e822178475741271b049a2e27df13/68747470733a2f2f62616467656e2e6e65742f62616467652f2d2f547970655363726970742f626c75653f69636f6e3d74797065736372697074266c6162656c)
[![](https://img.shields.io/npm/dt/scdl-core)](https://www.npmjs.com/package/scdl-core)# Usage
```js
const fs = require("fs");
const { SoundCloud } = require("scdl-core");await SoundCloud.connect();
const stream = await SoundCloud.download(
"https://soundcloud.com/martingarrix/martin-garrix-feat-bonn-no-sleep"
);
stream.pipe(fs.createWriteStream("song.mp3"));
```# API
## connect
```js
// Used to get the SoundCloud client_id. Call 1 time at the top of your app.
const { SoundCloud } = require("scdl-core");
await SoundCloud.connect();
await SoundCloud.download(
"https://soundcloud.com/martingarrix/martin-garrix-feat-bonn-no-sleep"
);
stream.pipe(fs.createWriteStream("song.mp3"));
```## search
```js
const result = await SoundCloud.search({
query: string,
limit?: number, // Default: 20
offset?: number, // Default: 0
filter?: 'all' | 'albums' | 'playlists' | 'users' | 'tracks' // Default: "all"
});
```## tracks
#### getTrackByIds
```js
const ids = [578933490, 499766382];
const tracks = await SoundCloud.tracks.getTracksByIds(ids);
```#### getTrack
```js
const permalink =
"https://soundcloud.com/martingarrix/martin-garrix-feat-bonn-no-sleep";
const track = await SoundCloud.tracks.getTrack(permalink);
```#### getTrending
```js
const trendingTracks = await SoundCloud.tracks.getTrending({
limit?: number, // Default: 20
offset?: number // Default: 0
});
```## playlists/albums
#### getPlaylist/getAlbum
```js
const permalink =
"https://soundcloud.com/martingarrix/sets/martin-garrix-matisse-sadko";
const playlist = await SoundCloud.playlists.getPlaylist(permalink);
```## users
#### getUser
```js
const permalink = "https://soundcloud.com/martingarrix";
const user = await SoundCloud.users.getUser(permalink);
```## download
```js
const permalink =
"https://soundcloud.com/martingarrix/martin-garrix-feat-bonn-no-sleep";
const stream = await SoundCloud.download(permalink);
stream.pipe(fs.createWriteStream("song.mp3"));// For streaming, you can customize the `highWaterMark` value to reduce lag if the internet is not good.
// Example:
const stream = await SoundCloud.download(permalink, {
highWaterMark: 1 << 25, // 32Mb, default is 16kb
});
```#### Use with Discord.js
```javascript
// Discord.js v12
const voiceChannel = message.member.voiceChannel;
voiceChannel
.join()
.then((connection) => {
SoundCloud.download(trackPermalink).then((stream) => {
connection.play(stream);
});
})
.catch((err) => console.log(err));
``````javascript
// Discord.js v13
const audioPlayer = createAudioPlayer();
const voiceConnection = joinVoiceChannel({
channelId,
guildId,
adapterCreator,
});
voiceConnection.subscribe(audioPlayer);
const stream = await SoundCloud.download(SONG_URL);
const audioResource = createAudioResource(stream);
audioPlayer.play(audioResource);
```# Install
```bash
npm install scdl-core --save
```Or for Yarn users:
```bash
yarn add scdl-core
```## License
[MIT](https://choosealicense.com/licenses/mit/)