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

stremio-addon-client

v1.16.1

Published

Client library for using stremio addons (v3 protocol)

Downloads

69

Readme

stremio-addon-client

Client library for using stremio addons (v3 protocol). You can read the actual protocol here.

This can be used to make a UI to the stremio addons. It is currently used in the Stremio desktop app, mobile app and web app.

Client

const client = require('stremio-addon-client')

NOTE: All functions here can either return a Promise or be given a callback(err, res)

client.detectFromURL(url) - detects whether a URL is an addon, collection or neither and constructs the given object

If it detects an add-on: { addon: AddonClientInstance }

If it detects a collection: { collection: { /* collection descriptor that can be loaded by colletion.load() */ } }

If it detects neither, it will throw an exception (or return an error if using a callback): errors.ERR_RESP_UNRECOGNIZED

Please note, this will apply the stremio-addon-linter to lint both add-ons and collections. If the linting fails, the err will contain lintResult property with the exact output from the linter.

client.fromDescriptor(descriptor) - returns an instance of AddonClient, from AddonDescriptor

Please note, descriptor must be a valid descriptor

Instance of AddonClient

addon.get(resource, type, id [, extra]) - call the add-on with the given args
addon.isSupported(resource, type, id) - returns true/false depending on whether this addon supports this call, according to the manifest
addon.manifest - the manifest of the add-on
addon.toDescriptor() - returns an AddonDescriptor

AddonClient Example

client.detectFromURL('https://gateway.ipfs.io/ipfs/QmeZ431sbdzuqJppkiGMTucuZxwBH7CffQMtftkLDypBrg/manifest.json')
.then(function(resp) {
	// resp.addon is an instance of AddonClient
	return resp.addon.get('meta', 'movie', 'exmp:1')
})
.then(function(resp) {
	console.log(resp.meta)
})

AddonCollection

let col = new client.AddonCollection()
col.load(require('stremio-official-addons'))

col.getAddons() - get an array of all Add-ons, where each is an instance of AddonClient

col.load() - load from an object that describes all add-ons (format: [{ manifest, transportUrl, flags }], i.e. [AddonDescriptor])

col.save() - get the object that describes all add-ons (same format as col.load())

col.includes(addon) - returns boolean, whether the add-on is in the collection

col.add(addon) - adds an addon (AddonClient) to a collection

col.remove(addon) - removes an addon (AddonClient) from the collection

col.clone() - creates a clone of the collection

Universal save/load format ([AddonDescriptor])

The format of the .save() and .load() functions is widely used across Stremio to describe a collection of add-ons.

It can also be used to distribute collections of add-ons as JSON files amongst users - similar to the Kodi add-on repositories.

The format is [{ manifest, transportUrl, flags }] (also referred to as [AddonDescriptor]), where flags is ignored by Stremio if loading an untrusted collection.

AddonDescriptor

manifest is a valid stremio addon v3 manifest

transportUrl is the URL to the add-on; the transport that will be used will be determined from this URL

flags is used when Stremio is loading a trusted collection (a built-in collection) to flag add-ons as official or protected

mapURL

client.mapURL(URL1) (returns a string, URL2) is a function that will convert URL1 to a more browser-friendly URL2. This just means forcing HTTPS, and changing localhost to 127.0.0.1 (CORS does not work on localhost). Since this is needed in a lot of places, we expose that function, and recommend that every URL obtained by user input is passed through it before becoming transportUrl

Internal APIs

Transport

let transport = new Transport(url)
transport.manifest(cb)
transport.get(args, cb)

// transport.name

NOTE - you can synchronously construct instances of AddonClient by using the constructor directly: new AddonClient(manifest, transport, flags)