2.1.4 • Published 9 months ago

soulseek-ts v2.1.4

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

soulseek-ts

NPM

A Soulseek client for Node. Fully-typed and promise-based :^)

Features

  • File search
  • File download

Not Implemented

  • File sharing
  • Chat

Getting Started

Check out some examples, or get up and running with this minimal starter:

// create a new client and login
const client = new SlskClient()
await client.login(USERNAME, PASSWORD)

// send a search request and wait for the results
const results = await client.search('autechre')

// grab the first result we find
const result = results.at(0)
if (!result) {
  throw new Error('No results')
}

// grab the first file from the result
const file = result.files.at(0)
if (!file) {
  throw new Error('No files')
}

// send a download request
const download = await client.download(result.username, file.filename)

// create a unique filename for our download and make sure the downloads directory exists
const parsedFilename = path.parse(file.filename.replaceAll('\\', '/'))
const filePath = path.join(
  DOWNLOADS_DIR,
  `slsk-${result.username}-${parsedFilename.name}-${Date.now()}${parsedFilename.ext}`
)
await fs.promises.mkdir(DOWNLOADS_DIR, { recursive: true })

// stream the download data into the file and wait until it is finished
await new Promise((resolve) => {
  const downloaded = fs.createWriteStream(filePath)
  download.stream.pipe(downloaded)
  download.stream.on('end', resolve)
})

// clean up our client
client.destroy()
2.1.4

9 months ago

2.1.3

9 months ago

2.1.2

1 year ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.6

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago