Code Monkey home page Code Monkey logo

node-soundcloud-downloader's Introduction

node-soundcloud-downloader

Zack Radisic downloads Node.js CI

Download Soundcloud tracks with Node.js

npm install soundcloud-downloader

I couldn't find any packages that worked with a Discord bot I was working on so I created my own.

Features

  • Extremely fast (interacts directly with the Soundcloud API)
  • Download/manipulate audio from Soundcloud (it is returned as a stream)
  • Get information about tracks and playlists
  • Filter and download specific formats
  • Search and find related tracks/playlists/albums/users

Table of Contents

Here are the two most commonly used functions:

  • Returns a JSON object containing the track's information, as well as media links.

Read the docs for more.

Examples

The easiest way to get Soundcloud audio is with the scdl.download(url: string) function, which returns a Promise containing a ReadableStream.

const scdl = require('soundcloud-downloader').default
const fs = require('fs')

const SOUNDCLOUD_URL = 'https://soundcloud.com/askdjfhaklshf'
const CLIENT_ID = 'asdhkalshdkhsf'

scdl.download(SOUNDCLOUD_URL).then(stream => stream.pipe(fs.createWriteStream('audio.mp3')))

You can do anything you like with the stream that is returned, an example with Discord.js:

const client = new Discord.Client()
const url = 'https://soundcloud.com/taliya-jenkins/double-cheese-burger-hold-the'
const clientID = 'asdlkajasd'
const channelID = '123456789'
client.on('ready', () => {
  const channel = client.channels.cache.get(channelID)
  channel.join().then(connection => {
    scdl.download(url, clientID).then(stream => {
      connection.play(stream)
    })
  })
})

You can also create a custom instance of the SCDL class with settings configured to your liking:

const scdlCreate = require('../').create
const axios = require('axios').default

const scdl = scdlCreate({
  clientID: 'adasdasd',
  saveClientID: true,
  filePath: './client_id.json',
  axiosInstance: axios.create()
})

You can view the code for these examples and find more in the example folder.

Client ID

You can obtain a Client ID by visting the Soundcloud website and inspecting network traffic (perhaps with Chrome DevTools or some HTTP proxy software) and looking for any requests to the Soundcloud API. Ex:

https://api-v2.soundcloud.com/me/play-history/tracks?client_id={CLIENT ID IS HERE}&limit=25&offset=0&linked_partitioning=1&app_version=1590494738&app_locale=en

Here is a picture of where you should be able to find it:

To-do

If I have the time and there is enough demand, I am interested in implementing the following functionalities:

  • Audio format selection ✅
  • Ability to use HTTP Live Streaming (HLS) ✅
  • Some more integrations with Discord.js like selecting best format for voice channels

If you have any feature requests, suggestions or questions do not hesistate to post them in the issues section

Disclaimer

I do not support piracy and this package is not designed for circumventing the technological measures employed by SoundCloud preventing unauthorized access to copyrighted works. This package is only for downloading audio you have access to.

node-soundcloud-downloader's People

Contributors

asgarrrr avatar cryogenicplanet avatar dependabot[bot] avatar smaznet avatar zackradisic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

node-soundcloud-downloader's Issues

scdl.getSetInfo(url) returns all tracks in a playlist but only the first few tracks has info.

Thank you for making this repo, and streaming soundcloud music possible. I've encounter the following problem when using it.

Here is a picture of the console.log() prints out after calling await scdl.getSetInfo(url). This happens on any playlist url, https://soundcloud.com/user-845046062/sets/playlist for example.

When I go to the playlist link and copy the track url that doesn't have the info printed and use `scdl.getInfo(url), it shows all the track info normally.

Any clues? Could it be that I'm not providing a ClienID?
Thank you so much!

getSetInfo() artwork_url always null

Apparently each time doing scdl.getSetInfo() will always get this:

{
    artwork_url: null,
    created_at: '2022-11-03T01:10:39Z',
    description: null,
    duration: 379115,
    embeddable_by: 'all',
    genre: '',
    id: 1521503137,
    kind: 'playlist',
    label_name: null,
    last_modified: '2022-11-03T01:10:39Z',
    license: 'all-rights-reserved',
    likes_count: 7,
    managed_by_feeds: false,
    permalink: 'natasha-bedingfield-unwritten',
    permalink_url: 'https://soundcloud.com/matthibbertmusic/sets/natasha-bedingfield-unwritten',
    public: true,
    purchase_title: null,
    purchase_url: null,
    release_date: null,
    reposts_count: 0,
    secret_token: null,
    sharing: 'public',
    tag_list: '',
    title: 'Natasha Bedingfield - Unwritten (Matt Hibbert Edit) (Filtered for SC, full vocal in DL)',
    ...
}

everything else is fine except for artwork_url, why is that??? it's very annoying to always get null for this when clearly playlists like this one has an artwork_url

Error ToLowerCase lasted version

C:\Users\33647\Desktop\News\node_modules\soundcloud-downloader\dist\index.js:92
this.saveClientID = process.env.SAVE_CLIENT_ID.toLowerCase() === 'true';
^

TypeError: Cannot read property 'toLowerCase' of undefined
at new SCDL (C:\Users\33647\Desktop\News\node_modules\soundcloud-downloader\dist\index.js:92:56)
at Object. (C:\Users\33647\Desktop\News\node_modules\soundcloud-downloader\dist\index.js:369:12)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object. (C:\Users\33647\Desktop\News\node_modules\soundcloud-downloader\index.js:1:14)
at Module._compile (internal/modules/cjs/loader.js:776:30)
[nodemon] app crashed - waiting for file changes before starting...

Error 404 on all links with opus format

Hey, i started using your module in my bot after your pull request which was version 0.0.9 of your project, currently that version is working fine but after trying to update to 0.1.2 and refactor for the new changes i get error 404 on all links from the download method

I tested with this example

const scdl = require("soundcloud-downloader");
let url = "https://soundcloud.com/marcelonunes-2/pearl-jam-yellow-led-better";

const info = await scdl.getInfo(url, SOUNDCLOUD_CLIENT_ID);
const opus = scdl.filterMedia(info.media.transcodings, { format: scdl.FORMATS.OPUS });
stream = await scdl.download(opus[0].url, SOUNDCLOUD_CLIENT_ID);

I tried different songs and all are rejecting with error 404

Environment:

  • Node.js v12.16.1
  • MacOS 10.15.5
  • "soundcloud-downloader": "^0.1.2"

Get a user's likes

It would be convenient to be able to retrieve information on the tracks a user has liked. The API endpoint looks like this:

https://api-v2.soundcloud.com/users/<user_ID>/likes?client_id=<client_id>&limit=10&offset=0

A user's ID can be retrieved using the link to their profile with the resolve endpoint, so I'm thinking this feature could be implemented like so:

const profileURL = 'https://soundcloud.com/<username>'
let likes = await getLikes(profileURL) // Gets the user's id for you, then calls the likes endpoint

// Or with user ID
likes = await getLikes(123123123123)

downloadPlaylist error

When using the downloadPlaylist function, I get an error: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'url' of undefined

Can't check playlist of FirebaseURL

When I do:

scdl.isPlaylistURL("https://soundcloud.app.goo.gl/k6d2hrY5XJsPncZ26")

It will return false although that link is belong to a Soundcloud playlist.

Rejected promise

Hi,

Thanks for this repo, however I can't manage to download any track due to a rejected promise.
I followed the steps (providing a CLIENT_ID from soundcloud from the Chrome DevTools Network's tab), trying both with and without CLIENT_ID, similarly resulting in the following undhandled promise rejection:

(node:20171) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'transcodings' of undefined at /Users/davidthery/Desktop/node_modules/soundcloud-downloader/dist/index.js:58:73 at step (/Users/davidthery/Desktop/node_modules/soundcloud-downloader/dist/index.js:33:23) at Object.next (/Users/davidthery/Desktop/node_modules/soundcloud-downloader/dist/index.js:14:53) at fulfilled (/Users/davidthery/Desktop/node_modules/soundcloud-downloader/dist/index.js:5:58) at processTicksAndRejections (internal/process/task_queues.js:93:5) (Usenode --trace-warnings ...to show where the warning was created) (node:20171) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:20171) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I'm using Node v14.6.0.

If you have any clue?
Thanks,
David

hi can u help me please

i think soundcloud changed the api and we cant get it in dev tools anymore
can you guys help me another way to get that api code pls

TypeError: Cannot read property 'toLowerCase' of undefined

I got this error when i try to run my discord music bot today, it worked just find just then. I dont know why.
Here is the full error:

/home/watchandytw/Cute_Lemon's BOT :D/Music BOT/node_modules/soundcloud-downloader/dist/index.js:92
        this.saveClientID = process.env.SAVE_CLIENT_ID.toLowerCase() === 'true';
                                                       ^

TypeError: Cannot read property 'toLowerCase' of undefined
    at new SCDL (/home/watchandytw/Cute_Lemon's BOT :D/Music BOT/node_modules/soundcloud-downloader/dist/index.js:92:56)
    at Object.<anonymous> (/home/watchandytw/Cute_Lemon's BOT :D/Music BOT/node_modules/soundcloud-downloader/dist/index.js:369:12)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32)
    at Function.Module._load (node:internal/modules/cjs/loader:807:14)
    at Module.require (node:internal/modules/cjs/loader:991:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/home/watchandytw/Cute_Lemon's BOT :D/Music BOT/node_modules/soundcloud-downloader/index.js:1:14)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)

Bug: search() - Request to next_href link fails with 404 error

When you use the search method, the response is a paginated query with the field "next_href". The collection of tracks field is an array that is limited to 10 values.
So trying to visit "next_href" link to get the remaining collection of tracks results in an error.

Error when build

I get this error when I build.
When i run with ts-node everything is fine.

Screen Shot 2021-05-21 at 22 52 42

"node": "^14.15.4",
"soundcloud-downloader": "^1.0.0",
"typescript": "^4.2.4"
// tsconfig.json
{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es6",
    "noImplicitAny": true,
    "moduleResolution": "node",
    "sourceMap": false,
    "outDir": "dist",
    "baseUrl": ".",
    "paths": {
      "*": [
        "node_modules/*"
      ]
    },
  },
  "include": [
    "src/**/*"
  ]
}

Can't build project - Typescript problem

I added this library in my discord-bot typescript project, but i'm getting so many errors when I'm trying to build it.

Do you know something about it? I think that's some problems with types, but I don't know how to solve it

image

"Error: Request failed with status code 400" with some playlists using getSetInfo()

Hi all - I'm getting a http 400/Bad Request error when using getSetInfo() for some playlists (e.g. https://soundcloud.com/ilyanaazman/sets/best-of-mrrevillz or https://soundcloud.com/ilyanaazman/sets/bestofchillnation) while most others are perfectly fine (e.g. https://soundcloud.com/ilyanaazman/sets/latenightlofi).

Console output below with masked out client_id:

Error: Request failed with status code 400      at createError (/workspace/node_modules/axios/lib/core/createError.js:16:15)      at settle (/workspace/node_modules/axios/lib/core/settle.js:17:12)      at IncomingMessage.handleStreamEnd (/workspace/node_modules/axios/lib/adapters/http.js:244:11)      at IncomingMessage.emit (events.js:327:22)      at endReadableNT (_stream_readable.js:1220:12)      at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  config: {
    url: 'https://api-v2.soundcloud.com/tracks?ids=867665638%2C916488845%2C916541744%2C879502579%2C911544727%2C920224540%2C920227672%2C912258409%2C182859485%2C879588352%2C871408492%2C903271243%2C899338447%2C907746022%2C906903244%2C851514058%2C907746013%2C899541523%2C871778755%2C845983675%2C727730749%2C310455689%2C351996389%2C221308049%2C617744415%2C222335592%2C220021334%2C625572180%2C586430472%2C136515969%2C350544130%2C292528042%2C672835793%2C233271745%2C634818096%2C345014116%2C194674830%2C613079007%2C219240973%2C250830766%2C157946069%2C242071122%2C220940419%2C356904608%2C447921720%2C325876880%2C303520330%2C577977645%2C258583921%2C329292478%2C302734389%2C288394390%2C304744944%2C213828110%2C158384606%2C322256287%2C654816296%2C321085206%2C180526491%2C151836932%2C240510101%2C259932466%2C340422811%2C120417156%2C308158931%2C242970980%2C265004302%2C225515495%2C94470145%2C147235179%2C193641840%2C192956375%2C243086787%2C418406040%2C319849669%2C361549280%2C348894700%2C357040427%2C482437833%2C252638815%2C465024060%2C465229422%2C450607776%2C329511908%2C493285392%2C489363333%2C502948368%2C509000139%2C411189549%2C290210997%2C519271257%2C519206883%2C604903338%2C578505426%2C560864886%2C556088364%2C546188349%2C516324954%2C145367831%2C323733248%2C135322127%2C353880398%2C396944928%2C296968053%2C494976372%2C215558123%2C190445096%2C192408098%2C242672575%2C204778816%2C319887152%2C403960782%2C194510401%2C214816945%2C383884892%2C341315415%2C172595409%2C210014181%2C519749160%2C226139958%2C483679920%2C84118776%2C473381727%2C214140973%2C489177243%2C266963313%2C285262888%2C272020529&client_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    method: 'get',
    headers: {
      Accept: 'application/json, text/plain, */*',
      'User-Agent': 'axios/0.20.0'
    },
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    adapter: [Function: httpAdapter],
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    validateStatus: [Function: validateStatus],
    data: undefined
  },
  request: ClientRequest {
    _events: [Object: null prototype] {
      socket: [Function],
      abort: [Function],
      aborted: [Function],
      connect: [Function],
      error: [Function],
      timeout: [Function],
      prefinish: [Function: requestOnPrefinish]
    },
    _eventsCount: 7,
    _maxListeners: undefined,
    outputData: [],
    outputSize: 0,
    writable: true,
    _last: true,
    chunkedEncoding: false,
    shouldKeepAlive: false,
    useChunkedEncodingByDefault: false,
    sendDate: false,
    _removedConnection: false,
    _removedContLen: false,
    _removedTE: false,
    _contentLength: 0,
    _hasBody: true,
    _trailer: '',
    finished: true,
    _headerSent: true,
    socket: TLSSocket {
      _tlsOptions: [Object],
      _secureEstablished: true,
      _securePending: false,
      _newSessionPending: false,
      _controlReleased: true,
      secureConnecting: true,
      _SNICallback: null,
      servername: 'api-v2.soundcloud.com',
      alpnProtocol: false,
      authorized: true,
      authorizationError: null,
      encrypted: true,
      _events: [Object: null prototype],
      _eventsCount: 10,
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: 'api-v2.soundcloud.com',
      _readableState: [ReadableState],
      readable: true,
      _maxListeners: undefined,
      _writableState: [WritableState],
      writable: false,
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: undefined,
      _server: null,
      ssl: [TLSWrap],
      _requestCert: true,
      _rejectUnauthorized: true,
      parser: null,
      _httpMessage: [Circular],
      [Symbol(res)]: [TLSWrap],
      [Symbol(verified)]: true,
      [Symbol(pendingSession)]: null,
      [Symbol(asyncId)]: 210925,
      [Symbol(kHandle)]: [TLSWrap],
      [Symbol(kSetNoDelay)]: false,
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(connect-options)]: [Object]
    },
    connection: TLSSocket {
      _tlsOptions: [Object],
      _secureEstablished: true,
      _securePending: false,
      _newSessionPending: false,
      _controlReleased: true,
      secureConnecting: true,
      _SNICallback: null,
      servername: 'api-v2.soundcloud.com',
      alpnProtocol: false,
      authorized: true,
      authorizationError: null,
      encrypted: true,
      _events: [Object: null prototype],
      _eventsCount: 10,
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: 'api-v2.soundcloud.com',
      _readableState: [ReadableState],
      readable: true,
      _maxListeners: undefined,
      _writableState: [WritableState],
      writable: false,
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: undefined,
      _server: null,
      ssl: [TLSWrap],
      _requestCert: true,
      _rejectUnauthorized: true,
      parser: null,
      _httpMessage: [Circular],
      [Symbol(res)]: [TLSWrap],
      [Symbol(verified)]: true,
      [Symbol(pendingSession)]: null,
      [Symbol(asyncId)]: 210925,
      [Symbol(kHandle)]: [TLSWrap],
      [Symbol(kSetNoDelay)]: false,
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(connect-options)]: [Object]
    },
    _header: 'GET /tracks?ids=867665638%2C916488845%2C916541744%2C879502579%2C911544727%2C920224540%2C920227672%2C912258409%2C182859485%2C879588352%2C871408492%2C903271243%2C899338447%2C907746022%2C906903244%2C851514058%2C907746013%2C899541523%2C871778755%2C845983675%2C727730749%2C310455689%2C351996389%2C221308049%2C617744415%2C222335592%2C220021334%2C625572180%2C586430472%2C136515969%2C350544130%2C292528042%2C672835793%2C233271745%2C634818096%2C345014116%2C194674830%2C613079007%2C219240973%2C250830766%2C157946069%2C242071122%2C220940419%2C356904608%2C447921720%2C325876880%2C303520330%2C577977645%2C258583921%2C329292478%2C302734389%2C288394390%2C304744944%2C213828110%2C158384606%2C322256287%2C654816296%2C321085206%2C180526491%2C151836932%2C240510101%2C259932466%2C340422811%2C120417156%2C308158931%2C242970980%2C265004302%2C225515495%2C94470145%2C147235179%2C193641840%2C192956375%2C243086787%2C418406040%2C319849669%2C361549280%2C348894700%2C357040427%2C482437833%2C252638815%2C465024060%2C465229422%2C450607776%2C329511908%2C493285392%2C489363333%2C502948368%2C509000139%2C411189549%2C290210997%2C519271257%2C519206883%2C604903338%2C578505426%2C560864886%2C556088364%2C546188349%2C516324954%2C145367831%2C323733248%2C135322127%2C353880398%2C396944928%2C296968053%2C494976372%2C215558123%2C190445096%2C192408098%2C242672575%2C204778816%2C319887152%2C403960782%2C194510401%2C214816945%2C383884892%2C341315415%2C172595409%2C210014181%2C519749160%2C226139958%2C483679920%2C84118776%2C473381727%2C214140973%2C489177243%2C266963313%2C285262888%2C272020529&client_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX HTTP/1.1\r\n' +
      'Accept: application/json, text/plain, */*\r\n' +
      'User-Agent: axios/0.20.0\r\n' +
      'Host: api-v2.soundcloud.com\r\n' +
      'Connection: close\r\n' +
      '\r\n',
    _onPendingData: [Function: noopPendingOutput],
    agent: Agent {
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      defaultPort: 443,
      protocol: 'https:',
      options: [Object],
      requests: {},
      sockets: [Object],
      freeSockets: {},
      keepAliveMsecs: 1000,
      keepAlive: false,
      maxSockets: Infinity,
      maxFreeSockets: 256,
      maxCachedSessions: 100,
      _sessionCache: [Object],
      [Symbol(kCapture)]: false
    },
    socketPath: undefined,
    method: 'GET',
    insecureHTTPParser: undefined,
    path: '/tracks?ids=867665638%2C916488845%2C916541744%2C879502579%2C911544727%2C920224540%2C920227672%2C912258409%2C182859485%2C879588352%2C871408492%2C903271243%2C899338447%2C907746022%2C906903244%2C851514058%2C907746013%2C899541523%2C871778755%2C845983675%2C727730749%2C310455689%2C351996389%2C221308049%2C617744415%2C222335592%2C220021334%2C625572180%2C586430472%2C136515969%2C350544130%2C292528042%2C672835793%2C233271745%2C634818096%2C345014116%2C194674830%2C613079007%2C219240973%2C250830766%2C157946069%2C242071122%2C220940419%2C356904608%2C447921720%2C325876880%2C303520330%2C577977645%2C258583921%2C329292478%2C302734389%2C288394390%2C304744944%2C213828110%2C158384606%2C322256287%2C654816296%2C321085206%2C180526491%2C151836932%2C240510101%2C259932466%2C340422811%2C120417156%2C308158931%2C242970980%2C265004302%2C225515495%2C94470145%2C147235179%2C193641840%2C192956375%2C243086787%2C418406040%2C319849669%2C361549280%2C348894700%2C357040427%2C482437833%2C252638815%2C465024060%2C465229422%2C450607776%2C329511908%2C493285392%2C489363333%2C502948368%2C509000139%2C411189549%2C290210997%2C519271257%2C519206883%2C604903338%2C578505426%2C560864886%2C556088364%2C546188349%2C516324954%2C145367831%2C323733248%2C135322127%2C353880398%2C396944928%2C296968053%2C494976372%2C215558123%2C190445096%2C192408098%2C242672575%2C204778816%2C319887152%2C403960782%2C194510401%2C214816945%2C383884892%2C341315415%2C172595409%2C210014181%2C519749160%2C226139958%2C483679920%2C84118776%2C473381727%2C214140973%2C489177243%2C266963313%2C285262888%2C272020529&client_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    _ended: true,
    res: IncomingMessage {
      _readableState: [ReadableState],
      readable: false,
      _events: [Object: null prototype],
      _eventsCount: 3,
      _maxListeners: undefined,
      socket: [TLSSocket],
      connection: [TLSSocket],
      httpVersionMajor: 1,
      httpVersionMinor: 1,
      httpVersion: '1.1',
      complete: true,
      headers: [Object],
      rawHeaders: [Array],
      trailers: {},
      rawTrailers: [],
      aborted: false,
      upgrade: false,
      url: '',
      method: null,
      statusCode: 400,
      statusMessage: 'Bad Request',
      client: [TLSSocket],
      _consuming: false,
      _dumped: false,
      req: [Circular],
      responseUrl: 'https://api-v2.soundcloud.com/tracks?ids=867665638%2C916488845%2C916541744%2C879502579%2C911544727%2C920224540%2C920227672%2C912258409%2C182859485%2C879588352%2C871408492%2C903271243%2C899338447%2C907746022%2C906903244%2C851514058%2C907746013%2C899541523%2C871778755%2C845983675%2C727730749%2C310455689%2C351996389%2C221308049%2C617744415%2C222335592%2C220021334%2C625572180%2C586430472%2C136515969%2C350544130%2C292528042%2C672835793%2C233271745%2C634818096%2C345014116%2C194674830%2C613079007%2C219240973%2C250830766%2C157946069%2C242071122%2C220940419%2C356904608%2C447921720%2C325876880%2C303520330%2C577977645%2C258583921%2C329292478%2C302734389%2C288394390%2C304744944%2C213828110%2C158384606%2C322256287%2C654816296%2C321085206%2C180526491%2C151836932%2C240510101%2C259932466%2C340422811%2C120417156%2C308158931%2C242970980%2C265004302%2C225515495%2C94470145%2C147235179%2C193641840%2C192956375%2C243086787%2C418406040%2C319849669%2C361549280%2C348894700%2C357040427%2C482437833%2C252638815%2C465024060%2C465229422%2C450607776%2C329511908%2C493285392%2C489363333%2C502948368%2C509000139%2C411189549%2C290210997%2C519271257%2C519206883%2C604903338%2C578505426%2C560864886%2C556088364%2C546188349%2C516324954%2C145367831%2C323733248%2C135322127%2C353880398%2C396944928%2C296968053%2C494976372%2C215558123%2C190445096%2C192408098%2C242672575%2C204778816%2C319887152%2C403960782%2C194510401%2C214816945%2C383884892%2C341315415%2C172595409%2C210014181%2C519749160%2C226139958%2C483679920%2C84118776%2C473381727%2C214140973%2C489177243%2C266963313%2C285262888%2C272020529&client_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
      redirects: [],
      [Symbol(kCapture)]: false
    },
    aborted: false,
    timeoutCb: null,
    upgradeOrConnect: false,
    parser: null,
    maxHeadersCount: null,
    reusedSocket: false,
    _redirectable: Writable {
      _writableState: [WritableState],
      writable: true,
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _options: [Object],
      _ended: true,
      _ending: true,
      _redirectCount: 0,
      _redirects: [],
      _requestBodyBuffers: [],
      _onNativeResponse: [Function],
      _currentRequest: [Circular],
      _currentUrl: 'https://api-v2.soundcloud.com/tracks?ids=867665638%2C916488845%2C916541744%2C879502579%2C911544727%2C920224540%2C920227672%2C912258409%2C182859485%2C879588352%2C871408492%2C903271243%2C899338447%2C907746022%2C906903244%2C851514058%2C907746013%2C899541523%2C871778755%2C845983675%2C727730749%2C310455689%2C351996389%2C221308049%2C617744415%2C222335592%2C220021334%2C625572180%2C586430472%2C136515969%2C350544130%2C292528042%2C672835793%2C233271745%2C634818096%2C345014116%2C194674830%2C613079007%2C219240973%2C250830766%2C157946069%2C242071122%2C220940419%2C356904608%2C447921720%2C325876880%2C303520330%2C577977645%2C258583921%2C329292478%2C302734389%2C288394390%2C304744944%2C213828110%2C158384606%2C322256287%2C654816296%2C321085206%2C180526491%2C151836932%2C240510101%2C259932466%2C340422811%2C120417156%2C308158931%2C242970980%2C265004302%2C225515495%2C94470145%2C147235179%2C193641840%2C192956375%2C243086787%2C418406040%2C319849669%2C361549280%2C348894700%2C357040427%2C482437833%2C252638815%2C465024060%2C465229422%2C450607776%2C329511908%2C493285392%2C489363333%2C502948368%2C509000139%2C411189549%2C290210997%2C519271257%2C519206883%2C604903338%2C578505426%2C560864886%2C556088364%2C546188349%2C516324954%2C145367831%2C323733248%2C135322127%2C353880398%2C396944928%2C296968053%2C494976372%2C215558123%2C190445096%2C192408098%2C242672575%2C204778816%2C319887152%2C403960782%2C194510401%2C214816945%2C383884892%2C341315415%2C172595409%2C210014181%2C519749160%2C226139958%2C483679920%2C84118776%2C473381727%2C214140973%2C489177243%2C266963313%2C285262888%2C272020529&client_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
      [Symbol(kCapture)]: false
    },
    [Symbol(kCapture)]: false,
    [Symbol(kNeedDrain)]: false,
    [Symbol(corked)]: 0,
    [Symbol(kOutHeaders)]: [Object: null prototype] {
      accept: [Array],
      'user-agent': [Array],
      host: [Array]
    }
  },
  response: {
    status: 400,
    statusText: 'Bad Request',
    headers: {
      'strict-transport-security': 'max-age=63072000',
      vary: 'Origin',
      via: '1.1 e57fe70b9ed429fb51b4b2432cadc67b.cloudfront.net (CloudFront)',
      'x-amz-cf-id': 'YbS6yqSmjIrGDdLZqKdTd3QHiqETWVPsKNUV43eE_Zak-hrQqsoAAQ=='
    config: {
      url: 'https://api-v2.soundcloud.com/tracks?ids=867665638%2C916488845%2C916541744%2C879502579%2C911544727%2C920224540%2C920227672%2C912258409%2C182859485%2C879588352%2C871408492%2C903271243%2C899338447%2C907746022%2C906903244%2C851514058%2C907746013%2C899541523%2C871778755%2C845983675%2C727730749%2C310455689%2C351996389%2C221308049%2C617744415%2C222335592%2C220021334%2C625572180%2C586430472%2C136515969%2C350544130%2C292528042%2C672835793%2C233271745%2C634818096%2C345014116%2C194674830%2C613079007%2C219240973%2C250830766%2C157946069%2C242071122%2C220940419%2C356904608%2C447921720%2C325876880%2C303520330%2C577977645%2C258583921%2C329292478%2C302734389%2C288394390%2C304744944%2C213828110%2C158384606%2C322256287%2C654816296%2C321085206%2C180526491%2C151836932%2C240510101%2C259932466%2C340422811%2C120417156%2C308158931%2C242970980%2C265004302%2C225515495%2C94470145%2C147235179%2C193641840%2C192956375%2C243086787%2C418406040%2C319849669%2C361549280%2C348894700%2C357040427%2C482437833%2C252638815%2C465024060%2C465229422%2C450607776%2C329511908%2C493285392%2C489363333%2C502948368%2C509000139%2C411189549%2C290210997%2C519271257%2C519206883%2C604903338%2C578505426%2C560864886%2C556088364%2C546188349%2C516324954%2C145367831%2C323733248%2C135322127%2C353880398%2C396944928%2C296968053%2C494976372%2C215558123%2C190445096%2C192408098%2C242672575%2C204778816%2C319887152%2C403960782%2C194510401%2C214816945%2C383884892%2C341315415%2C172595409%2C210014181%2C519749160%2C226139958%2C483679920%2C84118776%2C473381727%2C214140973%2C489177243%2C266963313%2C285262888%2C272020529&client_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
      method: 'get',
      headers: [Object],
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 0,
      adapter: [Function: httpAdapter],
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxBodyLength: -1,
    },
      _events: [Object: null prototype],
      _maxListeners: undefined,
      writable: true,
      chunkedEncoding: false,
      useChunkedEncodingByDefault: false,
      _removedConnection: false,
      _contentLength: 0,
      _trailer: '',
      _headerSent: true,
      connection: [TLSSocket],
        'Accept: application/json, text/plain, */*\r\n' +
        'User-Agent: axios/0.20.0\r\n' +
        '\r\n',
      agent: [Agent],
      socketPath: undefined,
      insecureHTTPParser: undefined,
      _ended: true,
      timeoutCb: null,
      [Symbol(kNeedDrain)]: false,
      [Symbol(kOutHeaders)]: [Object: null prototype]
    data: {}
  isAxiosError: true,
}

Please remove console.log in info.js

looks like you have deleted console.log which is in src/info.js, but in dist/info.js there is still one console.log on line 86. It's really annoying because it fills my terminal every time the request fails.

Discord

I think you should include a tiny guide on how to use with Discord.JS.

i.e get file, play it and clear it after the file has been played.

even though I think adding a way to stream the audio directly via a link would be better(which is basically already on your to-do list)

Why does this CLOSE_WAIT happen?

node    47028 ubuntu  163u  IPv4 1384716      0t0  TCP MYIP:51314->server-52-84-229-94.sin2.r.cloudfront.net:https (CLOSE_WAIT)
node    47028 ubuntu  167u  IPv4 1384730      0t0  TCP MYIP:51318->server-52-84-229-94.sin2.r.cloudfront.net:https (CLOSE_WAIT)
node    47028 ubuntu  169u  IPv4 1384727      0t0  TCP MYIP:51316->server-52-84-229-94.sin2.r.cloudfront.net:https (CLOSE_WAIT)
node    47028 ubuntu  170u  IPv4 1387572      0t0  TCP MYIP:52174->server-13-35-20-66.sin5.r.cloudfront.net:https (ESTABLISHED)
node    47028 ubuntu  172u  IPv4 1388618      0t0  TCP MYIP:51574->server-52-84-229-94.sin2.r.cloudfront.net:https (CLOSE_WAIT)

When I play the music by discord bot (using this library), the bot has many close_wait connection.
This leads to waste of resources.

Breaking change in 0.2.1 from 0.2.0

After updating to 0.2.1 I am getting this error
(node:9432) UnhandledPromiseRejectionWarning: TypeError: scdl.isValidUrl is not a function

Usage:

const scdl = require("soundcloud-downloader");
scdl.isValidUrl(url)

Error when compiling


8   const trackNames = []
          ~~~~~~~~~~

node_modules/soundcloud-downloader/src/download-playlist.ts:10:24 - error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
  Type 'undefined' is not assignable to type 'string'.

10     const p = download(track.permalink_url, clientID, axiosInstance)
                          ~~~~~~~~~~~~~~~~~~~

node_modules/soundcloud-downloader/src/download-playlist.ts:15:19 - error TS7005: Variable 'trackNames' implicitly has an 'any[]' type.

15   return [result, trackNames]
                     ~~~~~~~~~~

node_modules/soundcloud-downloader/src/download.ts:91:29 - error TS2532: Object is possibly 'undefined'.

91   return await fromMediaObj(info.media.transcodings[0], clientID, axiosInstance)
                               ~~~~~~~~~~

node_modules/soundcloud-downloader/src/index.ts:1:19 - error TS7016: Could not find a declaration file for module 'soundcloud-key-fetch'. 'D:/Bernd/BerndPC/Documents/Github/Javascript/Discord-MusicBot/node_modules/soundcloud-key-fetch/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/soundcloud-key-fetch` if it exists or add a new declaration (.d.ts) file containing `declare module 'soundcloud-key-fetch';`

1 import sckey from 'soundcloud-key-fetch'
                    ~~~~~~~~~~~~~~~~~~~~~~

node_modules/soundcloud-downloader/src/index.ts:24:32 - error TS2532: Object is possibly 'undefined'.

24   const filtered = filterMedia(info.media.transcodings, { format: format })
                                  ~~~~~~~~~~

node_modules/soundcloud-downloader/src/index.ts:51:3 - error TS2564: Property 'STREAMING_PROTOCOLS' has no initializer and is not definitely assigned in the constructor.

51   STREAMING_PROTOCOLS: { [key: string]: STREAMING_PROTOCOLS }
     ~~~~~~~~~~~~~~~~~~~

node_modules/soundcloud-downloader/src/index.ts:52:3 - error TS2564: Property 'FORMATS' has no initializer and is not definitely assigned in the constructor.        

52   FORMATS: { [key: string]: FORMATS }
     ~~~~~~~

node_modules/soundcloud-downloader/src/index.ts:57:3 - error TS2564: Property 'axios' has no initializer and is not definitely assigned in the constructor.

57   axios: AxiosInstance
     ~~~~~

node_modules/soundcloud-downloader/src/index.ts:247:5 - error TS2322: Type 'string | undefined' is not assignable to type 'string'.
  Type 'undefined' is not assignable to type 'string'.

247     return this._clientID
        ~~~~~~~~~~~~~~~~~~~~~

node_modules/soundcloud-downloader/src/index.ts:274:7 - error TS2322: Type 'string | undefined' is not assignable to type 'string'.
  Type 'undefined' is not assignable to type 'string'.

274       return this._clientID
          ~~~~~~~~~~~~~~~~~~~~~

node_modules/soundcloud-downloader/src/index.ts:287:7 - error TS2769: No overload matches this call.
  Overload 1 of 4, '(path: number | PathLike, options: { encoding?: null | undefined; flag?: string | undefined; } | null | undefined, callback: (err: ErrnoException | null, data: Buffer) => void): void', gave the following error.
    Argument of type '"utf8"' is not assignable to parameter of type '{ encoding?: null | undefined; flag?: string | undefined; } | null | undefined'.
  Overload 2 of 4, '(path: number | PathLike, options: string | { encoding: string; flag?: string | undefined; }, callback: (err: ErrnoException | null, data: string) => void): void', gave the following error.
    Argument of type '(err: NodeJS.ErrnoException, data: string) => void' is not assignable to parameter of type '(err: ErrnoException | null, data: string) => void'.
      Types of parameters 'err' and 'err' are incompatible.
        Type 'ErrnoException | null' is not assignable to type 'ErrnoException'.
          Type 'null' is not assignable to type 'ErrnoException'.
  Overload 3 of 4, '(path: number | PathLike, options: string | { encoding?: string | null | undefined; flag?: string | undefined; } | null | undefined, callback: (err: ErrnoException | null, data: string | Buffer) => void): void', gave the following error.
    Argument of type '(err: NodeJS.ErrnoException, data: string) => void' is not assignable to parameter of type '(err: ErrnoException | null, data: string | Buffer) => void'.
      Types of parameters 'err' and 'err' are incompatible.
        Type 'ErrnoException | null' is not assignable to type 'ErrnoException'.
          Type 'null' is not assignable to type 'ErrnoException'.

287       fs.readFile(filename, 'utf8', (err: NodeJS.ErrnoException, data: string) => {
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
288         if (err) return reject(err)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
309         }
    ~~~~~~~~~
310       })
    ~~~~~~~~


node_modules/soundcloud-downloader/src/index.ts:322:31 - error TS2322: Type 'string | undefined' is not assignable to type 'string'.
  Type 'undefined' is not assignable to type 'string'.

322       if (isFirebaseURL(url)) url = await convertFirebaseURL(url, this.axios)
                                  ~~~

node_modules/soundcloud-downloader/src/info.ts:168:24 - error TS2345: Argument of type 'number' is not assignable to parameter of type 'never'.

168       splitIds[i].push(ids[x])
                           ~~~~~~

node_modules/soundcloud-downloader/src/likes.ts:43:23 - error TS2532: Object is possibly 'undefined'.

43   while (nextHref && (options.limit > 0 || options.limit === -1)) {
                         ~~~~~~~~~~~~~

node_modules/soundcloud-downloader/src/likes.ts:53:89 - error TS2769: No overload matches this call.
  Overload 1 of 2, '(...items: ConcatArray<never>[]): never[]', gave the following error.
    Argument of type 'Like' is not assignable to parameter of type 'ConcatArray<never>'.
      Type 'Like' is missing the following properties from type 'ConcatArray<never>': length, join, slice
  Overload 2 of 2, '(...items: ConcatArray<never>[]): never[]', gave the following error.
    Argument of type 'Like' is not assignable to parameter of type 'ConcatArray<never>'.

53     query.collection = query.collection.reduce((prev, curr) => curr.track ? prev.concat(curr) : prev, [])
                                                                                           ~~~~


node_modules/soundcloud-downloader/src/likes.ts:54:10 - error TS2454: Variable 'response' is used before being assigned.

54     if (!response) {
            ~~~~~~~~

node_modules/soundcloud-downloader/src/likes.ts:63:7 - error TS2532: Object is possibly 'undefined'.

63       options.limit -= query.collection.length
         ~~~~~~~~~~~~~

node_modules/soundcloud-downloader/src/likes.ts:65:11 - error TS2532: Object is possibly 'undefined'.

             ~~~~~~~~~~~~~

node_modules/soundcloud-downloader/src/likes.ts:79:10 - error TS2454: Variable 'response' is used before being assigned.

79   return response
            ~~~~~~~~


Found 20 errors.```

This is the error log from tsc

nothing is working

=== npm audit security report ===

┌──────────────────────────────────────────────────────────────────────────────┐
│ Manual Review │
│ Some vulnerabilities require your attention to resolve │
│ │
│ Visit https://go.npm.me/audit-guide for additional guidance │
└──────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low │ Prototype Pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ minimist │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=0.2.1 <1.0.0 || >=1.2.3 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ soundcloud │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ soundcloud > node-static > optimist > minimist │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/1179
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low │ Unauthorized File Access │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ node-static │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ No patch available │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ soundcloud │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ soundcloud > node-static │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/1206
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low │ Open Redirect │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ node-static │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ No patch available │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ soundcloud │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ soundcloud > node-static │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/1207
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Denial of Service │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ node-static │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ No patch available │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ soundcloud │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ soundcloud > node-static │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/1208
└───────────────┴──────────────────────────────────────────────────────────────┘
found 4 vulnerabilities (3 low, 1 high) in 146 scanned packages
4 vulnerabilities require manual review. See the full report for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.