Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
node-spotify-webhelper-portscanner
Advanced tools
Readme
This package is a fork and a extension of the Node Spotify Web Helper module: https://github.com/nadavbar/node-spotify-webhelper It keeps the same interface as described in the docs below and extend it to use a port scanner to detect Spotify open ports that supports Spotify local protocol.
Node.js interface for the Spotify WebHelper API, based on this great article: http://cgbystrom.com/articles/deconstructing-spotifys-builtin-http-server/
The API interacts with the SpotifyWebHelper process via HTTP. For windows, the module checks whether SpotifyWebHelper.exe is running, and try to run it if not.
API:
This module exposes the SpotifyWebHelper object, which exposes the following methods:
Examples - Get Status
var SpotifyWebHelper = require('node-spotify-webhelper');
var spotify = new SpotifyWebHelper();
// get the name of the song which is currently playing
spotify.getStatus(function (err, res) {
if (err) {
return console.error(err);
}
console.info('currently playing:',
res.track.artist_resource.name, '-',
res.track.track_resource.name);
});
Examples - Port detection The following example will detect open ports for Spotify desktop applications. To detect open ports a forked and modified port scanner node module has been used: https://github.com/baalexander/node-portscanner
Each of those ports respond to the Spotify local protocol and can be used to communicate to Spotify desktop application on the same host.
var SpotifyWebHelper = require('node-spotify-webhelper-portscanner');
var spotifyClient = new SpotifyWebHelper(); // init with default port
spotifyClient.scanPorts({
lowPort : 3000,
highPort : 5000,
timeout : 300
}
, function(error, ports) {
if(!error)
return console.log( ports );
else return console.error(error);
});
where lowPort
is the lower port number, highPort
is the higher port number, timeout
is the socket timeout for the port in msec
.
An example of the ouput. A json containing a port
number and an error
field if any like:
[
{
"port": 4370
},
{
"port": 4371,
"error" : { "error" : "Error: socket hang up", "code" : "ECONNRESET"}
}
]
Examples - Connect to a specific port As soon as a port is known to work, the Spotify Web Helper can be instantiated with that port to correctly communicate to Spotify running application on the same host:
var SpotifyWebHelper = require('node-spotify-webhelper-portscanner');
console.log("Connecting to Spotify on port [%d]...", openPort);
var spotifyClient = new SpotifyWebHelper( { port : openPort });
spotifyClient.getStatus(function (err, res) {
if (err) {
return console.error(err);
}
console.info('Currently Playing:',
res.track.artist_resource.name, '-',
res.track.track_resource.name);
});
return console.log("Spotify is listening on port [%d]", item);
});
Examples - Auto detect an open port and connect
To automatically detect an open port and connect to this one, use the autoDectect
option set to true.
var SpotifyWebHelper = require('../index');
var spotifyClient = new SpotifyWebHelper( { autoDectect : true }); // init with default port
spotifyClient.getStatus(function (err, res) {
if (err) {
console.error(err);
}
else if(res) {
console.info('Currently Playing:',
res.track.artist_resource.name, '-',
res.track.track_resource.name);
}
});
See examples/
folder for more examples and code.
FAQs
Node.js interface for the local Spotify WebHelper API plus a Port Scanner
The npm package node-spotify-webhelper-portscanner receives a total of 2 weekly downloads. As such, node-spotify-webhelper-portscanner popularity was classified as not popular.
We found that node-spotify-webhelper-portscanner 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.