An asynchronous Python library for building Stremio addons with ease
Project description
Stremio Addon Framework

A Python framework for building Stremio addons with async support, leveraging BlackSheep for fast HTTP handling and modern tooling.
Features ✨
- Async-first: Leverage Python's
asynciofor high-performance addons. - Decorator-based handlers: Easily register handlers for resources like
stream,meta,catalog, andsubtitles. - Static file serving: Serve static directories with custom cache control.
- Central registry publishing: Publish your addon to Stremio's central API with one call.
Installation
pip install stremio
Quick Start
from stremio import Addon
# Define your addon manifest.
# See: https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/responses/manifest.md
manifest = {
"id": "org.example.myaddon",
"version": "1.0.0",
"name": "My Awesome Addon",
"description": "This is a simple Awesome Addon!",
"logo": "https://myaddon.com/logo.png",
"catalogs": [],
"resources": ["stream", "meta"], # Add your supported resources here
"types": ["movie"]
}
addon = Addon(manifest=manifest, port=7000)
# Add a stream handler
@addon.stream()
async def stream_handler(data):
return {
"streams": [{"name": "4K", "url": "https://example.com/cars_3.mp4"}]
}
# Add a subtitles handler
@addon.subtitles()
async def subtitles_handler(data):
return {
"subtitles": [{"id": "1", "url": "https://example.com/cars_3_ar.srt", "lang": "Arabic"}]
}
if __name__ == "__main__":
addon.run()
Usage Guide
1. Initialize the Addon
addon = Addon(
manifest=manifest,
static_dir=["static"], # Serve static files from these directories
cache_max_age=3600, # Cache responses for 1 hour; you can override this on handler response
public_host="myaddon.com",
log_level="info"
)
| Parameter | Description |
|---|---|
manifest |
Required Addon manifest (validated on initialization). |
static_dir |
Directories to serve static files from. |
cache_max_age |
Max cache age in seconds for responses (default: 0). |
public_host |
Public URL for addon installation links (e.g., stremio://myaddon.com/manifest.json). |
log_level |
Server log level (debug, info, warning, error, critical). |
2. Register Resource Handlers
Use decorators to register handlers:
Stream Handler
@addon.stream()
async def stream_handler(data):
# data = {"id": "tt12345", "type": "movie", "extraArgs": None}
return {"streams": [...]} # See: https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/responses/stream.md
Meta Handler
@addon.meta()
async def meta_handler(data):
return {"meta": {...}} # See: https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/responses/meta.md
Catalog Handler
@addon.catalog()
async def catalog_handler(data):
return {"metas": [...]} # Return list of meta items. See: https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/requests/defineCatalogHandler.md#returns
Subtitles Handler
@addon.subtitles()
async def subtitles_handler(data):
return {"subtitles": [...]} # See: https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/responses/subtitles.md
3. Custom Landing Page
@addon.landing_page()
async def landing_page(request): # homepage a.k.a accessing myaddon.com/
return "<h1>Welcome to My Addon!</h1>"
4. Publish to Central Registry
async def publish_addon():
await addon.publishToCentral(
manifest_url="https://myaddon.com/manifest.json",
)
Advanced Configuration
Cache Control
Return these keys in your handler responses to set cache headers:
{
"cacheMaxAge": 3600, # max-age=3600
"staleRevalidate": 86400, # stale-while-revalidate=86400
"staleError": 172800 # stale-if-error=172800
}
Static Files
Addon(static_dir=["assets", "public"])
Files in assets/file.txt will be available at myaddon.com/assets/file.txt.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file stremio-0.1.0.dev0.tar.gz.
File metadata
- Download URL: stremio-0.1.0.dev0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01c3be641aa61259dea361be3093822723f8cbe32199cf1371c1e31cf507b997
|
|
| MD5 |
4860ff44fa65f32cb5755b1d042300a0
|
|
| BLAKE2b-256 |
fa69583ee552b323f84d8d1ec0a836d85617665a16afe5dd907719695ec68bf4
|
Provenance
The following attestation bundles were made for stremio-0.1.0.dev0.tar.gz:
Publisher:
publish-to-pypi.yml on AYMENJD/stremio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stremio-0.1.0.dev0.tar.gz -
Subject digest:
01c3be641aa61259dea361be3093822723f8cbe32199cf1371c1e31cf507b997 - Sigstore transparency entry: 164137226
- Sigstore integration time:
-
Permalink:
AYMENJD/stremio@10a7b32ee9d6d1f61e7cd9164b148f67342b2504 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AYMENJD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@10a7b32ee9d6d1f61e7cd9164b148f67342b2504 -
Trigger Event:
workflow_dispatch
-
Statement type: