
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
adblockradio-sdk
Advanced tools
This is a JS Node & browser library to connect to adblockradio.com API servers. It provides live information about the nature of broadcast contents: either ads, talk or music. It also gives the average volume gain of radio streams so that channel-hopping between stations does not lead to volume variations.
$ npm install
The demo script demo.js
requires libabr.js
. To test it in a browser, you need to use browserify.
$ browserify demo.js -o bundle.js
or
$ npm run build
Then launch a local web server at http://localhost:5000
:
$ serve -s
The demo has no UI, everything happens in the web console (F12 to display it in Firefox & Chrome).
Put a valid token in a token
file. Then:
$ nodejs demo_node.js
A token is required to use this API. To get one:
The workflow is to call connectServer
, then get the list of available streams with getSupportedRadios
. You create a list of desired radios and send it to the server with sendPlaylist
. You register to a prediction callback with setPredictionCallback
. It will give you live updates about the streams status.
If a prediction is incorrect, use sendFlag
to help improve the system.
If you want to send some feedback with the API, use sendFeedback
.
var abrsdk = require("./libabr.js")();
var token = "change me";
var onConnectionEvent = function(err, isConnected) {
if (err) return console.log("connection error: " + err);
if (!isConnected) return console.log("disconnected");
abrsdk.getSupportedRadios(function(data) {
console.log("supported radios: " + JSON.stringify(data));
// here you can choose which stations you want to monitor.
// you can monitor at most data.maxPlaylistLen stations at the same time.
abrsdk.sendPlaylist(data.supportedRadios.slice(0, data.maxPlaylistLen), token, function(err, validatedPlaylist) {
if (err) {
console.log("sendPlaylist error = " + err);
} else {
// the validated playlist contains the list of monitored radios you have submitted,
// minus the unavailable, invalid, or in excess station names.
console.log("validated playlist = " + JSON.stringify(validatedPlaylist));
abrsdk.setPredictionCallback(onPrediction);
// to signal an incorrect radio status, send a flag and improve future predictions.
//abrsdk.sendFlag(validatedPlaylist, token);
// to send a feedback with the API, use abrsdk.sendFeedback(boolean isPositive, string feedback, string token)
//abrsdk.sendFeedback(true, "test feedback", token);
}
});
});
}
var onPrediction = function(predictions) {
var status, volume;
for (var i=0; i<predictions.radios.length; i++) {
switch (predictions.status[i]) {
case abrsdk.statusList.STATUS_AD: status = "AD"; break;
case abrsdk.statusList.STATUS_SPEECH: status = "SPEECH"; break;
case abrsdk.statusList.STATUS_MUSIC: status = "MUSIC"; break;
default: status = "not available";
}
// normalized volume to apply to the audio tag to have similar loudness between channels
volume = Math.pow(10, (Math.min(abrsdk.GAIN_REF-predictions.gain[i],0))/20);
// you can now plug the data to your radio player.
console.log(predictions.radios[i] + " has status " + status + " and volume " + Math.round(volume*100)/100);
}
}
abrsdk.connectServer(onConnectionEvent);
MIT
FAQs
Adblock Radio client SDK
The npm package adblockradio-sdk receives a total of 3 weekly downloads. As such, adblockradio-sdk popularity was classified as not popular.
We found that adblockradio-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.