Stremio add-ons guide

Stremio add-ons guide

  • Home
  • SDK
  • Guide

›Add-on SDK Guide

Add-on SDK Guide

  • Prelude
  • 1. Get started
  • 2. Adding catalogs
  • 3. Meta
  • 4. Streams
  • 5. Deploying

Generic Add-on Guide

  • The basics
  • 1. The add-on manifest
  • 2. Testing the add-on
  • 3. The catalog
  • 4. Simple meta
  • 5. Providing streams
  • 6. Multiple videos
  • 7. Dynamic content
  • 8. Deploying

4. Streams

The streams in Stremio's add-ons are just shortcuts to the actual media. They do not contain any videos but instead, they just point Stremio to the right place where these videos can be found.

Update the manifest

If you've selected "streams" in addon-bootstrap, you will have streams already listed in the resources array.

"resources": [
    "catalog",
    {
        "name": "meta",
        "types": ["movie"],
        "idPrefixes": ["hiwrld_"]
    },
    "streams"
]

Add streams

At this point you have two videos in your catalog. In order to serve them, you will create a function:

function getMovieStreams(id) {
    const streams = {
        tt1254207: [
            { "title": "HTTP location", "yt_ID": "aqz-KE-bpKQ"}
        ]
        hiwrld_jellyfish: [
            { "title": "Web, 3 MBps, HD", "url": "http://jell.yfish.us/media/jellyfish-3-mbps-hd-h264.mkv" },
            { "title": "Web 15 MBps, HD", "url": "http://jell.yfish.us/media/jellyfish-15-mbps-hd-h264.mkv" },
            { "title": "Web, 120 MBps, 4K", "url": "http://jell.yfish.us/media/jellyfish-120-mbps-4k-uhd-h264.mkv" }
        ]
    }
    return Promise.resolve(streams[id] || [])
}

Let's handle this resource:

builder.defineStreamHandler(({type, id}) => {
    // Docs: https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/requests/defineStreamHandler.md
    let results;

    switch(type) {
        case 'movie':
            results = getMovieStreams(id)
            break
       default:
            results = Promise.resolve( [] )
            break
    }
    return results.then(streams => ({streams}))
})

When your add-on is unable to provide streams for particular video, you have to return an empty streams array. Otherwise and error is shown to the user.

As you can see, the stream object can point to variety of streams. The complete reference is located here.

← 3. Meta5. Deploying →
  • Update the manifest
  • Add streams
Stremio add-ons guide
Docs
GuideAPI Reference
Community
RedditFacebookTwitter
More
Official WebsiteBlogGitHub
Copyright © 2023 Stremio