Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mateusaquino/betterstremio
🎬 Enhance your Stremio experience with themes and plugins
https://github.com/mateusaquino/betterstremio
Last synced: 4 days ago
JSON representation
🎬 Enhance your Stremio experience with themes and plugins
- Host: GitHub
- URL: https://github.com/mateusaquino/betterstremio
- Owner: MateusAquino
- Created: 2024-05-31T16:45:53.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-06-05T19:13:17.000Z (5 months ago)
- Last Synced: 2024-06-05T20:23:57.936Z (5 months ago)
- Language: JavaScript
- Size: 147 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
🎬 BetterStremio is a dynamic Plugin & Theme loader for Stremio.
## 💡 How it works
**BetterStremio** patches the `server.js` file to inject code in the local development web server hosted at `127.0.0.1:11470` and adds a loader script to run external plugins and CSS themes. There is no need to download external executables! :)
![image](https://github.com/MateusAquino/BetterStremio/assets/16140783/1d721c4f-6493-4ed7-bb6c-ddc804b88630)
## 🚀 Getting Started
Download and run the installer from the [releases page](https://github.com/MateusAquino/BetterStremio/releases/). You can also choose the "Repair" option if you've updated your Stremio's server.js file or BetterStremio is broken.
> [!TIP]
> The original stremio server can still be used when opening `stremio.exe`. For BetterStremio to work it **must** be opened though the shotcut.Soon we'll be supporting MacOS and Linux (you can also contribute with an installer script).
If you want to install it manually check out Contribute section for more information about how it works.
Demo Plugin: https://github.com/MateusAquino/WatchParty
Demo Theme: https://github.com/REVENGE977/StremioAmoledTheme## 👾 Developing Plugins & Themes
While developing plugins (.js files) and themes (.css files) you should be accessing through the browser at `localhost:11470` for easier reloading and access to Developer Tools.
### 🎨 Themes
Here's a sample of all theme options (note these @annotations are not required but are a nice to have).**Sample.theme.css**:
```css
/**
* @name Amoled Theme
* @description A theme that uses amoled pitch black color.
* @image https://github.com/REVENGE977/stremio-enhanced/raw/main/images/amoled_screenshot.png
* @updateUrl https://raw.githubusercontent.com/REVENGE977/StremioAmoledTheme/main/amoled.theme.css
* @shareUrl https://github.com/REVENGE977/StremioAmoledTheme
* @version 1.0.1
* @author REVENGE977
*/
```
Pitch black Stremio Theme ref: https://github.com/REVENGE977/StremioAmoledTheme### ⚡ Plugins
Developing plugins is easy, here are all the methods you need for a sample plugin:
**Sample.plugin.js**:
```js
module.exports = class SamplePlugin {
getName() {return "Sample BetterStremio Plugin"}
getImage() {return "https://cdn-icons-png.flaticon.com/512/9908/9908191.png"}
getDescription() {return "Sample plugin description."}
getVersion() {return "1.0.0"}
getAuthor() {return "YourAt"}
getShareURL() {return "https://github.com/Sample/example"}
getUpdateURL() {return "https://raw.githubusercontent.com/Sample/example/main/Example.js"}
onBoot() {}
onReady() {}
onLoad() {}
onEnable() {}
onDisable() {}
onSettings() {}
}
```All of these functions are optional. If you remove `onSettings()` declaration the settings button will be removed from your Plugin.
Prefer to always use `onLoad` event (when window is loaded), as `onBoot` is executed before the DOM is initialized and `onReady` when the DOM is parsed.You can also call functions from your own plugin, eg. for a better enable/disable compatibility:
```js
onEnable() { this.onLoad(); }
```### 🧩 API
Stremio's web source uses [angular directives](https://www.w3schools.com/angular/angular_ref_directives.asp) behind the scenes, you can use Plain JS or make use of Stremio Root functions exported by BetterStremio (eg. `BetterStremio.StremioRoot`).
When developing plugins you might need to store/read data or interact with Stremio libs and resources. Here are all default loaded APIs for BetterStremio:| Mod | Calls | Description |
| --- | ----- | ----------- |
| **BetterStremio** | `host`
`version`
`errors` | Basic Information variables
| **BetterStremio.Data** | `store: (plugin, key, value)`
`read: (plugin, key)`
`delete: (plugin, key)` | Read/Store information from storage |
| **BetterStremio.Plugins** | `enable: (plugin)`
`disable: (plugin)`
`reload: ()` | Used internally to control plugin states |
| **BetterStremio.Themes** | `enable: (theme)`
`disable: (theme)`
`reload: ()` | Used internally to control theme states |
| **BetterStremio.Internal** | `fetch: (route='/', async=true)`
`update: (filename, sourceUrl)`
`reloadInfo: ()`
`enabledPlugins`
`enabledThemes`
`enabledThemes`
`plugins`
`themes` | Required functions and variables for BetterStremio loader to handle plugins, themes and autoupdates |
| **BetterStremio.Toasts** | `error(title, desc, opts)`
`info(title, desc, opts)`
`success(title, desc, opts)`
`warning(title, desc, opts)` | Toasts notification lib used by Stremio
| **BetterStremio.StremioRoot** | Read on DevTools for all states and functions | Used by Stremio's Angular client to control inner states
| **BetterStremio.Player** | Read on DevTools for all states and functions | Video Player used by Stremio.
| **BetterStremio.Sharing** | Read on DevTools for all states and functions | Stremio's sharing module.
| **BetterStremio.Modules** | Read on DevTools for all states and functions | All loaded modules.
| **BetterStremio.Scopes** | Read on DevTools for all states and functions | Stremio scopes from controllers (updates once controller is open).If you need to use any other libraries or modules from Stremio (metadata, subtitles, windowManager), use the function sample below to import them.
```js
stremioApp.run([/* libs... */, function (/* callback modules */) => {
/* Your code */
}])
```For further information see examples of `BetterStremio.loader.js` or dive into `blob.js` on Developer Tools to make use of the source code, eg:
![Stremio blob.js from Network Page](https://github.com/MateusAquino/BetterStremio/assets/16140783/3e957108-2c73-452f-b9f4-f9a983a80627)
## 🛠️ TODOs:
- [x] Plugin & Theme loader
- [x] Auto-update for BetterStremio loader
- [x] Interface for plugins (stremio internals & storage)
- [x] Sample plugin & theme
- [x] Windows installer
- [ ] MacOS installer
- [ ] Linux installer
- [ ] Check for updates on plugins & themes (manual)
- [ ] Internationalization## 🤝 Contribute
This repository is currently available for contributions. If you'd like to help here are more advanced things to know about how BetterStremio works:
1. The installer patches Stremio's **server.js** file with **patch.js**, updating some routes:
- `GET /betterstremio/`: Get information about BetterStremio's patch version, path, installed plugins and themes.
- `GET /betterstremio/folder`: Open plugins/themes folder on user's file explorer.
- `GET /betterstremio/src/:path`: Static sharing of files on BetterStremio's folder.
- `POST /betterstremio/update/:path?from=URL`: Replaces a file on BetterStremio's folder with the raw content read from the URL for updates.
- `GET /`: Patched Stremio version, it read contents from "app.strem.io/shell-v4.4" as usual but injects BetterStremio's loader.
2. Patch.js has to use **__webpack_require__** from server.js webpack's build, therefore module ids are being fetched from **__webpack_require__.m**.
3. Patching insert these routes into `server.js` and creates a shortcut with two arguments for Stremio: `--development` and `--streaming-server` (see: [stremio/stremio-shell](https://github.com/stremio/stremio-shell))
4. BetterStremio loader will automatically update itself on next load (or past 24h) when **BetterStremio.version** is changed in this repository.
5. If you want to contribute or develop plugins & themes, you can also run stremio locally @ `http://localhost:11470` to access Developer Tools.