1.0.15 • Published 1 year ago

icecast-sdk-js v1.0.15

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Icecast SDK for JavaScript

Version

NodeJS / Typescript SDK for Icecast APIs

Icecast APIs

https://icecast.org/docs/icecast-trunk/server_stats/ \ https://icecast.org/docs/icecast-trunk/admin_interface/

Install

Use pnpm to install the module

pnpm install icecast-sdk-js

Or use npm to install the module

npm install icecast-sdk-js

Or use yarn to install the module

yarn add icecast-sdk-js

Usage

Get Stats

Sample Request

import IcecastServer from 'icecast-sdk-js'

const hostUrl = 'http://locahost:8000'
const ic = new IcecastServer(hostUrl)

void (async () => {
  const stats = await ic.getStats()
  console.log(stats)
})()

Sample Response

{
  "admin": "icemaster@localhost",
  "host": "localhost",
  "location": "Earth",
  "server_id": "Icecast 2.4.4",
  "server_start": "Wed, 20 Mar 2024 21:43:10 -0700",
  "server_start_iso8601": "2024-03-20T21:43:10-0700",
  "source": {
    "mount": "/your-mountpoint",
    "bitrate": 256,
    "genre": "field recording",
    "listener_peak": 0,
    "listeners": 0,
    "listenurl": "http://localhost:8000/your-mount-point",
    "server_description": "Unspecified description",
    "server_name": "your server name",
    "server_type": "audio/mpeg",
    "server_url": "your-website.net",
    "stream_start": "Thu, 27 Jun 2024 16:09:05 -0700",
    "stream_start_iso8601": "2024-06-27T16:09:05-0700",
    "title": "your title",
    "dummy": null
  }
}

Update Source Title (Requires Icecast Server admin username and password)

Sample Request

import IcecastServer from 'icecast-sdk-js'

const { IC_HOST, IC_USERNAME, IC_PASSWORD } = process.env || {}
const ic = new IcecastServer(IC_HOST, { username: IC_USERNAME, password: IC_PASSWORD })

void (async () => {
  const mountpoint = 'yourmountpoint'
  const title = 'your new title'
  try {
    const source = await ic.updateSource(mountpoint, title)
    console.log(source)
  } catch (error) {
    console.log(error.response.data)
  }
})()

Sample Response

{
  "mount": "/your-mountpoint",
  "bitrate": 256,
  "genre": "field recording",
  "listener_peak": 0,
  "listeners": 0,
  "listenurl": "http://localhost:8000/your-mount-point",
  "server_description": "Unspecified description",
  "server_name": "your server name",
  "server_type": "audio/mpeg",
  "server_url": "your-website.net",
  "stream_start": "Thu, 27 Jun 2024 16:09:05 -0700",
  "stream_start_iso8601": "2024-06-27T16:09:05-0700",
  "title": "your new title",
  "dummy": null
}
1.0.12-beta

1 year ago

1.0.13-beta

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.11-beta

1 year ago

1.0.10-beta

1 year ago

1.0.9-beta

2 years ago

1.0.8-beta

2 years ago

1.0.7-beta

2 years ago

1.0.6-beta

2 years ago

1.0.5-beta

2 years ago

1.0.4-beta

2 years ago

1.0.3-beta

2 years ago

1.0.2-beta

2 years ago

1.0.1-beta

2 years ago

1.0.0-beta

2 years ago