npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

spotify-port-scanner-node

v1.0.3

Published

This node module will connect to Spotify desktop application using the `spotilocal` protocol with automatic port detection of the host.

Downloads

7

Readme

spotify-port-scanner-node

This node module will connect to Spotify desktop application using the spotilocal protocol with automatic port detection of the host. This module uses the node module node-spotify-webhelper to communicate to the host application.

How to install

To install this module via npm type

npm install -s spotify-port-scanner

To install from sources

git clone https://github.com/loretoparisi/spotify-port-scanner-node.git
cd spotify-port scanner/
npm install

Usage

See examples in examples/ folder for more examples.

Connect the client to the host Spotify application while debugging.

var SpotifySDK = require('spotify-port-scanner-node');
var client = new SpotifySDK.SpotifyClient({ debug : true });
client.connect({
  lowPort : 3000,
  highPort : 5000
})
.then(() => {
  console.log("client connected to host %s:%s", client.getHost(), client.getPort());
})
  .catch(error => {
  console.log("client error", error);  
});

As soon as the client is connected, to get the host application instance and query for the status:

  // get host status
  // get spotify application host
  var host=client.getSpotifyHost();
  host.getStatus(function (error, status) {
    if (error) {
      console.log("host error", err);
    }
    else {
        console.info("host status:", status);
    }
  });

The host protocol

This is an example of host application protocol.

The response status contains the following fields

{
    "version": 9,
    "client_version": "1.0.36.124.g1cba1920",
    "playing": true,
    "shuffle": false,
    "repeat": false,
    "play_enabled": true,
    "prev_enabled": false,
    "next_enabled": true,
    "track": {
        "track_resource": {
            "name": "Blood Host",
            "uri": "spotify:track:2Y4V0ULxOW5ETI2JhnWFlb",
            "location": {
                "og": "https://open.spotify.com/track/2Y4V0ULxOW5ETI2JhnWFlb"
            }
        },
        "artist_resource": {
            "name": "Scar The Martyr",
            "uri": "spotify:artist:1gz9Dd0N7oCymbjVePlxbq",
            "location": {
                "og": "https://open.spotify.com/artist/1gz9Dd0N7oCymbjVePlxbq"
            }
        },
        "album_resource": {
            "name": "Scar The Martyr (Deluxe)",
            "uri": "spotify:album:0ab4DBE7MXSImsTvIegnHI",
            "location": {
                "og": "https://open.spotify.com/album/0ab4DBE7MXSImsTvIegnHI"
            }
        },
        "length": 407,
        "track_type": "normal"
    },
    "context": {},
    "playing_position": 49.558,
    "server_time": 1473682947,
    "volume": 1,
    "online": true,
    "open_graph_state": {
        "private_session": false,
        "posting_disabled": false
    },
    "running": true
}