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

dlna-browser-utils

v0.0.2

Published

Utility to browse dlna servers

Downloads

6

Readme

dlna-browser-utils

Small utility to be able to browse the content on a DLNA server.

There were other utilities to discover servers but not to easily browse the content.

Installation

To install simply run:

npm install dlna-browswer-utils

or

npm install https://github.com/mhdawson/dlna-browser-utils.git

Usage

The module exports a single function which has the following signature:

browseServer(id, controlUrl, options, callback)

where the parameters are as follows:

  • id - the id you want to search under. '0' means start from the root.
  • controlUrl - the control url for the server. It can be discovered by using a utility like node-ssdp. see the examples for an example of how you can do this.
  • options - options for the search as described below.
  • callback - callback with 2 parameters, err and result. If err is passed then an error occured, otherwise the result of the search will be in the result object. The result object is as described below.

The options object can optionally conaint the following elements:

  • browseFlag - flag passed to server for browsing. Default is 'BrowseDirectChildren'.
  • filter - filter passed to server for request. Default is '*' to match all results.
  • startIndex - index at which to start returning results. The default is 0 to return all results. If you specify an number that number of results will be omitted from the result. This can be used to get a large set of results incrementally.
  • requestCount - the number of results to return. If there are more than this number of results the result will only contain the first requestCount results.
  • sort - uPnP sort order. Default is '' for no sort.

The result object has two fields each of which is an array. These fields are:

  • container
  • item

The objects in the container array have the following fields:

  • parentID - id of the parent for the container.
  • id - id of the container.
  • childCount - number of children in the container.
  • searchable - indicates if the container is searchable.
  • title - title of the container.

The objects in the item array have the following fields:

  • parentID - id of the parent for the item.
  • id - id of the item.
  • title - title of the item.
  • res - the dlna resource link for the item.
  • contentType - the content type for the item.

Example Usage

The following example shows how to list all of the contents on ad DLNA server. It assumes you have already discovered the control url with a utility like node-ssdp.

As an example you could run it as:

node example.js "http://10.1.1.176:49081/dev/b9a87696-f016-4a54-81b3-75f57185a385/svc/upnp-org/ContentDirectory/action"

by substituting in the control url for your server.

"use strict";

const browseServer = require('./lib/index.js');

var listContent = function(queue, url, options, callback) {
  var root = queue.shift();
  browseServer(
    root,
    url,
    {},
    function(err, result) {
      if (err) {
        callback(err);
        return;
      }
      if (result.container) {
        for (let i = 0; i < result.container.length; i++) {
          if (result.container[i].id != 'Video/temp') {
            queue.push(result.container[i].id);
            console.log('Container:' + result.container[i].id);
          }
        }
      }

      if (result.item) {
        for (let i = 0; i < result.item.length; i++) {
          console.log('Item:' + result.item[i].title);
        }
      }
      if (queue.length >0) {
        listContent(queue, url, options, callback);
      }
    });
  }

  var queue = new Array();
  queue.push('0');
  listContent(queue,
              process.argv[2],
              {},
              function(err){
                console.log(err);
              });

A second example is included in the file example2.js. You will need to install node-ssdp in order to run this second example. It shows how you can dynamically look up a DLNA server by name and then list the top level content with 'dlna-browser-utils'.

As an example you can run it as:

node example2.js 'New - Michaels Media Server'

substituting in the name of a DLNA server on your network.

Contributing

Pull requests welcome. Particularly if you have DLNA servers to test against and find issues. So far I've only tested against my own DLNA server which is part of JavaPvr.