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

reshuffle-eidr-connector

v0.0.24

Published

Reshuffle connectors for eidr.org

Downloads

29

Readme

reshuffle-eidr-connector

Code | npm | Code sample

npm install reshuffle-eidr-connector

Reshuffle EIDR Connector

This package contains a Reshuffle connector to the Entertainment Identifier Registry (EIDR) service at eidr.org.

Please review the EIDR API Specification and User Guide for full details about the service.

The following example creates and API endpoint to query EIDR for movie data:

const { Reshuffle, HttpConnector } = require('reshuffle')
const { EIDRConnector } = require('reshuffle-eidr-connector')

const app = new Reshuffle()
const eidr = new EIDRConnector(app, {
  userId: process.env.EIDR_USERID,
  partyId: process.env.EIDR_PARTYID,
  password: process.env.EIDR_PASSWORD,
})
const http = new HttpConnector(app)

http.on({ method: 'GET', path: '/query' }, async (event) => {
  const name = (event.req.query.name || '').trim()
  if (name.length === 0) {
    return event.res.status(400).send('Missing name')
  }

  try {
    const { results } = await eidr.query({ title: { exact: name } })
    return event.res.json(results)

  } catch (e) {
    return event.res.status(e.status).json({
      error: e.message,
      details: e.details,
    })
  }
})

app.start(8000)

Table of Contents

Configuration Configuration options

Connector actions:

info Get connector information

query Search for media information

resolve Get information for one media resource

simpleQuery Simple search for media information

Configuration options
const app = new Reshuffle()
const eidrConnector = new EIDRConnector(app)

This default initialization will allow access to all public available EIDR functions, including ID resolution. Some functions, including query and ID registration, require EIDR membership credentials. Credentials can be passed as an object in the form:

{
  userId: string
  partyId: string
  password?: string
  shaddow?: string
  domain?: string
}

The userId and partyId are mandatory and provided by EIDR to its members. Either password or shaddow (the base64 encoded MD5 hash of password) must also be provided. The domain can used left out in most cases unless there is a specific reason to use a mirror service.

Credentials can also be passed as a string with the following format: Eidr <userId>:<partyId>:<shaddow>.

Credentials can be passed as a second argument to the connector's constructor:

const credentials = { ... }
const eidrConnector = new EIDRConnector(app, credentials)

or as the last optional argument to priviledged actions like query. This method is usedful when building an service or API to allow third patries to perform queries or other priviledged operations against the EIDR registry.

Connector actions

Info action

Definition:

() => {
  eidrApiVersion: string,
  eidrConnectorVersion: string,
}

Usage:

const info = await eidrConnector.info()

Get connector information.

Query action

Definition:

(
  query: object | string,
  options?: object,
  credentials?: string | object,
) => {
  totalMatches: number,
  results: object[],
}

Usage:

const q = '(/FullMetadata/BaseObjectData/ResourceName "abominable")'

// Get first 25 results
const { results } = await eidrConnector.query(q)

// Get results 11 - 20
const { results } = await eidrConnector.query(
  q,
  { pageNumber: 2, pageSize: 10 },
)

or

const id = '10.5240/DF48-AB62-4486-C185-9E1B-4'
const { results } = await eidrConnector.query({ title: { exact: name } })

Search the EIDR database for matches to the query. You can specify the query using EIDR XML query language or the EIDR Proxy JSON query language.

The optional options object supports the following optional fields:

  • pageNumber?: number - Results page number (default is 1)
  • pageSize?: number - Results page size (default is 25)
  • root?: string - EIDR ID for rooted queries

See the Configuration section above for more details about access credentials.

Resolve action

Definition:

(
  id: string,
) => {
  // media information
}

Usage:

const id = '10.5240/DF48-AB62-4486-C185-9E1B-4'
const info = await eidrConnector.resolve(id)

Get the full information for the media resource (movie, tv show etc) with the specified id. The full information can be very details, as described in page 21 of the EIDR API Specification.

Simple Query action

Definition:

(
  exprOrObj: string | object,
  compareFunction?: (a: object, b: object) => number,
  credentials?: string | object,
) => object[]

Usage:

const id = '10.5240/DF48-AB62-4486-C185-9E1B-4'
const results = await eidrConnector.simpleQuery({
  name,
  movie: true,
  valid: true,
  StructuralType: 'Performance',
})

Search the EIDR database for matches to the query. See query above for details.

The Simple Query action does not support pagination and returns the results array directly to the caller. The results are automatically sorted by descending order of release date. You can control the sort order by specifying a compareFunction that behaves like the one used by Array.sort.

See the Configuration section above for more details about access credentials.

Learn more

You can learn more about Reshuffle on dev.reshuffle.com.