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

neulion

v1.1.2

Published

Neulion API

Downloads

9

Readme

Neulion

Build Status NPM version

Neulion API wrapper for node.js. Currently this is a read-only API.

Install

With npm

npm install neulion

Debug

This module uses the debug module with a key of neulion

DEBUG=neulion node my-app.js

Usage

Node.js

var Neulion = require('neulion')

var config = {
  endpoint: 'http://mydomain.neulion.com/iptv-admin-mlsws/services/ContentWS?wsdl'
, username: 'username'
, password: 'such password'
, group: 101
, autoAuth: true
}

var api = new Neulion(config)

api
  .connect()
  .then(function() {
    return api.list({
      progDate: new Date()
    })
  })
  .then(function(videos) {
    return Promise.map(videos, function(id) {
      return api.details(id)
    })
  })
  .then(function(videos) {
    // ...
  })
  .catch(function(err) {
    console.error('error', err)
  })

API

new Neulion(config)

Create a new Neulion API wrapper

  • config - Object - api options
    • endpoint - String - Neulion HTTP endpoint
    • username - String - Username
    • password - String - Password
    • group - Number - Neulion group code
    • autoAuth - Boolean - Authenticate after connect (optional, default true)
var api = new Neulion({
  // ...
})

Neulion.Error

Custom Error class for extracting API response errors. Currently the SOAP calls return Error: undefined undefined and require further inspection.

api
  .details(200)
  .then(function(video) {

  })
  .catch(Neulion.NotConnectedError, function(err) {
    // API not currently connected or authenticated
  })
  .catch(Neulion.AuthenticationError, function(err) {
    // API not currently authenticated, either missing or invalid credentials
    // or the `auth` method was never called in the first place.
  })
  .catch(Neulion.SoapError, function(err) {
    // Error during API SOAP call
  })
  .catch(Neulion.Error, function(err) {
    // General catch-all for errors above
  })
  .catch(function(err) {
    // Something else went wrong
  })

api.connect()

Connect to the Neulion API and authenticate.

api
  .connect()
  .then(function() {
    // Arguments can be omitted if set in config
    // Method call can be omitted if `autoAuth` is set in config
    return api.auth(username, password)
  })
  .then(function(authCode) {
    // The actual soap client is stored as `api.client`
    console.log('SOAP client: ', api.client)
    
    // The WSDL XML schema is also saved for inspection
    console.log('SOAP schema: ', api.schema)
  })
  .catch(function(err) {
    // ...
  })

api.auth(username, password)

Alias: [authenticate]

Authenticate against the Neulion API and store the code for future requests. This is automatically called from connect by default since the auth code is required.

If arguments are sent, the internal config will be updated.

  • username - String - neulion login id (optional, uses config value)
  • password - String - neulion password (optional, uses config value)
api
  .auth('joe', 'asdf123')
  .then(function(authCode) {
    // `authCode` is saved internally
  })
  .catch(function(err) {
    // ...
  })

api.details(id)

Get the full video details from Neulion

  • id - Number - neulion video id
api
  .details(322301)
  .then(function(videos) {
    /*!
      [
        {
          altDesc:         String
        , altName:         String
        , archiveTime:     String
        , bigImage:        String
        , bigImageUrl:     String
        , categoryIdArray: Array
        , data1:           String
        , data2:           String
        , desc:            String
        , endTime:         Date
        , eventId:         String
        , extUrl:          String
        , gameId:          String
        , gameTime:        String
        , groupId:         Number
        , highlightType:   String
        , name:            String
        , progDate:        Date
        , programId:       Number
        , programType:     String
        , regRequired:     Boolean
        , shareInPlayer:   Boolean
        , smallImage:      String
        , smallImageUrl:   String
        , startTime:       Date
        , tagArray:        Array
        , updateTime:      String
        , videoName:       String
        , videoTime:       Date
        , videoUrl:        String
        }
      ]
     */
  })
  .catch(function(err) {
    // ...
  })

api.search(params)

Alias: [list]

Search for videos. Returns a list of found Neulion IDs. The details method must be called to get the full video object. Not entirely sure yet how the progDate and updateTime are matched in the API, they seem to return videos for the day of the day sent. Further investigation required.

  • params - api search parameters
    • groupId - Number - neulion group ID (optional, uses config value from constructor if set)
    • progDate - Date|String - limit to given day of date (String format: YYYY-MM-DDTHH:mm:ss.sssZ, date.toISOString())
    • name - String - search by name
    • description - String - search by description
    • updateTime - Date|String - search by last updated (String format: yyyyMMddhhmmss)
api
  .list({
    name: 'my awesome video'
  })
  .then(function(videos) {
    /*!
      [Number, Number, ...]
     */
  })
  .catch(Neulion.Error, function(err) {
    // ...
  })

api.range(start, end)

Search Neulion for videos within the given date range. The API currently only uses a given date to represent that entire day. This is a shortcut to running list multiple times with different dates. Returns a list of found Neulion IDs.

  • start - Date - starting day
  • end - Date - ending day
// Find videos from 5 days ago up to today
var end = Date.now()
  , start = end - (5 * 24 * 60 * 60 * 1000)

api
  .range(start, end)
  .then(function(videos) {
    /*!
      [Number, Number, ...]
     */
  })
  .catch(function(err) {
    // ...
  })

api.categories()

Find all video categories from Neulion. This is done to get the full details of a given category, since the API only returns category IDs on the video object.

This method can be slow depending on how many categories there are.

api
  .categories()
  .then(function(cats) {
    /*!
      [
        {
          categoryId: Number
        , categoryKey: String
        , name: String
        , parentId: Number
        }
      ]
     */
  })
  .catch(function(err) {
    // ...
  })

License

MIT