Spaces:
Build error
Build error
implement app
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .env.sample +553 -0
- .gitattributes +2 -0
- .github/FUNDING.yml +4 -0
- .github/ISSUE_TEMPLATE/bug_report.yml +107 -0
- .github/ISSUE_TEMPLATE/config.yml +6 -0
- .github/ISSUE_TEMPLATE/feature_request.yml +39 -0
- .github/workflows/build.yml +27 -0
- .github/workflows/deploy-docker.yml +197 -0
- .github/workflows/nightly.yml +64 -0
- .github/workflows/release.yml +31 -0
- .gitignore +10 -0
- .prettierrc +7 -0
- .release-please-manifest.json +3 -0
- .vscode/launch.json +16 -0
- .vscode/settings.json +4 -0
- CHANGELOG.md +665 -0
- CONFIGURING.md +45 -0
- Dockerfile +58 -0
- LICENSE +21 -0
- README.md +155 -9
- compose.yaml +17 -0
- fetch-proxy.js +103 -0
- nginx.conf +234 -0
- package-lock.json +0 -0
- package.json +35 -0
- packages/addon/package.json +25 -0
- packages/addon/src/addon.ts +1416 -0
- packages/addon/src/config.ts +537 -0
- packages/addon/src/index.ts +4 -0
- packages/addon/src/manifest.ts +37 -0
- packages/addon/src/responses.ts +29 -0
- packages/addon/src/server.ts +645 -0
- packages/addon/tsconfig.json +22 -0
- packages/cloudflare-loadbalancer/COMPARISON.md +67 -0
- packages/cloudflare-loadbalancer/README.md +70 -0
- packages/cloudflare-loadbalancer/deploy.sh +17 -0
- packages/cloudflare-loadbalancer/package.json +19 -0
- packages/cloudflare-loadbalancer/src/index.ts +260 -0
- packages/cloudflare-loadbalancer/src/test.ts +149 -0
- packages/cloudflare-loadbalancer/tsconfig.json +30 -0
- packages/cloudflare-loadbalancer/wrangler.toml +28 -0
- packages/cloudflare-worker/package.json +21 -0
- packages/cloudflare-worker/src/index.ts +215 -0
- packages/cloudflare-worker/tsconfig.json +48 -0
- packages/cloudflare-worker/worker-configuration.d.ts +5 -0
- packages/cloudflare-worker/wrangler.toml +138 -0
- packages/core/package.json +33 -0
- packages/core/src/db/db.ts +230 -0
- packages/core/src/db/index.ts +4 -0
- packages/core/src/db/queue.ts +58 -0
.env.sample
ADDED
@@ -0,0 +1,553 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ==============================================================================
|
2 |
+
# ESSENTIAL ADDON SETUP
|
3 |
+
# ==============================================================================
|
4 |
+
# These are the most important settings you'll need to configure.
|
5 |
+
|
6 |
+
# --- Addon Identification ---
|
7 |
+
# Descriptive name for your addon instance.
|
8 |
+
ADDON_NAME="AIOStreams"
|
9 |
+
# Unique identifier for your addon.
|
10 |
+
ADDON_ID="aiostreams.viren070.com"
|
11 |
+
|
12 |
+
# --- Network Configuration ---
|
13 |
+
# The port on which the addon will listen.
|
14 |
+
# Default: 3000
|
15 |
+
PORT=3000
|
16 |
+
|
17 |
+
# The base URL of your addon. Highly recommended for proper functioning.
|
18 |
+
# Used for generating installation URLs and identifying self-scraping.
|
19 |
+
# Example: https://aiostreams.yourdomain.com
|
20 |
+
BASE_URL=
|
21 |
+
|
22 |
+
# --- Security ---
|
23 |
+
# CRITICAL: Secret key for encrypting addon configuration.
|
24 |
+
# MUST be a 64-character hex string.
|
25 |
+
# Generate one using:
|
26 |
+
# Linux/macOS: openssl rand -hex 32
|
27 |
+
# Windows (PowerShell): -join ((0..31) | ForEach-Object { '{0:x2}' -f (Get-Random -Minimum 0 -Maximum 255) })
|
28 |
+
# Or: [System.Guid]::NewGuid().ToString("N") + [System.Guid]::NewGuid().ToString("N") (ensure it's 64 chars)
|
29 |
+
SECRET_KEY=
|
30 |
+
|
31 |
+
# API key to protect your addon installation and usage.
|
32 |
+
# Leave empty to disable password protection.
|
33 |
+
# Can be any string.
|
34 |
+
ADDON_PASSWORD=
|
35 |
+
|
36 |
+
# --- Database ---
|
37 |
+
# REQUIRED: The database URI for storing addon configuration.
|
38 |
+
# Supports SQLite (simplest) or PostgreSQL.
|
39 |
+
#
|
40 |
+
# SQLite example (stores data in a file):
|
41 |
+
# DATABASE_URI=sqlite://./data/db.sqlite
|
42 |
+
# (You can change './data/db.sqlite' to your preferred path)
|
43 |
+
#
|
44 |
+
# PostgreSQL example:
|
45 |
+
# DATABASE_URI=postgres://username:password@host:port/database_name
|
46 |
+
# (e.g., postgresql://postgres:password@localhost:5432/aiostreams)
|
47 |
+
DATABASE_URI=sqlite://./data/db.sqlite
|
48 |
+
|
49 |
+
|
50 |
+
# ==============================================================================
|
51 |
+
# DEBRID & OTHER SERVICE API KEYS
|
52 |
+
# ==============================================================================
|
53 |
+
|
54 |
+
# Provide a default TMDB access token to be used for the Title Matching filter if a user does not provide any.
|
55 |
+
TMDB_ACCESS_TOKEN=
|
56 |
+
|
57 |
+
# Configure API keys for debrid services and others you plan to use.
|
58 |
+
# 'DEFAULT_' values are pre-filled in the user's config page.
|
59 |
+
# 'FORCED_' values override user settings and hide the option.
|
60 |
+
|
61 |
+
# --- Real-Debrid ---
|
62 |
+
DEFAULT_REALDEBRID_API_KEY=
|
63 |
+
FORCED_REALDEBRID_API_KEY=
|
64 |
+
|
65 |
+
# --- AllDebrid ---
|
66 |
+
DEFAULT_ALLDEBRID_API_KEY=
|
67 |
+
FORCED_ALLDEBRID_API_KEY=
|
68 |
+
|
69 |
+
# --- Premiumize ---
|
70 |
+
DEFAULT_PREMIUMIZE_API_KEY=
|
71 |
+
FORCED_PREMIUMIZE_API_KEY=
|
72 |
+
|
73 |
+
# --- Debrid-Link ---
|
74 |
+
DEFAULT_DEBRIDLINK_API_KEY=
|
75 |
+
FORCED_DEBRIDLINK_API_KEY=
|
76 |
+
|
77 |
+
# --- Torbox ---
|
78 |
+
DEFAULT_TORBOX_API_KEY=
|
79 |
+
FORCED_TORBOX_API_KEY=
|
80 |
+
|
81 |
+
# --- OffCloud ---
|
82 |
+
DEFAULT_OFFCLOUD_API_KEY=
|
83 |
+
FORCED_OFFCLOUD_API_KEY=
|
84 |
+
DEFAULT_OFFCLOUD_EMAIL=
|
85 |
+
FORCED_OFFCLOUD_EMAIL=
|
86 |
+
DEFAULT_OFFCLOUD_PASSWORD=
|
87 |
+
FORCED_OFFCLOUD_PASSWORD=
|
88 |
+
|
89 |
+
# --- Put.io ---
|
90 |
+
DEFAULT_PUTIO_CLIENT_ID=
|
91 |
+
FORCED_PUTIO_CLIENT_ID=
|
92 |
+
DEFAULT_PUTIO_CLIENT_SECRET=
|
93 |
+
FORCED_PUTIO_CLIENT_SECRET=
|
94 |
+
|
95 |
+
# --- EasyNews ---
|
96 |
+
DEFAULT_EASYNEWS_USERNAME=
|
97 |
+
FORCED_EASYNEWS_USERNAME=
|
98 |
+
DEFAULT_EASYNEWS_PASSWORD=
|
99 |
+
FORCED_EASYNEWS_PASSWORD=
|
100 |
+
|
101 |
+
# --- EasyDebrid ---
|
102 |
+
DEFAULT_EASYDEBRID_API_KEY=
|
103 |
+
FORCED_EASYDEBRID_API_KEY=
|
104 |
+
|
105 |
+
# --- PikPak ---
|
106 |
+
DEFAULT_PIKPAK_EMAIL=
|
107 |
+
FORCED_PIKPAK_EMAIL=
|
108 |
+
DEFAULT_PIKPAK_PASSWORD=
|
109 |
+
FORCED_PIKPAK_PASSWORD=
|
110 |
+
|
111 |
+
# --- Seedr ---
|
112 |
+
DEFAULT_SEEDR_ENCODED_TOKEN=
|
113 |
+
FORCED_SEEDR_ENCODED_TOKEN=
|
114 |
+
|
115 |
+
|
116 |
+
# ==============================================================================
|
117 |
+
# CUSTOMIZATION & ACCESS CONTROL
|
118 |
+
# ==============================================================================
|
119 |
+
|
120 |
+
# --- Custom HTML ---
|
121 |
+
# Display custom HTML at the top of the addon's configuration page.
|
122 |
+
# Example: CUSTOM_HTML="<div>Welcome to my AIOStreams!</div>"
|
123 |
+
CUSTOM_HTML=
|
124 |
+
|
125 |
+
# --- Trusted Users ---
|
126 |
+
# Comma-separated list of trusted UUIDs.
|
127 |
+
# Trusted users can access features like regex filters if REGEX_FILTER_ACCESS is 'trusted'.
|
128 |
+
# Example: TRUSTED_UUIDS=ae32f456-1234-5678-9012-345678901234,another-uuid-here
|
129 |
+
# TRUSTED_UUIDS=
|
130 |
+
|
131 |
+
# --- Regex Filter Access ---
|
132 |
+
# Controls who can use regex filters.
|
133 |
+
# 'none': No one can use regex filters.
|
134 |
+
# 'trusted': Only users listed in TRUSTED_UUIDS.
|
135 |
+
# 'all': All users (only recommended if ADDON_PASSWORD is set).
|
136 |
+
# Default: trusted
|
137 |
+
REGEX_FILTER_ACCESS=trusted
|
138 |
+
|
139 |
+
# --- Aliased Configurations (Vanity URLs) ---
|
140 |
+
# Create shorter, memorable installation URLs.
|
141 |
+
# Format: aliasName1:uuid1:encryptedPassword1,aliasName2:uuid2:encryptedPassword2
|
142 |
+
# Users can then access the addon via /stremio/u/aliasName/manifest.json
|
143 |
+
# ALIASED_CONFIGURATIONS=
|
144 |
+
|
145 |
+
# ==============================================================================
|
146 |
+
# CACHE CONFIGURATION
|
147 |
+
# ==============================================================================
|
148 |
+
|
149 |
+
# --- Default maximum cache size ----
|
150 |
+
# The maximum number of items that can be held in a given cache instance, if not overriden by a specific cache instance
|
151 |
+
DEFAULT_MAX_CACHE_SIZE=100000
|
152 |
+
|
153 |
+
# --- Proxy IP TTL (StremThru/MediaFlow Proxy)
|
154 |
+
# The Time-To-Live (in seconds) of items in the Public IP cache.
|
155 |
+
# Set to -1 to disable caching
|
156 |
+
PROXY_IP_CACHE_TTL=900
|
157 |
+
|
158 |
+
# --- Addon Resource Caching ---
|
159 |
+
# Control the Caching of resources fetched from other addons
|
160 |
+
# Set to -1 to disable caching.
|
161 |
+
MANIFEST_CACHE_TTL=300
|
162 |
+
SUBTITLE_CACHE_TTL=300
|
163 |
+
STREAM_CACHE_TTL=-1
|
164 |
+
CATALOG_CACHE_TTL=300
|
165 |
+
META_CACHE_TTL=300
|
166 |
+
ADDON_CATALOG_CACHE_TTL=300
|
167 |
+
|
168 |
+
|
169 |
+
# --- RPDB API Key Validation Caching ---
|
170 |
+
# Control how long a valid API key check is cached for
|
171 |
+
# Default: 7 days
|
172 |
+
RPDB_API_KEY_VALIDITY_CACHE_TTL=604800
|
173 |
+
|
174 |
+
# ==============================================================================
|
175 |
+
# FEATURE CONTROL
|
176 |
+
# ==============================================================================
|
177 |
+
# Enable or disable specific addon features.
|
178 |
+
|
179 |
+
# --- Self-Scraping ---
|
180 |
+
# Prevent this AIOStreams instance from being added as an addon to itself.
|
181 |
+
# Default: true
|
182 |
+
DISABLE_SELF_SCRAPING=true
|
183 |
+
|
184 |
+
# --- Disabled Hosts ---
|
185 |
+
# Prevent certain hostnames from being added as addons.
|
186 |
+
# Format: host1:reason1,host2:reason2
|
187 |
+
# Example: DISABLED_HOSTS=torrentio.strem.fun:Blocked by Torrentio
|
188 |
+
# DISABLED_HOSTS=
|
189 |
+
|
190 |
+
# --- Disabled Addons (Marketplace) ---
|
191 |
+
# Disable specific addons from appearing in the marketplace.
|
192 |
+
# See https://github.com/Viren070/AIOStreams/blob/main/packages/core/src/utils/marketplace.ts for IDs.
|
193 |
+
# Format: addonID1:reason1,addonID2:reason2
|
194 |
+
# Example: DISABLED_ADDONS=torrentio:Blocked by Torrentio
|
195 |
+
# DISABLED_ADDONS=
|
196 |
+
|
197 |
+
# --- Disabled Services (Configuration Page) ---
|
198 |
+
# Hide certain services (e.g., debrid services) from the configuration page.
|
199 |
+
# Format: service1:reason1,service2:reason2
|
200 |
+
# Example: DISABLED_SERVICES=realdebrid:Not available on this instance
|
201 |
+
# DISABLED_SERVICES=
|
202 |
+
|
203 |
+
|
204 |
+
# ==============================================================================
|
205 |
+
# LOGGING
|
206 |
+
# ==============================================================================
|
207 |
+
|
208 |
+
# --- Log Level ---
|
209 |
+
# Set the verbosity of logs. Options: "error", "warn", "info", "http", "verbose","debug", "silly"
|
210 |
+
# Default: info
|
211 |
+
LOG_LEVEL=http
|
212 |
+
|
213 |
+
# --- Log Format ---
|
214 |
+
# Output logs in "json" or "text" format.
|
215 |
+
# Default: text
|
216 |
+
LOG_FORMAT=text
|
217 |
+
|
218 |
+
# --- Log Sensitive Information ---
|
219 |
+
# Whether to include potentially sensitive info (like API keys) in logs.
|
220 |
+
# Useful for debugging, but disable for production if concerned.
|
221 |
+
# Default: true
|
222 |
+
LOG_SENSITIVE_INFO=true
|
223 |
+
|
224 |
+
# --- Log Timezone ---
|
225 |
+
# Adjust the timezone used for logging
|
226 |
+
# e.g. Europe/Paris, America/New_York
|
227 |
+
LOG_TIMEZONE=Etc/UTC
|
228 |
+
|
229 |
+
|
230 |
+
# ==============================================================================
|
231 |
+
# PROXY FOR OUTGOING ADDON REQUESTS (Torrentio, etc.)
|
232 |
+
# ==============================================================================
|
233 |
+
# Configure a proxy for requests made *by* this AIOStreams instance *to* other addons (e.g., Torrentio).
|
234 |
+
# Useful if your server's IP is blocked by an upstream service.
|
235 |
+
|
236 |
+
# --- Addon Proxy URL ---
|
237 |
+
# The proxy URL to use for all requests to upstream addons.
|
238 |
+
# Example: ADDON_PROXY=http://warp:1080 (using https://github.com/cmj2002/warp-docker)
|
239 |
+
# ADDON_PROXY=
|
240 |
+
|
241 |
+
# --- Addon Proxy Configuration ---
|
242 |
+
# Optionally, specify which domains to proxy.
|
243 |
+
# Comma-separated list of rules: domain_pattern:boolean. Later rules have higher priority.
|
244 |
+
# Wildcards (*) can be used.
|
245 |
+
# Example: ADDON_PROXY_CONFIG="*:false,*.strem.fun:true" (only proxy *.strem.fun domains)
|
246 |
+
# ADDON_PROXY_CONFIG=
|
247 |
+
|
248 |
+
|
249 |
+
# ==============================================================================
|
250 |
+
# DEFAULT/FORCED STREAM PROXY (MediaFlow, StremThru)
|
251 |
+
# ==============================================================================
|
252 |
+
# Configure how AIOStreams handles stream proxies like MediaFlow or StremThru for playback.
|
253 |
+
# 'DEFAULT_' values are pre-filled. 'FORCE_' values override user settings.
|
254 |
+
|
255 |
+
# --- Stream Proxy Enabled ---
|
256 |
+
# DEFAULT_PROXY_ENABLED=true # Default state for enabling a stream proxy.
|
257 |
+
# FORCE_PROXY_ENABLED=false # Force stream proxy on/off for all users.
|
258 |
+
|
259 |
+
# --- Stream Proxy ID ---
|
260 |
+
# 'mediaflow' or 'stremthru'
|
261 |
+
DEFAULT_PROXY_ID=mediaflow
|
262 |
+
# FORCE_PROXY_ID=
|
263 |
+
|
264 |
+
# --- Stream Proxy URL ---
|
265 |
+
# URL of your MediaFlow or StremThru instance.
|
266 |
+
# DEFAULT_PROXY_URL=
|
267 |
+
# FORCE_PROXY_URL=
|
268 |
+
|
269 |
+
# --- Stream Proxy Credentials ---
|
270 |
+
# Format: username:password
|
271 |
+
# DEFAULT_PROXY_CREDENTIALS=
|
272 |
+
# FORCE_PROXY_CREDENTIALS=
|
273 |
+
|
274 |
+
# --- Stream Proxy Public IP ---
|
275 |
+
# Public IP for the proxy, if needed.
|
276 |
+
# DEFAULT_PROXY_PUBLIC_IP=
|
277 |
+
# FORCE_PROXY_PUBLIC_IP=
|
278 |
+
|
279 |
+
# --- Proxied Services ---
|
280 |
+
# Comma-separated list of services whose streams should be proxied (e.g., realdebrid,alldebrid).
|
281 |
+
# DEFAULT_PROXY_PROXIED_SERVICES=
|
282 |
+
# FORCE_PROXY_PROXIED_SERVICES=
|
283 |
+
|
284 |
+
# --- Disable Proxied Addons Feature ---
|
285 |
+
# If true, it disables the 'Proxied Addons' option.
|
286 |
+
FORCE_PROXY_DISABLE_PROXIED_ADDONS=false
|
287 |
+
|
288 |
+
# --- Encrypt Streaming URLs ---
|
289 |
+
# Encrypt MediaFlow/StremThru URLs for better compatibility with external players.
|
290 |
+
ENCRYPT_MEDIAFLOW_URLS=true
|
291 |
+
ENCRYPT_STREMTHRU_URLS=true
|
292 |
+
|
293 |
+
|
294 |
+
# --- Forced Public proxy URL adjustments ----
|
295 |
+
# If you'd like to force some adjustments to be made to the streaming urls generated by either proxy, you can do that here.
|
296 |
+
# This is useful when you want to use a local url for requests but have AIOStreams force the urls to use a specific host, port, and protocol.
|
297 |
+
# FORCE_PUBLIC_PROXY_HOST=
|
298 |
+
# FORCE_PUBLIC_PROXY_PORT=
|
299 |
+
# FORCE_PUBLIC_PROXY_PROTOCOL=
|
300 |
+
|
301 |
+
|
302 |
+
# ==============================================================================
|
303 |
+
# ADVANCED CONFIGURATION & LIMITS
|
304 |
+
# ==============================================================================
|
305 |
+
|
306 |
+
# --- General Default Timeout ---
|
307 |
+
# Default timeout in milliseconds for all requests if not overridden by a specific timeout.
|
308 |
+
# Default: 15000 (15 seconds)
|
309 |
+
DEFAULT_TIMEOUT=15000
|
310 |
+
|
311 |
+
# --- Configuration Limits ---
|
312 |
+
# Maximum number of addons allowed per AIOStreams configuration.
|
313 |
+
MAX_ADDONS=15
|
314 |
+
# Maximum number of groups allowed per AIOStreams configuration
|
315 |
+
MAX_GROUPS=20
|
316 |
+
# Maximum number of keyword filters per AIOStreams configuration.
|
317 |
+
MAX_KEYWORD_FILTERS=30
|
318 |
+
# Maximum number of condition filters per AIOStreams configuration
|
319 |
+
MAX_CONDITION_FILTERS=30
|
320 |
+
# Maximum timeout (ms) an addon can be set to via override.
|
321 |
+
MAX_TIMEOUT=50000
|
322 |
+
# Minimum timeout (ms) an addon can be set to via override.
|
323 |
+
MIN_TIMEOUT=1000
|
324 |
+
|
325 |
+
|
326 |
+
# ==============================================================================
|
327 |
+
# RATE LIMIT CONFIGURATION
|
328 |
+
# ==============================================================================
|
329 |
+
# Configure rate limits to prevent abuse. Typically, defaults are fine.
|
330 |
+
|
331 |
+
# --- Disable Rate Limits ---
|
332 |
+
# Set to true to disable all rate limits (NOT RECOMMENDED).
|
333 |
+
# Default: false
|
334 |
+
DISABLE_RATE_LIMITS=false
|
335 |
+
|
336 |
+
# Window and Max requests refer to the maximum number of requests a user can make within a specific timeframe
|
337 |
+
|
338 |
+
# --- Static File Serving ---
|
339 |
+
STATIC_RATE_LIMIT_WINDOW=5
|
340 |
+
STATIC_RATE_LIMIT_MAX_REQUESTS=75
|
341 |
+
|
342 |
+
# --- User API ---
|
343 |
+
USER_API_RATE_LIMIT_WINDOW=5
|
344 |
+
USER_API_RATE_LIMIT_MAX_REQUESTS=5
|
345 |
+
|
346 |
+
# --- Stream API ---
|
347 |
+
STREAM_API_RATE_LIMIT_WINDOW=5
|
348 |
+
STREAM_API_RATE_LIMIT_MAX_REQUESTS=10
|
349 |
+
|
350 |
+
# --- Format API ---
|
351 |
+
FORMAT_API_RATE_LIMIT_WINDOW=5
|
352 |
+
FORMAT_API_RATE_LIMIT_MAX_REQUESTS=30
|
353 |
+
|
354 |
+
# --- Catalog API ---
|
355 |
+
CATALOG_API_RATE_LIMIT_WINDOW=5
|
356 |
+
CATALOG_API_RATE_LIMIT_MAX_REQUESTS=5
|
357 |
+
|
358 |
+
# --- Stremio Stream ---
|
359 |
+
STREMIO_STREAM_RATE_LIMIT_WINDOW=15
|
360 |
+
STREMIO_STREAM_RATE_LIMIT_MAX_REQUESTS=10
|
361 |
+
|
362 |
+
# --- Stremio Catalog ---
|
363 |
+
STREMIO_CATALOG_RATE_LIMIT_WINDOW=5
|
364 |
+
STREMIO_CATALOG_RATE_LIMIT_MAX_REQUESTS=30
|
365 |
+
|
366 |
+
# --- Stremio Manifest ---
|
367 |
+
STREMIO_MANIFEST_RATE_LIMIT_WINDOW=5
|
368 |
+
STREMIO_MANIFEST_RATE_LIMIT_MAX_REQUESTS=5
|
369 |
+
|
370 |
+
# --- Stremio Subtitle ---
|
371 |
+
STREMIO_SUBTITLE_RATE_LIMIT_WINDOW=5
|
372 |
+
STREMIO_SUBTITLE_RATE_LIMIT_MAX_REQUESTS=10
|
373 |
+
|
374 |
+
# --- Stremio Meta ---
|
375 |
+
STREMIO_META_RATE_LIMIT_WINDOW=5
|
376 |
+
STREMIO_META_RATE_LIMIT_MAX_REQUESTS=15
|
377 |
+
|
378 |
+
|
379 |
+
# ==============================================================================
|
380 |
+
# INACTIVE USER PRUNING
|
381 |
+
# ==============================================================================
|
382 |
+
# Automatically prune (delete) inactive user configurations.
|
383 |
+
|
384 |
+
# --- Prune Interval ---
|
385 |
+
# How often to check for inactive users, in seconds.
|
386 |
+
# Default: 86400 (1 day)
|
387 |
+
PRUNE_INTERVAL=86400
|
388 |
+
|
389 |
+
# --- Prune Max Inactivity Days ---
|
390 |
+
# Maximum days of inactivity before a user's configuration is pruned.
|
391 |
+
# Set to -1 to disable
|
392 |
+
# Default: -1
|
393 |
+
PRUNE_MAX_DAYS=-1
|
394 |
+
|
395 |
+
|
396 |
+
# ==============================================================================
|
397 |
+
# EXTERNAL ADDON SERVICE URLs & TIMEOUTS
|
398 |
+
# ==============================================================================
|
399 |
+
# URLs and default timeouts for various external Stremio addons that AIOStreams can integrate with.
|
400 |
+
# Change these if you use self-hosted versions or if defaults become outdated.
|
401 |
+
|
402 |
+
# ----------- COMET ------------
|
403 |
+
COMET_URL=https://comet.elfhosted.com/
|
404 |
+
# DEFAULT_COMET_TIMEOUT=
|
405 |
+
# Advanced: Override Comet hostname/port/protocol if COMET_URL is internal but needs to be public-facing.
|
406 |
+
# Only uncomment and set if needed. Usually, leave these commented.
|
407 |
+
# FORCE_COMET_HOSTNAME=
|
408 |
+
# FORCE_COMET_PORT=
|
409 |
+
# FORCE_COMET_PROTOCOL= # e.g., https
|
410 |
+
|
411 |
+
# ----------- MEDIAFUSION ------------
|
412 |
+
MEDIAFUSION_URL=https://mediafusion.elfhosted.com/
|
413 |
+
# DEFAULT_MEDIAFUSION_TIMEOUT=
|
414 |
+
MEDIAFUSION_CONFIG_TIMEOUT=5000 # Timeout (ms) for /encrypt-user-data endpoint.
|
415 |
+
# API Password for self-hosted MediaFusion (for auto-configuration).
|
416 |
+
# MEDIAFUSION_API_PASSWORD=
|
417 |
+
|
418 |
+
# ----------- JACKETTIO -------------
|
419 |
+
JACKETTIO_URL=https://jackettio.elfhosted.com/
|
420 |
+
# DEFAULT_JACKETTIO_TIMEOUT=
|
421 |
+
# Default indexers for auto-configuration with Jackettio.
|
422 |
+
DEFAULT_JACKETTIO_INDEXERS='["bitsearch", "eztv", "thepiratebay", "therarbg", "yts"]'
|
423 |
+
# Default StremThru URL used by Jackettio.
|
424 |
+
DEFAULT_JACKETTIO_STREMTHRU_URL=https://stremthru.13377001.xyz
|
425 |
+
# Self-hosted StremThru for Jackettio:
|
426 |
+
# DEFAULT_JACKETTIO_STREMTHRU_URL=http://stremthru:8080
|
427 |
+
# Advanced: Override Jackettio hostname/port/protocol (similar to Comet).
|
428 |
+
# FORCE_JACKETTIO_HOSTNAME=
|
429 |
+
# FORCE_JACKETTIO_PORT=
|
430 |
+
# FORCE_JACKETTIO_PROTOCOL=
|
431 |
+
|
432 |
+
# --------- STREMTHRU-STORE ---------
|
433 |
+
STREMTHRU_STORE_URL=https://stremthru.elfhosted.com/stremio/store/
|
434 |
+
# DEFAULT_STREMTHRU_STORE_TIMEOUT=
|
435 |
+
# Advanced: Override StremThru Store hostname/port/protocol (similar to Comet).
|
436 |
+
# FORCE_STREMTHRU_STORE_HOST=
|
437 |
+
# FORCE_STREMTHRU_STORE_PORT=
|
438 |
+
# FORCE_STREMTHRU_STORE_PROTOCOL=
|
439 |
+
# --------- STREMTHRU-TORZ -----
|
440 |
+
STREMTHRU_TORZ_URL=https://stremthru.elfhosted.com/stremio/torz/
|
441 |
+
# DEFAULT_STREMTHRU_TORZ_TIMEOUT=
|
442 |
+
# Advanced: Override StremThru Torz hostname/port/protocol (similar to Comet).
|
443 |
+
# FORCE_STREMTHRU_TORZ_HOST=
|
444 |
+
# FORCE_STREMTHRU_TORZ_PORT=
|
445 |
+
# FORCE_STREMTHRU_TORZ_PROTOCOL=
|
446 |
+
|
447 |
+
# --------- EASYNEWS+ ADDON ---------
|
448 |
+
EASYNEWS_PLUS_URL=https://b89262c192b0-stremio-easynews-addon.baby-beamup.club/
|
449 |
+
# DEFAULT_EASYNEWS_PLUS_TIMEOUT=
|
450 |
+
|
451 |
+
# -------- EASYNEWS++ ADDON ---------
|
452 |
+
EASYNEWS_PLUS_PLUS_URL=https://easynews-cloudflare-worker.jqrw92fchz.workers.dev/
|
453 |
+
# DEFAULT_EASYNEWS_PLUS_PLUS_TIMEOUT=
|
454 |
+
|
455 |
+
# --------- STREAMFUSION ---------
|
456 |
+
STREAMFUSION_URL=https://stream-fusion.stremiofr.com/
|
457 |
+
# DEFAULT_STREAMFUSION_TIMEOUT=
|
458 |
+
|
459 |
+
# --------- MARVEL UNIVERSE ---------
|
460 |
+
MARVEL_UNIVERSE_URL=https://addon-marvel.onrender.com/
|
461 |
+
# DEFAULT_MARVEL_UNIVERSE_TIMEOUT=
|
462 |
+
|
463 |
+
# --------- DC UNIVERSE ---------
|
464 |
+
DC_UNIVERSE_URL=https://addon-dc-cq85.onrender.com/
|
465 |
+
# DEFAULT_DC_UNIVERSE_TIMEOUT=
|
466 |
+
|
467 |
+
# --------- STAR WARS UNIVERSE ---------
|
468 |
+
STAR_WARS_UNIVERSE_URL=https://addon-star-wars-u9e3.onrender.com/
|
469 |
+
# DEFAULT_STAR_WARS_UNIVERSE_TIMEOUT=
|
470 |
+
|
471 |
+
# --------- ANIME KITSU ---------
|
472 |
+
ANIME_KITSU_URL=https://anime-kitsu.strem.fun/
|
473 |
+
# DEFAULT_ANIME_KITSU_TIMEOUT=
|
474 |
+
|
475 |
+
# --------- NUVIOSTREAMS ---------
|
476 |
+
NUVIOSTREAMS_URL=https://nuviostreams.hayd.uk/
|
477 |
+
# DEFAULT_NUVIOSTREAMS_TIMEOUT=
|
478 |
+
|
479 |
+
# --------- TMDB COLLECTIONS ---------
|
480 |
+
TMDB_COLLECTIONS_URL=https://61ab9c85a149-tmdb-collections.baby-beamup.club/
|
481 |
+
# DEFAULT_TMDB_COLLECTIONS_TIMEOUT=
|
482 |
+
|
483 |
+
# ----------- TORRENTIO -------------
|
484 |
+
TORRENTIO_URL=https://torrentio.strem.fun/
|
485 |
+
# DEFAULT_TORRENTIO_TIMEOUT=
|
486 |
+
|
487 |
+
# -------- ORION STREMIO ADDON --------
|
488 |
+
ORION_STREMIO_ADDON_URL=https://5a0d1888fa64-orion.baby-beamup.club/
|
489 |
+
# DEFAULT_ORION_STREMIO_ADDON_TIMEOUT=
|
490 |
+
|
491 |
+
# ------------ PEERFLIX --------------
|
492 |
+
PEERFLIX_URL=https://peerflix-addon.onrender.com/
|
493 |
+
# DEFAULT_PEERFLIX_TIMEOUT=
|
494 |
+
|
495 |
+
# -------- TORBOX STREMIO ADDON --------
|
496 |
+
TORBOX_STREMIO_URL=https://stremio.torbox.app/
|
497 |
+
# DEFAULT_TORBOX_STREMIO_TIMEOUT=
|
498 |
+
|
499 |
+
# -------- EASYNEWS ADDON (Standalone) --------
|
500 |
+
EASYNEWS_URL=https://ea627ddf0ee7-easynews.baby-beamup.club/
|
501 |
+
# DEFAULT_EASYNEWS_TIMEOUT=
|
502 |
+
|
503 |
+
# ------------ DEBRIDIO -----------
|
504 |
+
DEBRIDIO_URL=https://addon.debridio.com/
|
505 |
+
# DEFAULT_DEBRIDIO_TIMEOUT=
|
506 |
+
|
507 |
+
# ------------ DEBRIDIO TVDB ------------
|
508 |
+
DEBRIDIO_TVDB_URL=https://tvdb-addon.debridio.com/
|
509 |
+
# DEFAULT_DEBRIDIO_TVDB_TIMEOUT=
|
510 |
+
|
511 |
+
# ------------ DEBRIDIO TMDB ------------
|
512 |
+
DEBRIDIO_TMDB_URL=https://tmdb-addon.debridio.com/
|
513 |
+
# DEFAULT_DEBRIDIO_TMDB_TIMEOUT=
|
514 |
+
|
515 |
+
# ------------ DEBRIDIO TV ------------
|
516 |
+
DEBRIDIO_TV_URL=https://tv-addon.debridio.com/
|
517 |
+
# DEFAULT_DEBRIDIO_TV_TIMEOUT=
|
518 |
+
|
519 |
+
# ------------ DEBRIDIO WATCHTOWER ------------
|
520 |
+
DEBRIDIO_WATCHTOWER_URL=https://wt-addon.debridio.com/
|
521 |
+
# DEFAULT_DEBRIDIO_WATCHTOWER_TIMEOUT=
|
522 |
+
|
523 |
+
# ------------ OPENSUBTITLES V3 ------------
|
524 |
+
OPENSUBTITLES_URL=https://opensubtitles-v3.strem.io/
|
525 |
+
# DEFAULT_OPENSUBTITLES_TIMEOUT=
|
526 |
+
|
527 |
+
# ------------ TORRENT CATALOGS ------------
|
528 |
+
TORRENT_CATALOGS_URL=https://torrent-catalogs.strem.fun/
|
529 |
+
# DEFAULT_TORRENT_CATALOGS_TIMEOUT=
|
530 |
+
|
531 |
+
# ------------ RPDB CATALOGS ------------
|
532 |
+
RPDB_CATALOGS_URL=https://1fe84bc728af-rpdb.baby-beamup.club/
|
533 |
+
# DEFAULT_RPDB_CATALOGS_TIMEOUT=
|
534 |
+
|
535 |
+
# ------------- DMM Cast ----------------
|
536 |
+
# DEFAULT_DMM_CAST_TIMEOUT=
|
537 |
+
|
538 |
+
# ----------- STREAMING CATALOGS ---------
|
539 |
+
STREAMING_CATALOGS_URL=https://7a82163c306e-stremio-netflix-catalog-addon.baby-beamup.club
|
540 |
+
# DEFAULT_STREAMING_CATALOGS_TIMEOUT=
|
541 |
+
|
542 |
+
# ----------- ANIME CATALOGS -----------
|
543 |
+
ANIME_CATALOGS_URL=https://1fe84bc728af-stremio-anime-catalogs.baby-beamup.club
|
544 |
+
# DEFAULT_ANIME_CATALOGS_TIMEOUT=
|
545 |
+
|
546 |
+
# ----------- DOCTOR WHO UNIVERSE -----------
|
547 |
+
DOCTOR_WHO_UNIVERSE_URL=https://new-who.onrender.com
|
548 |
+
# DEFAULT_DOCTOR_WHO_UNIVERSE_TIMEOUT=
|
549 |
+
|
550 |
+
# ----------- WEBSTREAMR -----------
|
551 |
+
WEBSTREAMR_URL=https://webstreamr.hayd.uk
|
552 |
+
# DEFAULT_WEBSTREAMR_TIMEOUT=
|
553 |
+
# ==============================================================================
|
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
37 |
+
*.ico filter=lfs diff=lfs merge=lfs -text
|
.github/FUNDING.yml
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# These are supported funding model platforms
|
2 |
+
|
3 |
+
github: Viren070
|
4 |
+
ko_fi: Viren070
|
.github/ISSUE_TEMPLATE/bug_report.yml
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Bug report
|
2 |
+
description: Report a bug you encountered
|
3 |
+
title: 'bug: '
|
4 |
+
labels:
|
5 |
+
- bug
|
6 |
+
body:
|
7 |
+
- type: dropdown
|
8 |
+
id: 'deployment'
|
9 |
+
attributes:
|
10 |
+
label: Deployment Method
|
11 |
+
description: How are you hosting the addon?
|
12 |
+
options:
|
13 |
+
- Public ElfHosted Instance
|
14 |
+
- Private ElfHosted Instance
|
15 |
+
- Cloudflare Workers
|
16 |
+
- VPS
|
17 |
+
- Other, specify at description
|
18 |
+
validations:
|
19 |
+
required: true
|
20 |
+
- type: input
|
21 |
+
id: 'addonVersion'
|
22 |
+
attributes:
|
23 |
+
label: Addon Version
|
24 |
+
description: What version of the addon are you using, or what was the commit that your deployment was built off of?
|
25 |
+
placeholder: v1.13.8
|
26 |
+
validations:
|
27 |
+
required: true
|
28 |
+
- type: dropdown
|
29 |
+
id: 'bugArea'
|
30 |
+
attributes:
|
31 |
+
label: Bug Area
|
32 |
+
description: Select what area of the addon this issue affects
|
33 |
+
options:
|
34 |
+
- Deploying
|
35 |
+
- Configuring
|
36 |
+
- Installing
|
37 |
+
- Obtaining streams.
|
38 |
+
- Playback
|
39 |
+
validations:
|
40 |
+
required: true
|
41 |
+
- type: input
|
42 |
+
id: 'deviceInfo'
|
43 |
+
attributes:
|
44 |
+
label: Device/Browser/OS/Stremio Version
|
45 |
+
description: Details about the device this issue occurs on. Leave blank if not applicable (e.g. error within addon)
|
46 |
+
placeholder: Windows on Stremio 5 Beta
|
47 |
+
- type: textarea
|
48 |
+
id: 'bugDescription'
|
49 |
+
attributes:
|
50 |
+
label: Bug Description / Steps to Reproduce
|
51 |
+
description: Precisely describe the bug you encountered and the steps to reproduce it. Avoid vague descriptions. Include relevant details - such as if you were using MediaFlow.
|
52 |
+
validations:
|
53 |
+
required: true
|
54 |
+
- type: textarea
|
55 |
+
id: 'expectedBehaviour'
|
56 |
+
attributes:
|
57 |
+
label: Expected Behavior
|
58 |
+
description: Describe what you expected to happen.
|
59 |
+
validations:
|
60 |
+
required: true
|
61 |
+
- type: textarea
|
62 |
+
id: 'configExport'
|
63 |
+
attributes:
|
64 |
+
label: Configuration Export
|
65 |
+
description: Provide an export of your configuration with credentials excluded (make sure to double check it has nothing sensitive in it like custom addon URLs or overriden URLs etc.
|
66 |
+
validations:
|
67 |
+
required: true
|
68 |
+
- type: textarea
|
69 |
+
id: 'screenshots'
|
70 |
+
attributes:
|
71 |
+
label: Screenshots
|
72 |
+
description: If applicable, add screenshots of the bug and your configuration.
|
73 |
+
- type: checkboxes
|
74 |
+
id: 'debuggingChecklist'
|
75 |
+
attributes:
|
76 |
+
label: Debugging Checklist
|
77 |
+
description: Confirm you have included at least some of the following debugging information. If you haven't, please do so before submitting the issue.
|
78 |
+
options:
|
79 |
+
- label: >-
|
80 |
+
If applicable, I have included server logs
|
81 |
+
required: false
|
82 |
+
- label: >-
|
83 |
+
If applicable, I have included MediaFlow logs
|
84 |
+
required: false
|
85 |
+
- type: checkboxes
|
86 |
+
id: 'issueChecklist'
|
87 |
+
attributes:
|
88 |
+
label: Issue Checklist
|
89 |
+
description: Confirm that you have understood and followed these requirements
|
90 |
+
options:
|
91 |
+
- label: >-
|
92 |
+
I have written a short but informative title that clearly describes the issue.
|
93 |
+
required: true
|
94 |
+
- label: >-
|
95 |
+
I have given clear and descriptive steps to reproduce the issue.
|
96 |
+
required: true
|
97 |
+
- label: >-
|
98 |
+
I have checked open and closed issues and confirmed that this is not a duplicate of another issue.
|
99 |
+
required: true
|
100 |
+
- label: >-
|
101 |
+
I have filled out all of the requested information adequately.
|
102 |
+
required: true
|
103 |
+
- label: >-
|
104 |
+
I am using the [latest version](https://github.com/Viren070/AIOStreams/releases/latest).
|
105 |
+
required: true
|
106 |
+
|
107 |
+
|
.github/ISSUE_TEMPLATE/config.yml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
blank_issues_enabled: false
|
2 |
+
contact_links:
|
3 |
+
- name: AIOStreams Community Support
|
4 |
+
url: https://github.com/Viren070/AIOStreams/discussions/categories/help
|
5 |
+
about: If you need help, create a new post here with your question.
|
6 |
+
|
.github/ISSUE_TEMPLATE/feature_request.yml
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Feature Request
|
2 |
+
description: Suggest an idea for the project
|
3 |
+
title: 'feature request: '
|
4 |
+
labels:
|
5 |
+
- feature request
|
6 |
+
body:
|
7 |
+
- type: checkboxes
|
8 |
+
id: '1'
|
9 |
+
attributes:
|
10 |
+
label: Checklist
|
11 |
+
description: >-
|
12 |
+
Please check the following before submitting a feature request. If you
|
13 |
+
are unable to check all the boxes, please provide more information in the
|
14 |
+
description.
|
15 |
+
options:
|
16 |
+
- label: >-
|
17 |
+
I checked that this feature has not been requested before
|
18 |
+
required: true
|
19 |
+
- label: >-
|
20 |
+
I checked that this feature is not in the "Not planned" list
|
21 |
+
required: true
|
22 |
+
- label: >-
|
23 |
+
This feature will benefit the majority of users
|
24 |
+
- type: textarea
|
25 |
+
id: '2'
|
26 |
+
attributes:
|
27 |
+
label: Problem Description / Use Case
|
28 |
+
description: >-
|
29 |
+
Provide a detailed description of the problem you are facing or the use case you have in mind.
|
30 |
+
validations:
|
31 |
+
required: true
|
32 |
+
- type: textarea
|
33 |
+
id: '3'
|
34 |
+
attributes:
|
35 |
+
label: Proposed Solution
|
36 |
+
description: >-
|
37 |
+
Provide a detailed description of the solution you'd like to see. If you have any ideas on how to implement the feature, please include them here.
|
38 |
+
validations:
|
39 |
+
required: true
|
.github/workflows/build.yml
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Build Addon
|
2 |
+
|
3 |
+
on:
|
4 |
+
pull_request:
|
5 |
+
branches:
|
6 |
+
- main
|
7 |
+
paths:
|
8 |
+
- 'packages/**'
|
9 |
+
- 'package-lock.json'
|
10 |
+
- 'package.json'
|
11 |
+
- 'tsconfig.json'
|
12 |
+
- 'tsconfig.base.json'
|
13 |
+
|
14 |
+
jobs:
|
15 |
+
test:
|
16 |
+
runs-on: ubuntu-latest
|
17 |
+
steps:
|
18 |
+
- uses: actions/checkout@v4
|
19 |
+
- name: Use Node.js
|
20 |
+
uses: actions/setup-node@v4
|
21 |
+
with:
|
22 |
+
node-version: '22.x'
|
23 |
+
|
24 |
+
- name: Install Dependencies
|
25 |
+
run: npm ci
|
26 |
+
- name: Build Addon
|
27 |
+
run: npm run build
|
.github/workflows/deploy-docker.yml
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Build and Deploy Docker Images
|
2 |
+
|
3 |
+
on:
|
4 |
+
workflow_dispatch:
|
5 |
+
inputs:
|
6 |
+
ref:
|
7 |
+
description: Git Ref
|
8 |
+
required: true
|
9 |
+
type: string
|
10 |
+
|
11 |
+
jobs:
|
12 |
+
build:
|
13 |
+
name: build
|
14 |
+
runs-on: ubuntu-latest
|
15 |
+
permissions:
|
16 |
+
packages: write
|
17 |
+
contents: read
|
18 |
+
steps:
|
19 |
+
- name: Checkout
|
20 |
+
uses: actions/checkout@v4
|
21 |
+
with:
|
22 |
+
fetch-depth: 0
|
23 |
+
ref: ${{inputs.ref}}
|
24 |
+
token: ${{ secrets.GITHUB_TOKEN }}
|
25 |
+
|
26 |
+
- name: Login to Docker Hub
|
27 |
+
uses: docker/login-action@v3
|
28 |
+
with:
|
29 |
+
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
30 |
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
31 |
+
|
32 |
+
- name: Login to GitHub Container Registry
|
33 |
+
uses: docker/login-action@v3
|
34 |
+
with:
|
35 |
+
registry: ghcr.io
|
36 |
+
username: ${{ github.repository_owner }}
|
37 |
+
password: ${{ secrets.GITHUB_TOKEN }}
|
38 |
+
|
39 |
+
- name: Set up QEMU
|
40 |
+
uses: docker/setup-qemu-action@v3
|
41 |
+
|
42 |
+
- name: Set up Buildx
|
43 |
+
uses: docker/setup-buildx-action@v3
|
44 |
+
|
45 |
+
- name: Calculate Image Tags
|
46 |
+
env:
|
47 |
+
INPUT_REF: ${{inputs.ref}}
|
48 |
+
run: |
|
49 |
+
declare TAGS=""
|
50 |
+
case "${INPUT_REF}" in
|
51 |
+
v[0-9]*.[0-9]*.[0-9]*)
|
52 |
+
TAGS="${INPUT_REF}"
|
53 |
+
if [[ "$(git rev-parse origin/main)" = "$(git rev-parse "${INPUT_REF}")" ]]; then
|
54 |
+
TAGS="${TAGS} latest"
|
55 |
+
fi
|
56 |
+
CHANNEL="stable"
|
57 |
+
;;
|
58 |
+
[0-9]*.[0-9]*.[0-9]*-nightly)
|
59 |
+
TAGS="${INPUT_REF} nightly"
|
60 |
+
CHANNEL="nightly"
|
61 |
+
;;
|
62 |
+
*)
|
63 |
+
echo "Invalid Input Ref: ${INPUT_REF}"
|
64 |
+
exit 1
|
65 |
+
esac
|
66 |
+
|
67 |
+
if [[ -z "${TAGS}" ]]; then
|
68 |
+
echo "Empty Tags!"
|
69 |
+
exit 1
|
70 |
+
fi
|
71 |
+
|
72 |
+
{
|
73 |
+
echo 'DOCKER_IMAGE_TAGS<<EOF'
|
74 |
+
for tag in ${TAGS}; do
|
75 |
+
echo "viren070/aiostreams:${tag}"
|
76 |
+
echo "ghcr.io/viren070/aiostreams:${tag}"
|
77 |
+
done
|
78 |
+
echo EOF
|
79 |
+
} >> "${GITHUB_ENV}"
|
80 |
+
|
81 |
+
echo "TAGS=${TAGS}" >> "${GITHUB_ENV}"
|
82 |
+
|
83 |
+
echo "CHANNEL=${CHANNEL}" >> "${GITHUB_ENV}"
|
84 |
+
|
85 |
+
cat "${GITHUB_ENV}"
|
86 |
+
|
87 |
+
- name: Node
|
88 |
+
uses: actions/setup-node@v4
|
89 |
+
with:
|
90 |
+
node-version: 20
|
91 |
+
|
92 |
+
- name: Generate metadata
|
93 |
+
run: |
|
94 |
+
node scripts/generateMetadata.js --channel=${{env.CHANNEL}}
|
95 |
+
|
96 |
+
- name: Build & Push
|
97 |
+
uses: docker/build-push-action@v6
|
98 |
+
with:
|
99 |
+
cache-from: type=gha
|
100 |
+
cache-to: type=gha,mode=max
|
101 |
+
platforms: linux/amd64,linux/arm64
|
102 |
+
push: true
|
103 |
+
context: .
|
104 |
+
file: ./Dockerfile
|
105 |
+
tags: ${{env.DOCKER_IMAGE_TAGS}}
|
106 |
+
|
107 |
+
- name: Send Discord Notification
|
108 |
+
env:
|
109 |
+
CHANNEL: ${{env.CHANNEL}}
|
110 |
+
TAGS: ${{env.TAGS}}
|
111 |
+
run: |
|
112 |
+
# Determine role based on channel
|
113 |
+
if [ "$CHANNEL" = "stable" ]; then
|
114 |
+
ROLE_ID="<@&1384627130272452638>"
|
115 |
+
COLOR=5763719 # Green
|
116 |
+
TITLE="🎉 Stable Release"
|
117 |
+
else
|
118 |
+
ROLE_ID="<@&1384627462155272242>"
|
119 |
+
COLOR=15844367 # Orange
|
120 |
+
TITLE="🌙 Nightly Build"
|
121 |
+
fi
|
122 |
+
|
123 |
+
# Format tags for display (each tag on a new line with bullet points)
|
124 |
+
FORMATTED_TAGS=""
|
125 |
+
for tag in $TAGS; do
|
126 |
+
if [ -z "$FORMATTED_TAGS" ]; then
|
127 |
+
FORMATTED_TAGS="• \`$tag\`"
|
128 |
+
else
|
129 |
+
FORMATTED_TAGS="$FORMATTED_TAGS\n• \`$tag\`"
|
130 |
+
fi
|
131 |
+
done
|
132 |
+
|
133 |
+
# Get current timestamp in ISO 8601 format UTC
|
134 |
+
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
135 |
+
|
136 |
+
# Create JSON payload file
|
137 |
+
cat << EOF > discord_payload.json
|
138 |
+
{
|
139 |
+
"content": "$ROLE_ID",
|
140 |
+
"embeds": [
|
141 |
+
{
|
142 |
+
"title": "$TITLE - Docker Images Published",
|
143 |
+
"description": "New Docker images have been built and pushed to registries.",
|
144 |
+
"color": $COLOR,
|
145 |
+
"fields": [
|
146 |
+
{
|
147 |
+
"name": "📦 Channel",
|
148 |
+
"value": "• \`$CHANNEL\`",
|
149 |
+
"inline": true
|
150 |
+
},
|
151 |
+
{
|
152 |
+
"name": "🏷️ Tags Published",
|
153 |
+
"value": "$FORMATTED_TAGS",
|
154 |
+
"inline": false
|
155 |
+
},
|
156 |
+
{
|
157 |
+
"name": "📍 View Images",
|
158 |
+
"value": "[Docker Hub](https://hub.docker.com/r/viren070/aiostreams) · [GHCR](https://github.com/Viren070/AIOStreams/pkgs/container/aiostreams)",
|
159 |
+
"inline": false
|
160 |
+
},
|
161 |
+
{
|
162 |
+
"name": "🔗 View Build",
|
163 |
+
"value": "[GitHub Actions](https://github.com/Viren070/aiostreams/actions/runs/${{ github.run_id }})",
|
164 |
+
"inline": false
|
165 |
+
}
|
166 |
+
],
|
167 |
+
"footer": {
|
168 |
+
"text": "AIOStreams CI",
|
169 |
+
"icon_url": "https://github.com/Viren070.png"
|
170 |
+
},
|
171 |
+
"timestamp": "$TIMESTAMP"
|
172 |
+
}
|
173 |
+
]
|
174 |
+
}
|
175 |
+
EOF
|
176 |
+
|
177 |
+
echo "Sending to Discord:"
|
178 |
+
cat discord_payload.json
|
179 |
+
|
180 |
+
# Send payload to Discord and capture response and status code
|
181 |
+
http_response=$(curl -s -w "\n%{http_code}" -H "Content-Type: application/json" \
|
182 |
+
-X POST \
|
183 |
+
-d @discord_payload.json \
|
184 |
+
"${{ secrets.DISCORD_WEBHOOK_URL }}")
|
185 |
+
|
186 |
+
http_body=$(echo "$http_response" | sed '$d')
|
187 |
+
http_code=$(echo "$http_response" | tail -n1)
|
188 |
+
|
189 |
+
echo "HTTP Status Code: $http_code"
|
190 |
+
echo "Discord Response Body: $http_body"
|
191 |
+
|
192 |
+
if [ "$http_code" != "204" ]; then
|
193 |
+
echo "Error sending to Discord webhook."
|
194 |
+
exit 1
|
195 |
+
fi
|
196 |
+
|
197 |
+
echo "Message sent successfully!"
|
.github/workflows/nightly.yml
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Nightly Builds
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches: [main]
|
6 |
+
paths:
|
7 |
+
- 'packages/**'
|
8 |
+
- 'package-lock.json'
|
9 |
+
- 'package.json'
|
10 |
+
- 'tsconfig.json'
|
11 |
+
- 'tsconfig.base.json'
|
12 |
+
- 'Dockerfile'
|
13 |
+
|
14 |
+
jobs:
|
15 |
+
release:
|
16 |
+
name: release
|
17 |
+
if: ${{ github.ref == 'refs/heads/main' }}
|
18 |
+
runs-on: ubuntu-latest
|
19 |
+
permissions:
|
20 |
+
actions: write
|
21 |
+
contents: write
|
22 |
+
pull-requests: write
|
23 |
+
steps:
|
24 |
+
- name: Checkout code
|
25 |
+
uses: actions/checkout@v4
|
26 |
+
|
27 |
+
- name: Generate timestamp tag
|
28 |
+
id: gen_tag
|
29 |
+
run: |
|
30 |
+
TIMESTAMP=$(date '+%Y.%m.%d.%H%M-nightly')
|
31 |
+
echo "tag_name=$TIMESTAMP" >> $GITHUB_OUTPUT
|
32 |
+
|
33 |
+
- name: Create git tag
|
34 |
+
env:
|
35 |
+
TAG_NAME: ${{ steps.gen_tag.outputs.tag_name }}
|
36 |
+
run: |
|
37 |
+
git config user.name "github-actions[bot]"
|
38 |
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
39 |
+
git tag $TAG_NAME
|
40 |
+
git push origin $TAG_NAME
|
41 |
+
|
42 |
+
- name: Get commit message
|
43 |
+
id: commit_msg
|
44 |
+
run: |
|
45 |
+
COMMIT_MSG=$(git log -1 --pretty=%B)
|
46 |
+
echo "commit_msg<<EOF" >> $GITHUB_OUTPUT
|
47 |
+
echo "$COMMIT_MSG" >> $GITHUB_OUTPUT
|
48 |
+
echo "EOF" >> $GITHUB_OUTPUT
|
49 |
+
|
50 |
+
- name: Create GitHub prerelease
|
51 |
+
env:
|
52 |
+
GH_TOKEN: ${{ github.token }}
|
53 |
+
run: |
|
54 |
+
gh release create "${{ steps.gen_tag.outputs.tag_name }}" \
|
55 |
+
--repo "${GITHUB_REPOSITORY}" \
|
56 |
+
--title "${{ steps.gen_tag.outputs.tag_name }}" \
|
57 |
+
--notes "${{ steps.commit_msg.outputs.commit_msg }}" \
|
58 |
+
--prerelease
|
59 |
+
|
60 |
+
- name: Trigger Docker Image Publish
|
61 |
+
env:
|
62 |
+
GH_TOKEN: ${{ github.token }}
|
63 |
+
run: |
|
64 |
+
gh workflow run --repo ${GITHUB_REPOSITORY} deploy-docker.yml -f ref=${{ steps.gen_tag.outputs.tag_name }}
|
.github/workflows/release.yml
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Release
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches: [main]
|
6 |
+
pull_request:
|
7 |
+
branches: [main]
|
8 |
+
|
9 |
+
jobs:
|
10 |
+
release:
|
11 |
+
name: release
|
12 |
+
if: ${{ github.ref == 'refs/heads/main' }}
|
13 |
+
runs-on: ubuntu-latest
|
14 |
+
permissions:
|
15 |
+
actions: write
|
16 |
+
contents: write
|
17 |
+
pull-requests: write
|
18 |
+
steps:
|
19 |
+
- name: Release
|
20 |
+
id: release
|
21 |
+
uses: google-github-actions/release-please-action@v4
|
22 |
+
with:
|
23 |
+
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
|
24 |
+
|
25 |
+
- name: Trigger Docker Image Publish
|
26 |
+
if: ${{ steps.release.outputs['release_created'] }}
|
27 |
+
env:
|
28 |
+
GH_TOKEN: ${{ github.token }}
|
29 |
+
TAG_NAME: ${{ steps.release.outputs.tag_name }}
|
30 |
+
run: |
|
31 |
+
gh workflow run --repo ${GITHUB_REPOSITORY} deploy-docker.yml -f ref=${TAG_NAME}
|
.gitignore
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
node_modules/
|
2 |
+
dist/
|
3 |
+
*.tsbuildinfo
|
4 |
+
out/
|
5 |
+
.next/
|
6 |
+
next-env.d.ts
|
7 |
+
.wrangler/
|
8 |
+
.env
|
9 |
+
metadata.json
|
10 |
+
data/
|
.prettierrc
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"semi": true,
|
3 |
+
"singleQuote": true,
|
4 |
+
"tabWidth": 2,
|
5 |
+
"trailingComma": "es5",
|
6 |
+
"endOfLine": "lf"
|
7 |
+
}
|
.release-please-manifest.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
".": "2.4.2"
|
3 |
+
}
|
.vscode/launch.json
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"version": "0.2.0",
|
3 |
+
"configurations": [
|
4 |
+
{
|
5 |
+
"name": "debug addon",
|
6 |
+
"type": "node",
|
7 |
+
"request": "launch",
|
8 |
+
"program": "src/server.ts",
|
9 |
+
"localRoot": "${workspaceFolder}/packages/addon",
|
10 |
+
"runtimeExecutable": "tsx",
|
11 |
+
"console": "integratedTerminal",
|
12 |
+
"internalConsoleOptions": "neverOpen",
|
13 |
+
"skipFiles": ["<node_internals>/**", "${workspaceFolder}/node_modules/**"]
|
14 |
+
}
|
15 |
+
]
|
16 |
+
}
|
.vscode/settings.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"editor.formatOnSave": true,
|
3 |
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
4 |
+
}
|
CHANGELOG.md
ADDED
@@ -0,0 +1,665 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Changelog
|
2 |
+
|
3 |
+
## [2.4.2](https://github.com/Viren070/AIOStreams/compare/v2.4.1...v2.4.2) (2025-06-27)
|
4 |
+
|
5 |
+
|
6 |
+
### Bug Fixes
|
7 |
+
|
8 |
+
* **debridio:** add Italy option ([7774310](https://github.com/Viren070/AIOStreams/commit/77743105de53e5de76ef4f4224883d57cc559bee))
|
9 |
+
|
10 |
+
## [2.4.1](https://github.com/Viren070/AIOStreams/compare/v2.4.0...v2.4.1) (2025-06-27)
|
11 |
+
|
12 |
+
|
13 |
+
### Bug Fixes
|
14 |
+
|
15 |
+
* add 'Clip' as valid type for Trailer ([025f622](https://github.com/Viren070/AIOStreams/commit/025f622002c1409ed6d0e997ac4ee3d857bf10ba))
|
16 |
+
* adjust defaults ([78d4d60](https://github.com/Viren070/AIOStreams/commit/78d4d604ca732d4f96ba9927724c7935e9a956d8))
|
17 |
+
|
18 |
+
## [2.4.0](https://github.com/Viren070/AIOStreams/compare/v2.3.2...v2.4.0) (2025-06-27)
|
19 |
+
|
20 |
+
|
21 |
+
### Features
|
22 |
+
|
23 |
+
* add always precache option ([d4ff4a2](https://github.com/Viren070/AIOStreams/commit/d4ff4a2c0c913e7c6e3754ecb9fd72b45b1f864d))
|
24 |
+
* add slice function to stream expression ([321b325](https://github.com/Viren070/AIOStreams/commit/321b32584014d20d8e78f66b4cef313d0cd22f0c))
|
25 |
+
* add USA TV and Argentina TV ([e29800a](https://github.com/Viren070/AIOStreams/commit/e29800a0ab159940cafa11f0d69d4bc3f46c918c))
|
26 |
+
* allow disabling user agent ([305ebd8](https://github.com/Viren070/AIOStreams/commit/305ebd84c8040866fc45fe1879921e3a7bb93997))
|
27 |
+
|
28 |
+
|
29 |
+
### Bug Fixes
|
30 |
+
|
31 |
+
* apply filters and precomputation to streams after each group fetch ([78144d0](https://github.com/Viren070/AIOStreams/commit/78144d02135072681237eae8bd5b11bf8fc3f991))
|
32 |
+
* fix filtering ([32b1c3c](https://github.com/Viren070/AIOStreams/commit/32b1c3c3b384fad4109520c5730e8076cb2c6ebc))
|
33 |
+
* include headers in logs ([4b9f268](https://github.com/Viren070/AIOStreams/commit/4b9f268b8f399a30f47d2140ecd9afd2856f284a))
|
34 |
+
* pass specified services in DebridioPreset ([e264db6](https://github.com/Viren070/AIOStreams/commit/e264db6fc57ce58da476deadef5b3684228eba73))
|
35 |
+
* set excludeUncached to false during pre-caching ([62aed42](https://github.com/Viren070/AIOStreams/commit/62aed42b07adf24c42cd5ac6c3a43d323e210890))
|
36 |
+
* skip failed addons on manifest fetch ([cada0de](https://github.com/Viren070/AIOStreams/commit/cada0de63ac8602adabd2af2b04015f87697668e))
|
37 |
+
* **streamfusion:** remove service requirement, enable torrent providers, lower limits ([3d856a2](https://github.com/Viren070/AIOStreams/commit/3d856a252dd77d27c81d4539ad848af95f1ca0dd))
|
38 |
+
|
39 |
+
## [2.3.2](https://github.com/Viren070/AIOStreams/compare/v2.3.1...v2.3.2) (2025-06-24)
|
40 |
+
|
41 |
+
|
42 |
+
### Bug Fixes
|
43 |
+
|
44 |
+
* only show warning when no idPrefixes are given ([832deae](https://github.com/Viren070/AIOStreams/commit/832deaed64ea977d493d3815a58f7528aa7b03e1))
|
45 |
+
* remove folderSize from downloadable streams ([baf4c46](https://github.com/Viren070/AIOStreams/commit/baf4c461682fae5dd30e809897498f5d5a62482b))
|
46 |
+
* remove length requirement for string properties in ManifestSchema ([b009511](https://github.com/Viren070/AIOStreams/commit/b00951144925f174a30b0e2858f963c6cbee3837))
|
47 |
+
|
48 |
+
## [2.3.1](https://github.com/Viren070/AIOStreams/compare/v2.3.0...v2.3.1) (2025-06-24)
|
49 |
+
|
50 |
+
|
51 |
+
### Bug Fixes
|
52 |
+
|
53 |
+
* set idPrefixes to undefined for new resources too ([97894be](https://github.com/Viren070/AIOStreams/commit/97894be562ef28a4ddd3887093481f60d4e6b3f1))
|
54 |
+
|
55 |
+
## [2.3.0](https://github.com/Viren070/AIOStreams/compare/v2.2.1...v2.3.0) (2025-06-24)
|
56 |
+
|
57 |
+
|
58 |
+
### Features
|
59 |
+
|
60 |
+
* add `EXPOSE_USER_COUNT` set to false by default ([3e9820b](https://github.com/Viren070/AIOStreams/commit/3e9820bc3de6bca391259026523a07d63e8c90e7))
|
61 |
+
* add more fields to bingeGroup ([f53c8ca](https://github.com/Viren070/AIOStreams/commit/f53c8cab1f3465ebf639e035824b7b3c2e069203))
|
62 |
+
* add tmdb addon ([96bf1de](https://github.com/Viren070/AIOStreams/commit/96bf1de8bd5a44b10bc3ada6dd8e1cd5c11b1d2e))
|
63 |
+
* add torrentsdb ([aebef33](https://github.com/Viren070/AIOStreams/commit/aebef33432d9d21c5c90577da73fc21803432b83))
|
64 |
+
* improve parsing for debridio tv ([320dbb2](https://github.com/Viren070/AIOStreams/commit/320dbb29020cc499c4d806f904feb0f4d45730d3))
|
65 |
+
|
66 |
+
|
67 |
+
### Bug Fixes
|
68 |
+
|
69 |
+
* add discovery+ option to streaming catalogs ([3b47339](https://github.com/Viren070/AIOStreams/commit/3b473393e201c32afbe5301a1d5ff9026b1f5718))
|
70 |
+
* make sorting in deduplicator consistent ([b15efd5](https://github.com/Viren070/AIOStreams/commit/b15efd5529d1246e538b25797930bcbab874b73b))
|
71 |
+
* only extract folder size if difference is large enough ([3d7808b](https://github.com/Viren070/AIOStreams/commit/3d7808b92cde840dac242ad8f52fd671a02199fb))
|
72 |
+
* set idPrefixes to undefined when an addon for that resource doesn't provide it ([f3ff7c5](https://github.com/Viren070/AIOStreams/commit/f3ff7c53d2ad4d6c809c1f27d5be3177969f4841))
|
73 |
+
|
74 |
+
## [2.2.1](https://github.com/Viren070/AIOStreams/compare/v2.2.0...v2.2.1) (2025-06-22)
|
75 |
+
|
76 |
+
|
77 |
+
### Bug Fixes
|
78 |
+
|
79 |
+
* add catalog and meta resources to mediafusion preset ([ee492e2](https://github.com/Viren070/AIOStreams/commit/ee492e2b218bbad813426368ec7f30ecedc79e59))
|
80 |
+
* add min and max constraints validation for options in config ([675eaf0](https://github.com/Viren070/AIOStreams/commit/675eaf0b6340ed52b2d0267442a24448048b04cb))
|
81 |
+
* allow null values in options array for manifest extras ([99d66e8](https://github.com/Viren070/AIOStreams/commit/99d66e835c421af0ad6c86500dc38f93b8d85ca3))
|
82 |
+
* correct property name from 'seeders' to 'seeder' in includedReasons ([912fa49](https://github.com/Viren070/AIOStreams/commit/912fa4910e097c2ec1424ac360482d56b51e6022))
|
83 |
+
* **frontend:** add sensible steps and remove min max constraint in NumberInput for TemplateOption ([1119721](https://github.com/Viren070/AIOStreams/commit/1119721054d77cf7729ed27cf7b4593237bc3675))
|
84 |
+
|
85 |
+
## [2.2.0](https://github.com/Viren070/AIOStreams/compare/v2.1.0...v2.2.0) (2025-06-22)
|
86 |
+
|
87 |
+
|
88 |
+
### Features
|
89 |
+
|
90 |
+
* add 'not' function to BaseConditionParser for filtering streams ([44d2c4c](https://github.com/Viren070/AIOStreams/commit/44d2c4c8708dae8c07370b16d6ca5e7750369ddb))
|
91 |
+
* add logging for include details/reasons during filtering ([9de901d](https://github.com/Viren070/AIOStreams/commit/9de901d22b6e3c8ae515f41fccb63447283492b8))
|
92 |
+
* add merge function in BaseConditionParser ([f223368](https://github.com/Viren070/AIOStreams/commit/f22336800ae952b6f3e703006075b4360da94524))
|
93 |
+
* add regexMatchedInRange function to BaseConditionParser ([cc2f5f7](https://github.com/Viren070/AIOStreams/commit/cc2f5f7608f8dbd3f9d52031e0e6da377d9031b0))
|
94 |
+
* add support for required and preferred filter conditions ([d9281bd](https://github.com/Viren070/AIOStreams/commit/d9281bd978f186a50f04ead98c6fcca41bb32bfb))
|
95 |
+
* adjust wording and naming of expression/condition parser ([a06aea9](https://github.com/Viren070/AIOStreams/commit/a06aea923cdad1540d2edb858ce1de1412d5dd11))
|
96 |
+
* apply filter conditions last ([41d507a](https://github.com/Viren070/AIOStreams/commit/41d507a679af598fbfb4e9391688f1dc70613a5c))
|
97 |
+
* enable addition and subtraction in base Parser ([c4e65f8](https://github.com/Viren070/AIOStreams/commit/c4e65f83b3a0157ec87b775d8967017bfd425ee8))
|
98 |
+
* handle missing debridio api key for clear errors ([ad4a51c](https://github.com/Viren070/AIOStreams/commit/ad4a51caa11c4447cff59ce6f07cf2a870d8f297))
|
99 |
+
* improve condition parser functions to support multiple parameters ([110146c](https://github.com/Viren070/AIOStreams/commit/110146c088ceebc1472eb8f5442d966faabb0278))
|
100 |
+
* loop through optionMetas to ensure new options are validated too and ignore individual errors from presets when necessary ([2ffc82c](https://github.com/Viren070/AIOStreams/commit/2ffc82c864878e0d212bbfa6582044555ba6fc78))
|
101 |
+
* support multiple regex names in regexMatched function ([455f430](https://github.com/Viren070/AIOStreams/commit/455f4307fdee14098c9b3766322dd47682e7d270))
|
102 |
+
* use title modifier for title in light gdrive formatter ([e542989](https://github.com/Viren070/AIOStreams/commit/e542989038ad253a098cce41e9480a2927c7514a))
|
103 |
+
|
104 |
+
|
105 |
+
### Bug Fixes
|
106 |
+
|
107 |
+
* actually use the streams after applying filter conditions ([4bc0259](https://github.com/Viren070/AIOStreams/commit/4bc0259dad92d636f338aae4b0b4af0cb0666d2a))
|
108 |
+
* allow empty regex names in ParsedStreamSchema and AIOStream ([cf39cdf](https://github.com/Viren070/AIOStreams/commit/cf39cdfee14d41bb67e9a8bff2d720e7d33cffc5))
|
109 |
+
* **debridio:** update preset to support new version ([#213](https://github.com/Viren070/AIOStreams/issues/213)) ([23e8078](https://github.com/Viren070/AIOStreams/commit/23e8078b3f5aaa7554857e3fefd0a49ba4d2f6b7))
|
110 |
+
* ensure comparison checks for deduplications are carried out when needed ([c7bb0c8](https://github.com/Viren070/AIOStreams/commit/c7bb0c8bee69b82688f08e005985b3a8e6436048))
|
111 |
+
* extract streamExpressionMatched from AIOStream parser ([7e65738](https://github.com/Viren070/AIOStreams/commit/7e657380d7f0c2cfd01b3367e9bd876465a710d8))
|
112 |
+
* fallback to parent get filename method when filename not found in description for mediafusion ([cfb5977](https://github.com/Viren070/AIOStreams/commit/cfb59771fc9bc23b3b982bfbfce75436ca4f37fa))
|
113 |
+
* fallback to using parsed properties from folder when undefined in file and correctly merge array properties ([8eb9b7a](https://github.com/Viren070/AIOStreams/commit/8eb9b7a92efbbf76991d532b828ab48070f13b6d))
|
114 |
+
* filter out uuid in filtered export ([bd21b36](https://github.com/Viren070/AIOStreams/commit/bd21b364d27cbcc72a464c14eb372ffbd8e33a51))
|
115 |
+
* **formatters:** make title modifier return consistent cases with each word titled ([3e6b45a](https://github.com/Viren070/AIOStreams/commit/3e6b45a554bdc15c473e64bc22cee5d0b8c7de7f))
|
116 |
+
* handle invalid addon password error separately for catalog API to be more clear ([a2275cc](https://github.com/Viren070/AIOStreams/commit/a2275cce1bcdf37ba7dd65016a544b222e8ee3a4))
|
117 |
+
* ignore port in host check ([e73be92](https://github.com/Viren070/AIOStreams/commit/e73be9298d82dbb2a9b492cb636c5bd5d82fd1e0))
|
118 |
+
* normalize case sensitivity in condition parser filters for resolutions, qualities, encodes, types, visualTags, audioTags, audioChannels, and languages ([87d2ffb](https://github.com/Viren070/AIOStreams/commit/87d2ffba7f8b8fc3e7ce70372e4f4932aa86bbc5))
|
119 |
+
* only form keyword patterns when length of array is greater than 0 ([9136694](https://github.com/Viren070/AIOStreams/commit/91366943bb813fd99cd6c4775952c8bc5af9d54f))
|
120 |
+
* rename 'not' function to 'negate' to avoid conflicts ([8477584](https://github.com/Viren070/AIOStreams/commit/8477584f9e65aae796c7aa432ffdbc36212f3260))
|
121 |
+
* update credentials field to allow empty strings ([c006321](https://github.com/Viren070/AIOStreams/commit/c00632146d4980ec5a640b54eeb3bbd63f999189))
|
122 |
+
|
123 |
+
## [2.1.0](https://github.com/Viren070/AIOStreams/compare/v2.0.1...v2.1.0) (2025-06-20)
|
124 |
+
|
125 |
+
|
126 |
+
### Features
|
127 |
+
|
128 |
+
* allow disabling pruning and disable it by default ([85c0ec1](https://github.com/Viren070/AIOStreams/commit/85c0ec1b5436af1115f97149f87b41aba41fe3ff))
|
129 |
+
* allow specifying providers in torrentio ([8e5f4b5](https://github.com/Viren070/AIOStreams/commit/8e5f4b520cbcf472598a955039dc33bdda676bd5))
|
130 |
+
* enable conditional operators in parser, allowing ternary statements in filter conditions ([eb6edfc](https://github.com/Viren070/AIOStreams/commit/eb6edfc3f1cb1c6a79400d2311cbe8811f1d284c))
|
131 |
+
* extract folder size for stremthru torz ([e775562](https://github.com/Viren070/AIOStreams/commit/e775562e3c736fb4d652a161a7e29f3fcd28be1f))
|
132 |
+
* improve cache stats logging ([d47eee0](https://github.com/Viren070/AIOStreams/commit/d47eee002112f6330d1b74920199bface0105eed))
|
133 |
+
* improve save install page ([a115e59](https://github.com/Viren070/AIOStreams/commit/a115e5906f568b630425276cf321a931b37aadf1))
|
134 |
+
* only add foldername if different and parse info from both folder and filename ([6eed23f](https://github.com/Viren070/AIOStreams/commit/6eed23f445d017ae6d18e9874978a8874350d006))
|
135 |
+
|
136 |
+
|
137 |
+
### Bug Fixes
|
138 |
+
|
139 |
+
* add enableCollectionFromMovie option to TMDB Collections ([71d9fe0](https://github.com/Viren070/AIOStreams/commit/71d9fe093cad1566172206d0a87662358bd446a6)), closes [#194](https://github.com/Viren070/AIOStreams/issues/194)
|
140 |
+
* add stream as supported resource for TMDB Collections ([d2ef215](https://github.com/Viren070/AIOStreams/commit/d2ef2154fda902900751c47527ff52390506bd54))
|
141 |
+
* add validation to pruneUsers method to ensure negative maxDays input is not used ([6b597b3](https://github.com/Viren070/AIOStreams/commit/6b597b31306fbe42d4104a71f9f330db32d9cda5))
|
142 |
+
* adjust idPrefixes handling to improve compatibility in most cases ([7fa8ba7](https://github.com/Viren070/AIOStreams/commit/7fa8ba71fbb682d077fb5c8ccfbadfb0050bea80))
|
143 |
+
* change all debrid service name to AllDebrid ([a89cdca](https://github.com/Viren070/AIOStreams/commit/a89cdca583e50c3bf66432bbb721797954323ba6)), closes [#208](https://github.com/Viren070/AIOStreams/issues/208)
|
144 |
+
* convert live types to http for webstreamr ([64977ca](https://github.com/Viren070/AIOStreams/commit/64977caeffe2cb6b95714916c14bfa006502c386))
|
145 |
+
* don't pass encoded_user_data header if URL is overriden ([ed2c0f5](https://github.com/Viren070/AIOStreams/commit/ed2c0f5800592c6bf140dc1f9ea8bdb9057d1d55))
|
146 |
+
* exit auto prune when max days is less than 0 ([ee1ddc0](https://github.com/Viren070/AIOStreams/commit/ee1ddc07389d01b382f19fa46e434ca93f41d3e8))
|
147 |
+
* explicitly check for unknown in version and default to 0.0.0 for manifest response ([8664e00](https://github.com/Viren070/AIOStreams/commit/8664e004e2553ffb675131488a4c4eab70ede7b3)), closes [#198](https://github.com/Viren070/AIOStreams/issues/198)
|
148 |
+
* extract size for nuviostreams ([ebbd7ec](https://github.com/Viren070/AIOStreams/commit/ebbd7ec3b24d11abc2806e9edbd2aeaee45faa09))
|
149 |
+
* fix error handling in config modal ([5182a07](https://github.com/Viren070/AIOStreams/commit/5182a07ac49d1aa79f515d72c71c7494a27866dd))
|
150 |
+
* **frontend:** filter out proxy credentials and url in export when exclude credentials is true ([3c31939](https://github.com/Viren070/AIOStreams/commit/3c319391b86e6efa530aab5b8cd04ad9341867d1))
|
151 |
+
* handle empty addon name in stream results and update description for addon name field ([5612140](https://github.com/Viren070/AIOStreams/commit/5612140ffee8b8e8804d36efdfd22e6f110b32ef))
|
152 |
+
* handle pikpak credentials for mediafusion ([eee444f](https://github.com/Viren070/AIOStreams/commit/eee444f376136ed04257187c4bb1ddc05f05a3f5))
|
153 |
+
* include addon name in error messages for invalid manifest URLs ([abf99c1](https://github.com/Viren070/AIOStreams/commit/abf99c1768f3cf86d6f58ec256705ae235f9d8f9))
|
154 |
+
* make types optional in ManifestSchema ([5281756](https://github.com/Viren070/AIOStreams/commit/5281756c78e362d3c48cc4469c07c17df9350d9c))
|
155 |
+
* make types required and provide array based on resources object array ([01cf37f](https://github.com/Viren070/AIOStreams/commit/01cf37f8340a9fd130ecb19c93dc7a9863eab012))
|
156 |
+
* manually override type to http for watchtower and nuviostreams ([1fb00a4](https://github.com/Viren070/AIOStreams/commit/1fb00a4317605ee9a5d0da73a4b363bf08b9bf6f))
|
157 |
+
* map defaultProviders to their values in TorrentioPreset configuration ([9b04403](https://github.com/Viren070/AIOStreams/commit/9b044037d38b46270e23172914d1e35f72f51e1f))
|
158 |
+
* normalize version check ([#206](https://github.com/Viren070/AIOStreams/issues/206)) ([05cc116](https://github.com/Viren070/AIOStreams/commit/05cc116fafc9ba6d0f40b7e10938e2505085ea10))
|
159 |
+
* only add to idPrefixes if not null ([6fb5f7b](https://github.com/Viren070/AIOStreams/commit/6fb5f7b841872b0261023766c2472c7f5201be95))
|
160 |
+
* overlapping snippets modal ([#202](https://github.com/Viren070/AIOStreams/issues/202)) ([195da69](https://github.com/Viren070/AIOStreams/commit/195da69f19ca8e15acd000420c1187fd4116de1f))
|
161 |
+
* prevent title from being parsed for info ([f8b2e2d](https://github.com/Viren070/AIOStreams/commit/f8b2e2d66ce07ae4342db974ed6f169c0474d1d2))
|
162 |
+
* remove idPrefixes from top level manifest ([908b4ff](https://github.com/Viren070/AIOStreams/commit/908b4ffa399439ab3f9428357b30a6ae7bc0f29d))
|
163 |
+
* remove outdated decoding of credentials causing issues with some credentials ([609931e](https://github.com/Viren070/AIOStreams/commit/609931e5318c8b6d782cc04cf6a6691269bba287))
|
164 |
+
* remove timestamp from cache stats ([509e3bd](https://github.com/Viren070/AIOStreams/commit/509e3bd2098f10d041a2a776d9b4099567fe4370))
|
165 |
+
* remove unused method handler for unsupported HTTP methods ([7405d27](https://github.com/Viren070/AIOStreams/commit/7405d272ab79321d8b1e97ee4bcd1a2b2f8c12a5))
|
166 |
+
* rename web_dl to webdl in stremthru store ([3fb57c5](https://github.com/Viren070/AIOStreams/commit/3fb57c5d04e23585e71a5e9f0643735f675671c7))
|
167 |
+
* simplify and fix configuration generation for services and providers in TorrentioPreset ([cfafeec](https://github.com/Viren070/AIOStreams/commit/cfafeecda3591c342d5f2aeb756fde4adc536024))
|
168 |
+
* try explicitly setting idPrefixes to an empty array ([c16060f](https://github.com/Viren070/AIOStreams/commit/c16060f7a5ffa5b5142fe5a0753046748f682f0a))
|
169 |
+
* try removing types ([10c4e2d](https://github.com/Viren070/AIOStreams/commit/10c4e2d51f7a0ba05d6214da1c848b66ec9237ca))
|
170 |
+
* try setting idPrefixes to null ([a5f32df](https://github.com/Viren070/AIOStreams/commit/a5f32df451c7ba73438322c217ffa431e9a84125))
|
171 |
+
* update descriptions for filtering options in menu component to clarify behavior ([67bb204](https://github.com/Viren070/AIOStreams/commit/67bb204362951ef3998c690ba1c0055c1a4cc12b))
|
172 |
+
* use password type where necessary ([0a12d33](https://github.com/Viren070/AIOStreams/commit/0a12d335c34b8181c9ac849bed623ea77b43a84c))
|
173 |
+
|
174 |
+
## [2.0.1](https://github.com/Viren070/AIOStreams/compare/v2.0.0...v2.0.1) (2025-06-19)
|
175 |
+
|
176 |
+
|
177 |
+
### Bug Fixes
|
178 |
+
|
179 |
+
* add audio channel to skipReasons ([ef1763c](https://github.com/Viren070/AIOStreams/commit/ef1763cbe60fe5c279138a152e1a8d677f30f0ce))
|
180 |
+
* correctly handle overriding URL for mediafusion ([9bf3838](https://github.com/Viren070/AIOStreams/commit/9bf3838732542c5cac1ef189cd5afefc13fe0204))
|
181 |
+
* ensure instances is defined ([7e00e32](https://github.com/Viren070/AIOStreams/commit/7e00e32bbe93a5610d4f94bc3d78a78e48d32c6b))
|
182 |
+
|
183 |
+
## [2.0.0](https://github.com/Viren070/AIOStreams/compare/v1.22.0...v2.0.0) (2025-06-18)
|
184 |
+
|
185 |
+
### 🚀 The Big Upgrades in v2 🚀
|
186 |
+
|
187 |
+
- **Beyond Just Streams:** AIOStreams v2 now supports more than just stream addons! You can integrate **any supported Stremio addon type**, including **Catalog addons, Subtitle addons, and even Addon Catalog addons** into your single AIOStreams setup. Now it truly can do _everything_!
|
188 |
+
- **100% Addon Compatibility:** That's right! AIOStreams v2 is designed to work with **100% of existing Stremio addons** that adhere to the Stremio addon SDK.
|
189 |
+
- **Sleek New UI**: The entire interface has been redesigned for a more modern, intuitive, and frankly, beautiful configuration experience.
|
190 |
+
|
191 |
+
_This new configuration page was only possible thanks to [Seanime](https://seanime.rahim.app), a beautiful application for anime_
|
192 |
+
|
193 |
+
---
|
194 |
+
|
195 |
+
### ✨ Feature Deep Dive - Get Ready for Control! ✨
|
196 |
+
|
197 |
+
This rewrite has paved the way for a TON of new features and enhancements. Here’s a rundown:
|
198 |
+
|
199 |
+
**🛠️ Configuration Heaven & Built-in Marketplace:**
|
200 |
+
|
201 |
+
- The configuration page now features a **built-in marketplace for addons**. This makes it super easy to discover and add new addons, displaying their supported resources (streams, catalogs, subtitles, etc.), Debrid services they integrate with, and stream types (torrent, http, usenet, live etc.).
|
202 |
+
- You can now **quickly enable or disable individual addons** within your AIOStreams setup without fully removing them. This is particularly useful because tools like StremThru Sidekick wouldn't be able to detect or manage the individual addons _inside_ your AIOStreams bundle, but with AIOStreams' own UI, you have that fine-grained control.
|
203 |
+
- Remember, the marketplace is just there for convenience. You can still add any addon you want using the 'Custom' addon at the top of the marketplace and use an addons manifest URL to add it to AIOStreams.
|
204 |
+
|
205 |
+
**📚 Supercharged Catalog Management:**
|
206 |
+
|
207 |
+
- **Total Catalog Control:** Reorder your catalogs exactly how you want them, **regardless of which addon they originate from!** Mix and match to your heart's content.
|
208 |
+
- **Granular Management:** Enable/disable specific catalogs, apply **shuffling** to individual catalogs - and control how long a shuffle lasts, **rename catalogs** for a personalized touch, and you can even **disable certain catalogs from appearing on your Stremio home page**, having them only show up in the Discover section for a cleaner look!
|
209 |
+
- **Universal RPDB Posters:** Ever wanted those sleek posters with ratings on _any_ catalog? Now you can! Apply **RPDB posters (with ratings) to any addon that uses a supported ID type (like IMDB or TMDB ID), even if the original addon doesn't support RPDB itself.** Yes, this means you could add RPDB posters to Cinemeta if you wanted!
|
210 |
+
- **Why not just use other tools like StremThru Sidekick or the Addon Manager for catalogs?**
|
211 |
+
- **Broader Compatibility:** Both StremThru Sidekick and Addon Manager are primarily limited to managing addons _for Stremio itself_. AIOStreams’ catalog features can be utilized by _any application_ that supports Stremio addons, not just Stremio.
|
212 |
+
- **True Internal Reordering:** Neither of those tools supports reordering catalogs _within an addon itself_. Since AIOStreams presents all its combined catalogs as coming from _one addon_, those tools wouldn't be able to reorder the catalogs _inside_ your AIOStreams setup. AIOStreams gives you that crucial internal control.
|
213 |
+
- **Safety:** AIOStreams does **not** make use of the Stremio API for its core functionality. This means it operates independently and **cannot break your Stremio account** or interfere with its settings.
|
214 |
+
|
215 |
+
**🌐 Expanded Addon Ecosystem:**
|
216 |
+
|
217 |
+
- The built-in marketplace comes packed with **many more addons than before**.
|
218 |
+
- Some notable new stream addons include: **StremThru Torz, Nuvio Streams, Debridio Watchtower, StreamFusion**, and even built-in support for **wrapping AIOStreams within AIOStreams** (AIOception!).
|
219 |
+
|
220 |
+
**💎 Revolutionary Grouping Feature:**
|
221 |
+
|
222 |
+
- This is a big one! I've implemented a **new grouping feature** that allows you to group your addons and apply highly customizable conditions.
|
223 |
+
- Streams from addons in Group 1 are always fetched. Then, you can set conditions for subsequent groups. For example, for Group 2, you could set a condition like `count(previousStreams) < 5`. This means addons in Group 2 will only be queried if the total number of streams found by Group 1 is less than 5. This means you can tell AIOStreams, for instance, to only tap into your backup/slower addon group if your main, preferred addons don't find enough streams first – super efficient!
|
224 |
+
- This allows for incredibly optimized and tailored stream fetching. (For more advanced setups and details, I highly recommend checking out the **[Wiki](https://github.com/Viren070/AIOStreams/wiki/Groups)**).
|
225 |
+
|
226 |
+
**🔎 Next-Level Filtering System:**
|
227 |
+
|
228 |
+
- The filtering system has been completely revamped. Previously, you could mainly exclude or prefer. Now, for _every_ filter criteria, you can set **four different filter types**:
|
229 |
+
- **Include:** If matched, this item won't be excluded by other exclude/required filters for _any other exclude/required filter_.
|
230 |
+
- **Required:** Exclude the stream if this criteria is _not_ detected.
|
231 |
+
- **Exclude:** Exclude the stream if this criteria _is_ detected.
|
232 |
+
- **Preferred:** This is used for ranking when you use that filter as a sort criteria.
|
233 |
+
- **New Filters Added:**
|
234 |
+
- **Conditions Filter:** This incredibly flexible filter uses the same powerful condition parser as the "Groups" feature. You can now enter **multiple filter conditions**, and any stream that matches _any_ of the conditions you define will be filtered out. This allows for an almost infinite number of ways to combine and exclude streams with surgical precision! For example, a condition like `addon(type(streams, 'debrid'), 'TorBox')` would exclude all Debrid-type streams _only_ from the "TorBox" addon, leaving its Usenet streams untouched.
|
235 |
+
- **Matching:** This powerful filter helps ensure you get the right content. It includes:
|
236 |
+
- **Title Matching:** Filter out results that don't match the requested title. You can choose between an "exact match" mode or a "contains" mode for flexibility. **You can optionally also match the year too.**
|
237 |
+
- **Season/Episode Matching:** Specifically for series, this mode filters out results with incorrect season or episode numbers, ensuring accuracy. This can be granularly applied to only specific addons or request types.
|
238 |
+
- **Audio Channels:** This was previously part of the Audio Tag filter but is now its own dedicated filter for more precise control (e.g., filter for 5.1, 7.1).
|
239 |
+
- **Seeders:** Define include/required/exclude ranges for seeders. Finally, you can set a **minimum seeder count** and automatically exclude results below that threshold!
|
240 |
+
- **Adjusted & Enhanced Filters:**
|
241 |
+
- **Cache:** Get fine-grained control over cached/uncached content. You can now exclude uncached/cached content from specific Debrid services or addons, and even for specific stream types. For example, you could filter out all uncached _torrents_ but still allow uncached _Usenet_ results.
|
242 |
+
- **Clean Results (now "Deduplicator"):** This is now far more customizable! You can modify what attributes are used to identify duplicates (e.g., infohash, filename) and how duplicates are removed for each stream type. For instance, for cached results, you might want one result from each of your Debrid services, while for uncached results, you might only want the single best result from your highest priority service.
|
243 |
+
- **Size:** You can now set **individual file size ranges for each resolution** (e.g., 1-2GB for 720p, 3-5GB for 1080p, etc.).
|
244 |
+
|
245 |
+
**📺 Smarter Sorting & Display:**
|
246 |
+
|
247 |
+
- Define **different sorting priorities for cached vs. uncached media**, and also **different sorting for movies vs. series.**
|
248 |
+
- **New "Light GDrive" Formatter:** For those who prefer a cleaner look but still need key information from the filename, this formatter only shows the title, year, and season/episode info (e.g., "Movie Title (2023) S01E01"), making sure you don't potentially choose an incorrect result while still keeping the text to a minimal level.
|
249 |
+
- And of course, you can always join our Discord server to discover custom display formats shared by the community and easily use them with AIOStreams' custom formatter feature!
|
250 |
+
|
251 |
+
**✨ Quality of Life Enhancements:**
|
252 |
+
|
253 |
+
- **Import/Export Configurations:** You can now easily **export your entire AIOStreams configuration into a file.** This file can then be imported into any AIOStreams instance at any time – perfect for backups or migrating to a new setup.
|
254 |
+
- **Shareable Templates:** There's an "Exclude Credentials" option when exporting, making it easy to share template configurations with others!
|
255 |
+
- **⚠️ Important Warning:** While the "Exclude Credentials" feature removes sensitive information you enter _directly_ into AIOStreams (like API keys), it **does not** modify or exclude URLs you provide for "Custom" addons or when you override an addon's default URL. These URLs can potentially contain sensitive tokens or identifiers, so please review them carefully before sharing a configuration file.
|
256 |
+
- **External Downloads:** For added convenience, AIOStreams v2 now adds an "External Download" link below each stream result. Clicking this will open the direct download link for that stream in your browser, making it easy to grab a copy of the content if needed.
|
257 |
+
- **Hide Errors:** Optionally hide error messages, and you can even specify this for particular resources (e.g., hide errors only for stream fetching, but show them for catalog fetching).
|
258 |
+
- **Precache Next Episode:** When you're watching a series, AIOStreams can automatically request results for the _next_ episode in the background. If it finds that all available results are uncached, it can **ping the first uncached result for your preferred Debrid service to start downloading it.** The goal? By the time you finish your current episode, the next one might already be cached and ready to stream instantly!
|
259 |
+
|
260 |
+
**A Note on Options:** AIOStreams v2 offers a vast array of configuration options, especially within the filtering system. While this provides incredible power and flexibility for advanced users, please remember that **most users won't need to dive deep into every setting.** The default configurations are designed to be sensible and provide a great experience out-of-the-box! For a detailed explanation of every option and how to fine-tune your setup, the **[AIOStreams v2 Configuration Guide](https://guides.viren070.me/stremio/addons/aiostreams)** has been fully updated and is your best resource.
|
261 |
+
|
262 |
+
---
|
263 |
+
|
264 |
+
### 💾 Under The Hood: The New Database Foundation 💾
|
265 |
+
|
266 |
+
- **Database-Driven:** AIOStreams is now database-based! This means your configurations are stored securely. When you create a configuration, it's assigned a **unique UUID** that you'll use to access it in Stremio.
|
267 |
+
- **Password Protected:** You'll protect your configurations with a **password**. Without it, no one else can access your configuration.
|
268 |
+
- **Seamless Updates (Mostly!):** A huge benefit of being database-driven is that for most setting changes, there’s **no longer a need to reinstall the addon in Stremio!** Just update your configuration, and the changes apply automatically.
|
269 |
+
- **Note:** The only exception is if you make changes to your catalogs that affect their order or which addons provide them (e.g., reordering addons in the list, adding/removing catalog-providing addons). In this specific case, a reinstall of the AIOStreams addon in Stremio is needed for Stremio to pick up the new catalog structure.
|
270 |
+
|
271 |
+
---
|
272 |
+
|
273 |
+
### ⚠️ Important Notes & Caveats for v2 ⚠️
|
274 |
+
|
275 |
+
- **Migration Requires Reconfiguration:** Due to the extensive changes and the new database system, existing AIOStreams users will need to **reconfigure their setups for v2.** Think of it as a fresh start with a much more powerful system! The **[v1 to v2 Migration Guide](https://github.com/Viren070/AIOStreams/wiki/Migrate-to-V2)** on the Wiki can help. For a deep dive into all the new settings, refer to the comprehensive **[AIOStreams v2 Configuration Guide](https://guides.viren070.me/stremio/addons/aiostreams)**. **If you use custom formatters, you should also check the migration guide for minor syntax adjustments.**
|
276 |
+
- **Torrentio support (on public instance)?** Torrentio, the most popular addon, was disabled for most of v1's history due to the way it works (multiple requests appear to come from one IP, which is problematic for public instances). Torrentio remains **disabled on the public instance**, and this will not change. Self-hosted instances will have Torrentio enabled by default. The developer of Torrentio has personally stated that he does not want ElfHosted's public instances scraping Torrentio.
|
277 |
+
- **Cloudflare Worker Support Dropped:** Maintaining compatibility with Cloudflare Workers alongside the new database requirements and feature set became infeasible. It was essentially like writing and maintaining two different versions of the addon. As such, direct Cloudflare Worker support has been dropped.
|
278 |
+
- **Free Hosting Challenges:** AIOStreams v2 now **requires a database** for storing configurations. Many free hosting services do not provide persistent database storage (or have very limited free tiers), which can lead to your configurations being wiped when the instance restarts.
|
279 |
+
- For example, **Hugging Face Spaces** requires a paid tier for persistent storage.
|
280 |
+
- **Koyeb's** free tier does not offer persistent file storage for the SQLite database, however, Koyeb _does_ provide a free PostgreSQL database instance which AIOStreams v2 can use, offering a viable free hosting path if configured correctly.
|
281 |
+
I recommend looking for hosting solutions that offer persistent storage or a compatible free database tier if you plan to self-host on a free platform.
|
282 |
+
|
283 |
+
---
|
284 |
+
|
285 |
+
### 🔧 Self-Hosting AIOStreams & Self-Hosting Guides 🔧
|
286 |
+
|
287 |
+
For those of you who like to have full control over your setup, **AIOStreams v2 is, of course, _still_ self-hostable!**
|
288 |
+
|
289 |
+
If you're migrating your instance from v1 to v2, read the [Migration](https://github.com/Viren070/AIOStreams/wiki/Migrate-to-V2) page on the Wiki to ensure nothing unexpected happens.
|
290 |
+
|
291 |
+
A few months back, I started out knowing very little about self-hosting (I was using Hugging Face to host my personal AIOStreams instance back then) and I've since decided to dive into self-hosting.
|
292 |
+
|
293 |
+
As a result, I've put together a **set of comprehensive self-hosting guides** that I'm excited to share with the community. My goal with these guides is to take you **from scratch to hosting all sorts of addons and applications**, including AIOStreams, without spending a dime or needing any hardware other than a laptop/computer. (Some of you may even be able to set this all up just using your phone/tablet)
|
294 |
+
|
295 |
+
The guides cover:
|
296 |
+
|
297 |
+
- Securing a **free Oracle Cloud VPS** (yes, free!).
|
298 |
+
- Installing **Docker** and getting comfortable with its basics.
|
299 |
+
- Utilizing my **highly flexible and detailed template compose project.** This Docker Compose setup is designed to be a launchpad for your self-hosting adventures and includes configurations for **countless apps, with AIOStreams v2 ready to go!**
|
300 |
+
|
301 |
+
If you've ever been curious about self-hosting but didn't know where to start, I believe these guides can help you get up and running with a powerful, remote, and secure setup.
|
302 |
+
|
303 |
+
- **https://guides.viren070.me/selfhosting**
|
304 |
+
|
305 |
+
---
|
306 |
+
|
307 |
+
### 💬 Join the AIOStreams Community on Discord! 💬
|
308 |
+
|
309 |
+
AIOStreams v2 wouldn't be where it is today without the feedback, bug reports, and ideas from our community. A Massive **THANK YOU** to everyone on Discord who took part in testing, shared suggestions, and patiently helped polish every feature. Your involvement genuinely shaped this release!
|
310 |
+
|
311 |
+
To celebrate the launch, I'm running a **1-year Real-Debrid giveaway (with 2 winners)** exclusively in the Discord server! Just join the server for your chance to win.
|
312 |
+
|
313 |
+
Outside of the giveaway, you can also join our server for:
|
314 |
+
|
315 |
+
- Questions about and support for AIOStreams
|
316 |
+
- Receive help with self hosting
|
317 |
+
- Discover setups shared by the community like formats, regexes, group filters, condition filters etc. (and possibly even share your own!)
|
318 |
+
- Staying updated on the latest AIOStreams developments
|
319 |
+
|
320 |
+
Join our server using the link below:
|
321 |
+
|
322 |
+
- **https://discord.viren070.me**
|
323 |
+
|
324 |
+
---
|
325 |
+
|
326 |
+
### ❤️ Support AIOStreams Development ❤️
|
327 |
+
|
328 |
+
AIOStreams is a passion project that I develop solo in my free time. Countless hours have gone into this v2 rewrite, and I'm committed to making it the best it can be.
|
329 |
+
|
330 |
+
If you find AIOStreams useful and want to support its continued development, please consider donating. Any amount is hugely appreciated and helps me dedicate more time to new features, bug fixes, and support.
|
331 |
+
|
332 |
+
- **[Sponsor me on GitHub](https://github.com/sponsors/Viren070)**
|
333 |
+
- **[Buy me a coffee on Ko-fi](https://ko-fi.com/viren070)**
|
334 |
+
|
335 |
+
---
|
336 |
+
|
337 |
+
### 🚀 Get Started with AIOStreams v2! 🚀
|
338 |
+
|
339 |
+
I'm incredibly excited for you all to try out AIOStreams v2! I believe it's a massive step forward. Please give it a go, explore the new features, and share your feedback.
|
340 |
+
|
341 |
+
Here’s how you can jump in:
|
342 |
+
|
343 |
+
**1. Try the Public Instance (Easiest Way!)**
|
344 |
+
|
345 |
+
- **ElfHosted (Official Public Instance):** Generously hosted and maintained.
|
346 |
+
- **Link:** **https://aiostreams.elfhosted.com/**
|
347 |
+
|
348 |
+
**2. Self-Host AIOStreams v2**
|
349 |
+
|
350 |
+
- **For New Self-Hosters:** If you know what you're doing - follow the [Deployment Wiki](https://github.com/Viren070/AIOStreams/wiki/Deployment). Otherwise, check out my comprehensive **[Self-Hosting Guides](https://guides.viren070.me/selfhosting)** to get started from scratch.
|
351 |
+
- **Migrating from v1?** If you're currently self-hosting v1, ensure your setup supports persistent storage and then follow the **[v1 to v2 Migration Guide](https://github.com/Viren070/AIOStreams/wiki/Migrate-to-V2)**.
|
352 |
+
|
353 |
+
**3. Managed Private Instance via ElfHosted (Support AIOStreams Development!)**
|
354 |
+
|
355 |
+
- Want AIOStreams without the self-hosting hassle? ElfHosted offers private, managed instances.
|
356 |
+
- ✨ **Support My Work:** If you sign up using my referral link, **33% of your subscription fee directly supports AIOStreams development!**
|
357 |
+
- **Get your ElfHosted AIOStreams Instance:** **https://store.elfhosted.com/product/aiostreams/elf/viren070**
|
358 |
+
|
359 |
+
This release marks a new chapter for AIOStreams, and I can't wait to see how you all use it to enhance your Stremio experience.
|
360 |
+
|
361 |
+
Cheers,
|
362 |
+
|
363 |
+
Viren.
|
364 |
+
|
365 |
+
See the commit breakdown below:
|
366 |
+
|
367 |
+
### Features
|
368 |
+
|
369 |
+
- add 'onlyOnDiscover' catalog modifier ([4024c01](https://github.com/Viren070/AIOStreams/commit/4024c01b0a55cdd18023cf4d9328f38d3b5c29d0))
|
370 |
+
- add alert and socials options to schema, implement SocialIcon component, and update TemplateOption to render new option types ([a0a3c82](https://github.com/Viren070/AIOStreams/commit/a0a3c8231ae77cd379eb39ba68ef437b15b0a4e5))
|
371 |
+
- add alert option to DebridioTmdbPreset and TmdbCollectionsPreset for language selector clarification ([093f90a](https://github.com/Viren070/AIOStreams/commit/093f90a3eeafb540aaf28638557ad75a8f1e44d9))
|
372 |
+
- add aliased configuration support ([5df60d7](https://github.com/Viren070/AIOStreams/commit/5df60d7085a0b5f938c8f135c93c29286aed566b))
|
373 |
+
- add anime catalogs ([5968685](https://github.com/Viren070/AIOStreams/commit/59686852d3b7c2e3f0f8e204bcf8b765aadb29f7))
|
374 |
+
- add anime specific sorting and add help box to sort menu ([77ee7b4](https://github.com/Viren070/AIOStreams/commit/77ee7b48c465d67e2e105d1c134d88cd96b27093))
|
375 |
+
- add api key field and handle encrypted values correctly. ([6a5759d](https://github.com/Viren070/AIOStreams/commit/6a5759d60e27ec83101a3f1b02284ad8242faea9))
|
376 |
+
- add asthetic startup logs ([fdbd282](https://github.com/Viren070/AIOStreams/commit/fdbd2821101bd8de0f9ffc4030a6b4938c43ec70))
|
377 |
+
- add audio channel filter and fix unknown filtering not working in some cases ([df546d3](https://github.com/Viren070/AIOStreams/commit/df546d3a0c9ca39e772a64980a6aa582a4e9c81a))
|
378 |
+
- add built-in torrentio format ([6fa1b2b](https://github.com/Viren070/AIOStreams/commit/6fa1b2b0c0cb45e9344163989009238d528d330b))
|
379 |
+
- add configurable URL modifications for Stremthru Store and Torz ([3ce9dd0](https://github.com/Viren070/AIOStreams/commit/3ce9dd0ff5e5b7e9298bef87b3c5abe12c96afc9))
|
380 |
+
- add delete icon to preferred list, only load valid values, fix password requirement check for new logins, fix spellings and add types ([d845c0c](https://github.com/Viren070/AIOStreams/commit/d845c0ce8bfb040c800355e97ea552758ad3c719))
|
381 |
+
- add doctor who universe ([048c612](https://github.com/Viren070/AIOStreams/commit/048c612896723acffe908459c381dd1ee6f63784))
|
382 |
+
- add donation modal button at top of about menu ([0170267](https://github.com/Viren070/AIOStreams/commit/01702671d59d7b924f4693e30b4f8fb1efaeaa15))
|
383 |
+
- add external download streams option ([952a050](https://github.com/Viren070/AIOStreams/commit/952a05057cfbd9446f19ea4e7c71e26ae8acee89)), closes [#191](https://github.com/Viren070/AIOStreams/issues/191)
|
384 |
+
- add folder size, add smart detect deduplicator, parse folder size for mediafusion, improve size parsing ([52fb3bb](https://github.com/Viren070/AIOStreams/commit/52fb3bb41c9b59433e00695c61fd643724c1bff4))
|
385 |
+
- add health check to dockerfile ([8c68051](https://github.com/Viren070/AIOStreams/commit/8c680511edb2c5936bebdab5931bd32a968bcc9e))
|
386 |
+
- add infohash extractor in base stream parser ([4b1f45d](https://github.com/Viren070/AIOStreams/commit/4b1f45da3a8c3eff9b9a2d675332267cbedf6722))
|
387 |
+
- add keepOpenOnSelect prop to Combobox for customizable popover behavior and set it to true by default ([f32a1a1](https://github.com/Viren070/AIOStreams/commit/f32a1a1002937023cb50a9b5d230950f9981aaba))
|
388 |
+
- add link to wiki in groups and link to predefined formatter definitions ([7f4405e](https://github.com/Viren070/AIOStreams/commit/7f4405e3574cdd230cc2112125163408738d2685))
|
389 |
+
- add more addons and fix stuff ([51f6bd6](https://github.com/Viren070/AIOStreams/commit/51f6bd606c1d4db184b7e9c497f8e63aaf3c03cc))
|
390 |
+
- add nuviostreams and anime kitsu ([34ed384](https://github.com/Viren070/AIOStreams/commit/34ed3846da218065ad89f840e739ec541109158a))
|
391 |
+
- add opensubtitles v3 ([b4f6927](https://github.com/Viren070/AIOStreams/commit/b4f69273a4de6572dafcd5b121910048da3cb3aa))
|
392 |
+
- add P2P option and enhance service handling in StremthruTorzPreset ([6390995](https://github.com/Viren070/AIOStreams/commit/6390995eebbd96ab524c3980b103500ecc8300ad))
|
393 |
+
- add predefined format definitions for torbox, gdrive, and light gdrive ([e3294eb](https://github.com/Viren070/AIOStreams/commit/e3294eb7e9403e457d622e848bbf81534e92c9e6))
|
394 |
+
- add public ip option and load forced/default value to proxy menu ([3c2c59e](https://github.com/Viren070/AIOStreams/commit/3c2c59e676144dba70ba9c3675f3767eab4991ea))
|
395 |
+
- add regex functions to condition parser ([731c1d0](https://github.com/Viren070/AIOStreams/commit/731c1d002cb2fa2bce79f7b20df27f4e6e726e2b))
|
396 |
+
- add season/episode matching ([4cd6522](https://github.com/Viren070/AIOStreams/commit/4cd6522417bb15eb37d23a39b6556ff8aa41838e))
|
397 |
+
- add seeders filters ([653b306](https://github.com/Viren070/AIOStreams/commit/653b30632154c31c1036b76bc84e013253539a47))
|
398 |
+
- add sensible built-in limits and configurable limits, remove unused variables from Env ([37259d9](https://github.com/Viren070/AIOStreams/commit/37259d90f133e57571a896929aa9c023027fad6e))
|
399 |
+
- add shuffle persistence setting and improve shuffling ([e6286bc](https://github.com/Viren070/AIOStreams/commit/e6286bcf9bdbf509722e68879803485cc7926c62))
|
400 |
+
- add size filters, allowing resolution specific limit ([fcec2b9](https://github.com/Viren070/AIOStreams/commit/fcec2b9ed850a852c4254306421c91b82c8a6c54))
|
401 |
+
- add social options to various presets ([ea02be9](https://github.com/Viren070/AIOStreams/commit/ea02be99a714e03687b603848f4157e1150aa817))
|
402 |
+
- add source addon name to catalog and improve ui/ux ([878cd7c](https://github.com/Viren070/AIOStreams/commit/878cd7c71fd648072dc9ec2c8de53428eb79a93c))
|
403 |
+
- add stream passthrough option, orion, jackettio, dmm cast, marvel, peerflix, ([0383671](https://github.com/Viren070/AIOStreams/commit/038367126eb4e9fa327101163a12b4ef6dc9b7e6))
|
404 |
+
- add stream type exclusions for cached and uncached results ([18e034f](https://github.com/Viren070/AIOStreams/commit/18e034f7bfb092c053405244a6f972aff44cf1d1))
|
405 |
+
- add StreamFusion ([8b34be3](https://github.com/Viren070/AIOStreams/commit/8b34be3845a86bddf0b95d9aab43607cf9223a92))
|
406 |
+
- add streaming catalogs ([4ce36f1](https://github.com/Viren070/AIOStreams/commit/4ce36f1ba0a8b3149cb9823b7499d625e0e285dd))
|
407 |
+
- add strict title matching ([c4991c6](https://github.com/Viren070/AIOStreams/commit/c4991c678db0333587e57a632e68f26a650ea24a))
|
408 |
+
- add support for converting ISO 639_2 to languages and prevent languages being detected as indexer in Easynews++ ([938323f](https://github.com/Viren070/AIOStreams/commit/938323f1dd5a4a333275c506afa1c85a8c9af361))
|
409 |
+
- add support for includes modifier for array ([90432ae](https://github.com/Viren070/AIOStreams/commit/90432ae9c8b93b7bc1ba4a7a677f7a576b946cd7))
|
410 |
+
- add webstreamr, improve parsing of nuviostream results, validate tmdb access token, always check for languages ([dc50c6c](https://github.com/Viren070/AIOStreams/commit/dc50c6c70b94df7cc0124bbc8b2f96df01011b38))
|
411 |
+
- adjust addons menu ([6d0a088](https://github.com/Viren070/AIOStreams/commit/6d0a088c395aacb7123a66c12d01df1547733f37))
|
412 |
+
- adjust default user data ([dea5950](https://github.com/Viren070/AIOStreams/commit/dea595055a1cb5ce07f26b64faa209bbaa71dd7a))
|
413 |
+
- adjust handling of meta requests by trying multiple supported addons until one succeeds ([9fab116](https://github.com/Viren070/AIOStreams/commit/9fab1162c004fa7c5f4b73b522527ec0ed142b8a))
|
414 |
+
- adjustments and proxy menu ([0c5479c](https://github.com/Viren070/AIOStreams/commit/0c5479c12997dc755b34897a4ed1814c2140dacb))
|
415 |
+
- allow editing catalog type ([d99a29f](https://github.com/Viren070/AIOStreams/commit/d99a29fd6e97b010d41047d61522ce49a7084ade))
|
416 |
+
- allow passing flags through ([bec91a8](https://github.com/Viren070/AIOStreams/commit/bec91a8a5835b340003381d99ebd5b02596dca4b))
|
417 |
+
- cache RPDB API Key validation ([63622e0](https://github.com/Viren070/AIOStreams/commit/63622e0a07c64b45a228a1f3f653449744ec96e4))
|
418 |
+
- changes ([e8c61a9](https://github.com/Viren070/AIOStreams/commit/e8c61a986066e1bdd06f00c5e3a4ff215ae5f968))
|
419 |
+
- changes ([13a20a7](https://github.com/Viren070/AIOStreams/commit/13a20a7b610da0f41b40ccaf454a31805b445e9e))
|
420 |
+
- clean up env vars and add rate limit to catalog api ([20fc37c](https://github.com/Viren070/AIOStreams/commit/20fc37cc123bacf729c57ae0718d6e85d02d4bb9))
|
421 |
+
- **conditions:** add support for multiple groupings, and add type constant ([2a525b2](https://github.com/Viren070/AIOStreams/commit/2a525b292ef98a8e5a6697f967474714d0ceec23))
|
422 |
+
- enhance language detection in MediaFusionStreamParser to parse languages from stream descriptions ([50db0e2](https://github.com/Viren070/AIOStreams/commit/50db0e2714f5f040660f47efa3012b41ae8da55d))
|
423 |
+
- enhance stream parsing to prefer folder titles when available ([4001fae](https://github.com/Viren070/AIOStreams/commit/4001faede127a5712c3112ea334726bd18717c7d))
|
424 |
+
- enhance strict title matching with configuration options for request types and addons ([3378851](https://github.com/Viren070/AIOStreams/commit/3378851ff8048216529a9d1a6715d3b9d1439d39))
|
425 |
+
- enhance title matching by adding year matching option and updating metadata handling ([62752ef](https://github.com/Viren070/AIOStreams/commit/62752ef98c75741e59e70a08ce811b1e032dc8a9))
|
426 |
+
- expand cache system and add rate limiting to all routes, attempt to block recursive requests ([c9356db](https://github.com/Viren070/AIOStreams/commit/c9356db83ab311261c001702ea5a31193a4b0432))
|
427 |
+
- filter out invalid items in wrapper repsponses, rather than failing whole request. add message parsing for torbox ([da7dc3a](https://github.com/Viren070/AIOStreams/commit/da7dc3a935d29ec66c9c7509313268c16c3e4f1a))
|
428 |
+
- fix condition parsing for unknown values and separate cached into cached and uncached function for simplicity ([3d26421](https://github.com/Viren070/AIOStreams/commit/3d26421b6878cf21edd6c648f5b61f125bf6cb4d))
|
429 |
+
- **frontend:** add customization options for addon name and logo in AboutMenu ([47cc8f6](https://github.com/Viren070/AIOStreams/commit/47cc8f6dd6287d214ba34b0413fee784adbc52a7))
|
430 |
+
- **frontend:** add descriptions to addons and catalog cards ([98c5b71](https://github.com/Viren070/AIOStreams/commit/98c5b71f1e364dc2eb9d97448c2cf5d2bf42b12a))
|
431 |
+
- **frontend:** add shuffle indicator to catalog item ([edd1e4f](https://github.com/Viren070/AIOStreams/commit/edd1e4f8093a9cbb24278f4470d05ff6732acd15))
|
432 |
+
- **frontend:** add tooltip for full service name in service tags for addon card ([5b8ec4d](https://github.com/Viren070/AIOStreams/commit/5b8ec4d9e75822d3ec39e55d5ae503d5f7c5a51f))
|
433 |
+
- **frontend:** add valid formatter snippets and add valid descriptions for proxy services ([12b3f42](https://github.com/Viren070/AIOStreams/commit/12b3f423c0fd1706b9014996978e737d246fcac1))
|
434 |
+
- **frontend:** enhance nightly version display with clickable commit link ([84d53cb](https://github.com/Viren070/AIOStreams/commit/84d53cbdcf835d797312245dc9377da71b0b54d7))
|
435 |
+
- **frontend:** hide menu control button text on smaller screens ([2361e5c](https://github.com/Viren070/AIOStreams/commit/2361e5c373253db928027c2da0ca0eaa54f35579))
|
436 |
+
- **frontend:** improve addons menu, preserve existing catalog settings ([2c5c642](https://github.com/Viren070/AIOStreams/commit/2c5c642b022601e3a41ed74934bd29538eec9d71))
|
437 |
+
- **frontend:** improve services page ([384bdc3](https://github.com/Viren070/AIOStreams/commit/384bdc3a52d67bc85b33f2338b0076d7bd165fc1))
|
438 |
+
- **frontend:** make catalog card title consistent with other cards ([5197331](https://github.com/Viren070/AIOStreams/commit/5197331a79093065f8de326f76bfb2add9c0050a))
|
439 |
+
- **frontend:** services page, parse markdown, toast when duplicate addon ([3bc2538](https://github.com/Viren070/AIOStreams/commit/3bc25387f521792d5a2455a600d459176767497e))
|
440 |
+
- **frontend:** update addon item layout for improved readability ([589e639](https://github.com/Viren070/AIOStreams/commit/589e639870fe9618dcee6e7e221750b1d8a9e17c))
|
441 |
+
- **frontend:** use NumberInput component ([77edb07](https://github.com/Viren070/AIOStreams/commit/77edb07831ac6c4daf628e044fd369534fb58fcc))
|
442 |
+
- **frontend:** use queue and default regex matched to undefined ([2c97ec0](https://github.com/Viren070/AIOStreams/commit/2c97ec04cde252ffdeafac25ecbe5c02148b4385))
|
443 |
+
- identify casted streams from DMM cast as library streams and include full message ([6fd5f5b](https://github.com/Viren070/AIOStreams/commit/6fd5f5b9c03e46667255c9949b3c98b176724ebd))
|
444 |
+
- implement advanced stream filtering with excluded conditions ([302b4cb](https://github.com/Viren070/AIOStreams/commit/302b4cb5c99fe00f21b5b775ef2187f4088717a9)), closes [#57](https://github.com/Viren070/AIOStreams/issues/57)
|
445 |
+
- implement cache statistics logging and configurable interval ([8594ca0](https://github.com/Viren070/AIOStreams/commit/8594ca0374be534cb89dbbee427805202cc08ce6))
|
446 |
+
- implement config validation and addon error handling ([f7b14cd](https://github.com/Viren070/AIOStreams/commit/f7b14cd1dbe54d714fe41881ff9993107746b895))
|
447 |
+
- implement detailed statistics tracking and reporting for stream deduplication process ([89eac41](https://github.com/Viren070/AIOStreams/commit/89eac415a422189d80a3c3c66cde26762bd7f437))
|
448 |
+
- implement disjoint set union (DSU) for stream deduplication, ensuring multiple detection methods are handled correctly ([b0cc718](https://github.com/Viren070/AIOStreams/commit/b0cc718a094f22b4c0cec870e5b06e2ec9e1e7e9))
|
449 |
+
- implement import functionality via modal for JSON files and URLs in TextInputs component ([32b5a5b](https://github.com/Viren070/AIOStreams/commit/32b5a5b7bdfc9b2b27e15eddf060555e6b9c0596))
|
450 |
+
- implement MAX_ADDONS and fix error returning ([ae74926](https://github.com/Viren070/AIOStreams/commit/ae74926ce2e04710771a7166e946f87166985188))
|
451 |
+
- implement pre-caching of the next episode ([980682c](https://github.com/Viren070/AIOStreams/commit/980682cd28e40f84caf1c8f1072fd79ec49ac62b))
|
452 |
+
- implement timeout constraints in preset options using MAX_TIMEOUT and MIN_TIMEOUT ([e415a70](https://github.com/Viren070/AIOStreams/commit/e415a70485fdd33bf5d9b1379d3ede633ea60475))
|
453 |
+
- implement user pruning functionality with configurable intervals and maximum inactivity days ([0bf6fcb](https://github.com/Viren070/AIOStreams/commit/0bf6fcbe9c484c4df6582d76d3bd8fd10567f34b))
|
454 |
+
- improve config handling, define all skip reasons, add env vars to disable addons/hosts/services, ([a301002](https://github.com/Viren070/AIOStreams/commit/a301002ba49fce87e40a28a650e411e5078f769b))
|
455 |
+
- improve formatting of zod errors when using unions ([9c2a970](https://github.com/Viren070/AIOStreams/commit/9c2a970c7d612c9432db70a011663f3f241072ca))
|
456 |
+
- improve French language regex to include common indicators ([163352a](https://github.com/Viren070/AIOStreams/commit/163352a1909faf4e4b45b56222ba08afa023fd7e))
|
457 |
+
- improve handling of unsupport meta id and type ([3779ea0](https://github.com/Viren070/AIOStreams/commit/3779ea09d392ffb3f14b7efcba989ec7cc44bf89))
|
458 |
+
- improve preset/parser system and add mediafusion, comet, stremthru torz, torbox, debridio, en, en+, en+ ([b70a763](https://github.com/Viren070/AIOStreams/commit/b70a763e8b6dc9cfbaf865c8526dd078e1965cb8))
|
459 |
+
- include preset id in formatter ([6053855](https://github.com/Viren070/AIOStreams/commit/6053855f9a3dc5b32bcd8296161ef8ac6df18df8))
|
460 |
+
- make `BASE_URL` required and disable self scraping by default ([d572c04](https://github.com/Viren070/AIOStreams/commit/d572c047e9da4d3cf5be645fd2125b3781b80898))
|
461 |
+
- make caching more configurable and add to sample .env ([1e65fd9](https://github.com/Viren070/AIOStreams/commit/1e65fd9e7dddfe3a0bb9bcf07d77d03fbadf846a))
|
462 |
+
- match years for series too, but don't filter out episode results without a year ([8394f09](https://github.com/Viren070/AIOStreams/commit/8394f0969da665b31074c8e6b9fc15bf9e731b2a))
|
463 |
+
- move 'custom' preset to the beginning ([0b85ff3](https://github.com/Viren070/AIOStreams/commit/0b85ff35e7eba5f62579e117621b212122fd8eca))
|
464 |
+
- **parser:** add support for additional video quality resolutions (144p, 180p, 240p, 360p, 576p) in regex parser ([59d86ff](https://github.com/Viren070/AIOStreams/commit/59d86ffcbfe4d576c49903cdeb8adf197b811963))
|
465 |
+
- prefer results with higher seeders when deduping ([aed775c](https://github.com/Viren070/AIOStreams/commit/aed775c6d5a2b983dc04adbd15b7409a8b11a3a0))
|
466 |
+
- proxy fixes and log adjustments ([091394b](https://github.com/Viren070/AIOStreams/commit/091394b837565f59815bb968dea13fdc356b6160))
|
467 |
+
- remove duplicated info from download streams ([4901745](https://github.com/Viren070/AIOStreams/commit/49017450b9958eabc5a04a098401f2a2561a8e26))
|
468 |
+
- remove useMultipleInstances and debridDownloader options for simplicity and force multiple instances. ([8c0622e](https://github.com/Viren070/AIOStreams/commit/8c0622ea984082dc8c8f678c12d8c962967a70c1))
|
469 |
+
- rename API Key to Addon Password and update related help text in save-install component ([b63813c](https://github.com/Viren070/AIOStreams/commit/b63813c29db53b5a3fbf83c6c042ee10fdda739d))
|
470 |
+
- rename cache to cached in condition parser ([db68a5c](https://github.com/Viren070/AIOStreams/commit/db68a5c0266a5aa05068c4bcbc0c0f0532cd6097))
|
471 |
+
- replace custom HTML div with SettingsCard component for consistent styling ([8611523](https://github.com/Viren070/AIOStreams/commit/86115230bfd5958374294896adc59c83f28d3fee))
|
472 |
+
- revert 89eac415a422189d80a3c3c66cde26762bd7f437 ([34b57c9](https://github.com/Viren070/AIOStreams/commit/34b57c9883901722736cb5d52e0911f6434ddfe3))
|
473 |
+
- service cred env vars, better validation, handling of encrypted values ([61e21cd](https://github.com/Viren070/AIOStreams/commit/61e21cd803981899b4e445c5058fb546db79096d))
|
474 |
+
- start ([3517218](https://github.com/Viren070/AIOStreams/commit/35172188081b688011031439ec26b11e428dd02d))
|
475 |
+
- stuff ([0c9c86c](https://github.com/Viren070/AIOStreams/commit/0c9c86c218c5754e62ff94c0d26d398f32da92a1))
|
476 |
+
- switch to different arrow icons and use built-in hideTextOnSmallScreen prop ([8d307a0](https://github.com/Viren070/AIOStreams/commit/8d307a0c2f755b16074e1a7262204e635853ddfd))
|
477 |
+
- ui improvements ([7e031e5](https://github.com/Viren070/AIOStreams/commit/7e031e51b12cd1fa09e1ed70b90467e8a6bd956e))
|
478 |
+
- ui improvements, check for anime type using kitsu id, loosen schema definitions ([9668a15](https://github.com/Viren070/AIOStreams/commit/9668a152fd116ed9fa9657e935b3b0ed711ce06d))
|
479 |
+
- ui improvments ([39b1e84](https://github.com/Viren070/AIOStreams/commit/39b1e84d87ea4422ebbdab2495d242aeee231562))
|
480 |
+
- update About component with new guide URLs and enhance Getting Started section ([5232e38](https://github.com/Viren070/AIOStreams/commit/5232e3847b4aeb812c44ad0e153b95189ceda607))
|
481 |
+
- update static file serving rate limiting and refactor file path handling ([010b63c](https://github.com/Viren070/AIOStreams/commit/010b63c8725bfb3968c6678b2615675b393fb449))
|
482 |
+
- update TMDB access token input to password type with placeholder ([2378869](https://github.com/Viren070/AIOStreams/commit/23788695e2cedad3a1491c78f17f7e900aa77aeb))
|
483 |
+
- use `API_KEY` as fallback for `ADDON_PASSWORD` to maintain backwards compatability ([5424490](https://github.com/Viren070/AIOStreams/commit/5424490a284aa74e98071a36f3848706f81f5033))
|
484 |
+
- use button for log in/out ([62911ad](https://github.com/Viren070/AIOStreams/commit/62911adfacde25c9f9e7b3551c277c4a7a6340db))
|
485 |
+
- use shorter function names in condition parser ([3bd2751](https://github.com/Viren070/AIOStreams/commit/3bd27519fdfa8cbf9435a48b49f3aeb2992aae42))
|
486 |
+
- use sliders for seeder ranges and fix some options not being multi-option ([915187a](https://github.com/Viren070/AIOStreams/commit/915187a6120dff969dcfe9d4bf9e473673f8ebf0))
|
487 |
+
- validate regexes on config validation ([dd0f45c](https://github.com/Viren070/AIOStreams/commit/dd0f45c731938c37575fb376a981d3c0d2c7a45a))
|
488 |
+
|
489 |
+
### Bug Fixes
|
490 |
+
|
491 |
+
- (mediafusion) increase max streams per resolution limit to 500 ([322b4f3](https://github.com/Viren070/AIOStreams/commit/322b4f375ebbd1047f3e457cf48d75ac9b610d15))
|
492 |
+
- adapt queries for PostgreSQL and SQLite ([e2834d5](https://github.com/Viren070/AIOStreams/commit/e2834d571c709cc9ca3db541da6c1374fb201490))
|
493 |
+
- adapt query for SQLite dialect in DB class ([a7bb898](https://github.com/Viren070/AIOStreams/commit/a7bb8983de03d5f1fb044636133c6f01aaeebf1f))
|
494 |
+
- add back library marker to LightGDriveFormatter ([871f54e](https://github.com/Viren070/AIOStreams/commit/871f54e896a4315f197e6a15b779d4b2a957e8a4))
|
495 |
+
- add back logo.png to v1 path for backwards compatability ([ce5a5b9](https://github.com/Viren070/AIOStreams/commit/ce5a5b99059cd2902d60c9e865503d995ed46df9))
|
496 |
+
- add back y flag ([0e0a18b](https://github.com/Viren070/AIOStreams/commit/0e0a18b9c1f7e65f84af762aab785aa7a79e1222))
|
497 |
+
- add block scope for array modifier handling in BaseFormatter ([02a2885](https://github.com/Viren070/AIOStreams/commit/02a2885d33dfbe355203d4f561408eb82355d939))
|
498 |
+
- add description for stremthru torz ([6e7c142](https://github.com/Viren070/AIOStreams/commit/6e7c14224e5fe90d56dbda7f6ac91d5b87091444))
|
499 |
+
- add extras to cache key for catalog shuffling ([1cdfc6e](https://github.com/Viren070/AIOStreams/commit/1cdfc6e0e3a44f983ac43f1c210257c63c0a78a9))
|
500 |
+
- add France option to DebridioTvPreset language selection ([bd19d01](https://github.com/Viren070/AIOStreams/commit/bd19d01b5434070384ac69278fbc8e21a65bafe9))
|
501 |
+
- add missing audio tags to constant ([fda5ffe](https://github.com/Viren070/AIOStreams/commit/fda5ffe2062f1e6953380c4904c174b81b3b07ef))
|
502 |
+
- add missing braces in parseConnectionURI function for sqlite and postgres cases ([807b681](https://github.com/Viren070/AIOStreams/commit/807b6810ea2b29900408a96e15f934d49b4407d9))
|
503 |
+
- add timeout to fetch requests in TMDBMetadata class to prevent hanging requests ([1a0d57a](https://github.com/Viren070/AIOStreams/commit/1a0d57af43efd68d41a623e2a81b23cb217011da))
|
504 |
+
- add validation for encrypted data format in decryptString function ([843b535](https://github.com/Viren070/AIOStreams/commit/843b535d7ca47c362e254669d0a3f149abe9ffc2))
|
505 |
+
- add verbose logging for resources and fix addon catalog support ([4daa644](https://github.com/Viren070/AIOStreams/commit/4daa6441eede8aa630108c21f8760fa7c19a3745))
|
506 |
+
- adjust cache stat logging behaviour ([d921070](https://github.com/Viren070/AIOStreams/commit/d921070192a4e07e3702b521a7b3819f42da3529))
|
507 |
+
- adjust default rate limit values ([aa98e7b](https://github.com/Viren070/AIOStreams/commit/aa98e7b491a1f7ab9360af8d69490c39bbfd8268))
|
508 |
+
- adjust grid layout in AddonFilterPopover ([632fbf9](https://github.com/Viren070/AIOStreams/commit/632fbf9206dcf5d9532557ca69df42683b5f7ffd))
|
509 |
+
- adjust grouping in season presence check logic ([d89e796](https://github.com/Viren070/AIOStreams/commit/d89e796cb07e534691401e307d28fc89f4176dad))
|
510 |
+
- adjust option name to keep backwards compatability with older configs ([eb651b5](https://github.com/Viren070/AIOStreams/commit/eb651b517db2bf8b91e3c60488f5336049a6bb69))
|
511 |
+
- adjust spacing in predefined formatters and add p2p marker to torbox format ([d8f5d1a](https://github.com/Viren070/AIOStreams/commit/d8f5d1a2d152d2930c0cb03c533748f81f742869))
|
512 |
+
- allow empty strings for formatter definitions ([dba54f5](https://github.com/Viren070/AIOStreams/commit/dba54f5c426e8b0391d3f2b2979b473574968036))
|
513 |
+
- allow null for released in MetaVideoSchema ([ca8d744](https://github.com/Viren070/AIOStreams/commit/ca8d74448ac2479c948a1cc8509cee8a76db0042))
|
514 |
+
- allow null value for description in MetaPreview ([0f16575](https://github.com/Viren070/AIOStreams/commit/0f165752db011c5d525c59bb915edda43afea718))
|
515 |
+
- allow null value in MetaVideoSchema ([73b4d0b](https://github.com/Viren070/AIOStreams/commit/73b4d0b99fc587f7f82515553d92bf7c69647157))
|
516 |
+
- always apply seeder ranges, defaulting seeders to 0 ([0f5dd76](https://github.com/Viren070/AIOStreams/commit/0f5dd764d9577944c587a75423db5256942b583b))
|
517 |
+
- apply negativity to all addon and encode sorting ([411ae7c](https://github.com/Viren070/AIOStreams/commit/411ae7cee234ec8fefe08bf3d844d4711dc37645))
|
518 |
+
- assign unique IDs to each stream to allow consistent comparison ([673ecb2](https://github.com/Viren070/AIOStreams/commit/673ecb2133d3dc5435db7be23cf116b2a6ad34c3))
|
519 |
+
- await precomputation of sort regexes ([56994ef](https://github.com/Viren070/AIOStreams/commit/56994ef9e83248d49e890af99181943c7715d9bb))
|
520 |
+
- call await on all compileRegex calls ([8e87004](https://github.com/Viren070/AIOStreams/commit/8e87004a07a8b5612356f5d346b4b1140a866b64))
|
521 |
+
- carry out regex check for new users too ([1555199](https://github.com/Viren070/AIOStreams/commit/155519951bd5422da9d9fc112e1eca89c4d1fb51))
|
522 |
+
- change image class from object-cover to object-contain in AddonCard component ([734bd88](https://github.com/Viren070/AIOStreams/commit/734bd88d34ba84267934862117a846c8c246e96e))
|
523 |
+
- check if title matching is enabled before attempting to fetch titles ([fd03112](https://github.com/Viren070/AIOStreams/commit/fd03112288bdf00504a6e614993a50170bd7fb43))
|
524 |
+
- coerce runtime to string type in MetaSchema for improved validation ([cc6eea7](https://github.com/Viren070/AIOStreams/commit/cc6eea7e52cc7604806f04459439c7256e1b5aee))
|
525 |
+
- coerce year field to string type in ParsedFileSchema for consistent data handling ([10bef68](https://github.com/Viren070/AIOStreams/commit/10bef68c3625b855a473406dbd9bc4e852fe3cb2))
|
526 |
+
- **comet:** don't make service required for comet ([826edae](https://github.com/Viren070/AIOStreams/commit/826edae8030627bb94591a07c6343ee64e0108f9))
|
527 |
+
- **constants:** add back Dual Audio, Dubbed, and Multi ([7c10930](https://github.com/Viren070/AIOStreams/commit/7c109304ffdf035532514284c021171e91c0fe93))
|
528 |
+
- **core:** actually apply exclude uncached/cached filters ([413a29d](https://github.com/Viren070/AIOStreams/commit/413a29d2d85b50b62042c26f9bed665c7822d11d))
|
529 |
+
- correct handling of year matching and improved normalisation ([bd53adc](https://github.com/Viren070/AIOStreams/commit/bd53adc8f7538243caf121c9b3583cd257dc9181))
|
530 |
+
- correct library marker usage in LightGDriveFormatter ([2470ae9](https://github.com/Viren070/AIOStreams/commit/2470ae94ec2f52f869e3c2edf904500095502b27))
|
531 |
+
- correct spelling of 'committed' in UserRepository class ([551335b](https://github.com/Viren070/AIOStreams/commit/551335bcbaef570a6c6b81d023c1985f6fd19cd2))
|
532 |
+
- correctly handle negate flag ([a65ef19](https://github.com/Viren070/AIOStreams/commit/a65ef19f555d34103cd68e8c021707a61e54cdde))
|
533 |
+
- correctly handle overriden URLs for mediafusion ([46e7e67](https://github.com/Viren070/AIOStreams/commit/46e7e6748e461ec77575efb5ebec4dc7ee50eba7))
|
534 |
+
- correctly handle required filters and remove HDR+DV as a tag after filtering/sorting ([113c150](https://github.com/Viren070/AIOStreams/commit/113c150e143b65eeea5dc2e5e1d74df6c096b8be))
|
535 |
+
- correctly handle undefined parsed file ([8b85a53](https://github.com/Viren070/AIOStreams/commit/8b85a5332d2b33fb6d79139fb6e771d6446b7957))
|
536 |
+
- correctly handle usenet results during deduping ([153366b](https://github.com/Viren070/AIOStreams/commit/153366b41a6b8a08cff8a4cd29ab10dfc1c7d3ac))
|
537 |
+
- correctly import/export FeatureControl ([654b1bc](https://github.com/Viren070/AIOStreams/commit/654b1bc0585d3403836159ac2efde495f4cd44d4))
|
538 |
+
- **custom:** replace 'stremio://' with 'https://' in manifest URL ([0a4a761](https://github.com/Viren070/AIOStreams/commit/0a4a76187d78e924222512f1ca971292463270b7))
|
539 |
+
- **custom:** update manifest URL option to use 'manifestUrl' ([6370ac7](https://github.com/Viren070/AIOStreams/commit/6370ac7d00a75bd626cad67fa448dcaaa9b0a6ba))
|
540 |
+
- decode data before attempting validation ([bdf9a91](https://github.com/Viren070/AIOStreams/commit/bdf9a9198f06e550e0fb3681936e6bfacf483731))
|
541 |
+
- decrypt values for catalog fetching ([6cf8436](https://github.com/Viren070/AIOStreams/commit/6cf843666f97dedc247e52cf6946842d66c50229))
|
542 |
+
- default seeders to 0 for included seeder range ([b0aea2d](https://github.com/Viren070/AIOStreams/commit/b0aea2ddec56da2428f515615251712313138cec))
|
543 |
+
- default seeders to 0 in condition parser too ([53123a3](https://github.com/Viren070/AIOStreams/commit/53123a314c45d39c9d482e5105f47de712fcc7fc))
|
544 |
+
- default value to mediaflow if neither forced or proxy is defined and remove fallback from select value ([61781b7](https://github.com/Viren070/AIOStreams/commit/61781b7e0650713777c7475416e1fc8b837c13fa))
|
545 |
+
- default version to 0.0.0 when not defined ([f031f1a](https://github.com/Viren070/AIOStreams/commit/f031f1a50eabad7d122021ce9b6556694c49af76))
|
546 |
+
- don't fail on invalid external api keys when skip errors is true ([c2db243](https://github.com/Viren070/AIOStreams/commit/c2db243b5798032b75843faf7254969d63ff14b6))
|
547 |
+
- don't make base_url required ([3d7b0da](https://github.com/Viren070/AIOStreams/commit/3d7b0da93fb1add0c6f1d4523411fc0e9512a2b9))
|
548 |
+
- don't make name required in MetaPreview schema ([062247a](https://github.com/Viren070/AIOStreams/commit/062247a89a38d3fad1129a8965a92b6245d5e08e))
|
549 |
+
- don't pass idPrefixes in manifest response ([35ceb87](https://github.com/Viren070/AIOStreams/commit/35ceb87ff325960fc035db735ac8009ab636e09d))
|
550 |
+
- don't validate user data on retrieval within UserRepository ([17873bb](https://github.com/Viren070/AIOStreams/commit/17873bb476d280e6f533cd7cabf8bb8e3e91d518))
|
551 |
+
- enable passthrough on all stremio response schemas ([377d215](https://github.com/Viren070/AIOStreams/commit/377d215c0f5801ff93ec1b0065d0c64ce1fd8217))
|
552 |
+
- encrypt forced proxy URL and credentials before assignment ([e741de3](https://github.com/Viren070/AIOStreams/commit/e741de378775baecd00ee9a8838f3f9fc6ca2bb1))
|
553 |
+
- enhance Japanese language regex to include 'jpn' as an abbreviation ([7a02f12](https://github.com/Viren070/AIOStreams/commit/7a02f12818f64971971bc49b3ec80de594c4a1fe))
|
554 |
+
- ensure debridDownloader defaults to an empty string when no serviceIds are present in StreamFusionPreset ([886a8cb](https://github.com/Viren070/AIOStreams/commit/886a8cb98190fb0e6b4b3d2358103485c9cc6f47))
|
555 |
+
- ensure early return on error handling in catalog route ([6cc20e1](https://github.com/Viren070/AIOStreams/commit/6cc20e124dfe751051f61a700eb4765e8083310e))
|
556 |
+
- ensure tmdb access token, rpdb api key, and password options are filtered out when exclude credentials is on ([299a6d5](https://github.com/Viren070/AIOStreams/commit/299a6d578cef763528095cb80b2337c44d1994e0))
|
557 |
+
- ensure transaction rollback only occurs if not committed in deleteUser method ([67b188e](https://github.com/Viren070/AIOStreams/commit/67b188e7d76b6d0a424f5b86360c2b8a20ddc3b9))
|
558 |
+
- ensure uniqueness of preset instanceIds and disallow dots in instanceId ([3a9be38](https://github.com/Viren070/AIOStreams/commit/3a9be38c77bb7a1b4b991c46902241a6e265b327))
|
559 |
+
- export formatZodError ([af90131](https://github.com/Viren070/AIOStreams/commit/af90131787616a091373e69bf6f8de67e06f1e78))
|
560 |
+
- fallback to undefined when both default and forced value are undefined for proxy id ([efb57bf](https://github.com/Viren070/AIOStreams/commit/efb57bfc3e1a2819712e54c03aee78f967427837))
|
561 |
+
- **formatters:** add message to light gdrive and remove unecessary spacing ([5cb1b0a](https://github.com/Viren070/AIOStreams/commit/5cb1b0a21ed6b29dccf1a56e59434c28da39d1be))
|
562 |
+
- **frontend:** encode password when loading config ([e8971df](https://github.com/Viren070/AIOStreams/commit/e8971df66d8ed79dec7d93bbc790c3de13f54a01))
|
563 |
+
- **frontend:** load existing overriden type in newType ([caeb282](https://github.com/Viren070/AIOStreams/commit/caeb282438edfa8c731b32775840cc5f71c3ec36))
|
564 |
+
- **frontend:** pass seeder info through to formatter ([2ec06a6](https://github.com/Viren070/AIOStreams/commit/2ec06a6f9905c7e1f9c32cc0a5ef56e96872933b))
|
565 |
+
- **frontend:** set default presetInstanceId to 'custom' to pass length check ([ec7a19a](https://github.com/Viren070/AIOStreams/commit/ec7a19a92d2ffc2b06046ab0176f02a4f5b2014e))
|
566 |
+
- **frontend:** try and make dnd better on touchscreen devices ([6aa1130](https://github.com/Viren070/AIOStreams/commit/6aa11301a5dc06eb8674cfb6a834bf181a41eeee))
|
567 |
+
- **frontend:** update filter options to use textValue to correctly show addon name when selected ([6a87480](https://github.com/Viren070/AIOStreams/commit/6a874806b893dbd6382082563f2c45c274e2650b))
|
568 |
+
- give more descriptive errors when no service is provded ([c0b6fd3](https://github.com/Viren070/AIOStreams/commit/c0b6fd3e7dac933b7fd0f10d999a48850c70244e))
|
569 |
+
- handle when drag ends outside drag context ([7a8655d](https://github.com/Viren070/AIOStreams/commit/7a8655dd4326821f2445b1055a819a87a2c3270b))
|
570 |
+
- handle when item doesn't exist in preferred list ([d728bb6](https://github.com/Viren070/AIOStreams/commit/d728bb67bdd872b2d812e3fa0ce1e5352860dff4))
|
571 |
+
- ignore language flags in Torrentio streams if Multi Subs is present ([6d08d7c](https://github.com/Viren070/AIOStreams/commit/6d08d7c0336366c185ad43a89657cbe94dc30278))
|
572 |
+
- ignore recursion checks for certain requests ([d266026](https://github.com/Viren070/AIOStreams/commit/d26602631e030f59ef0f0098633b7f4909db87bc))
|
573 |
+
- improve error handling in TMDBMetadata by including response status and status text ([2f37187](https://github.com/Viren070/AIOStreams/commit/2f371876c151a9b4b0b7db3a4cf1fa14868d4db6))
|
574 |
+
- improve filename sanitization in StreamParser by using Emoji_Presentation to keep numbers and removing identifiers ([714fedb](https://github.com/Viren070/AIOStreams/commit/714fedb2c318a115836faa939c5f888c7785b34c))
|
575 |
+
- include overrideType in catalog modification check ([db473f3](https://github.com/Viren070/AIOStreams/commit/db473f3a32788bb34ed9cede11a24be45979d040))
|
576 |
+
- increase recursion threshold limit and window for improved request handling ([cc2acde](https://github.com/Viren070/AIOStreams/commit/cc2acdeb7ab7dcfdaadc767450065dc8df520f57))
|
577 |
+
- log errors in more cases, correctly handle partial proxy configuration, correctly handle undefined value in tryDecrypt, only decrypt when defined ([56734f0](https://github.com/Viren070/AIOStreams/commit/56734f0956b38998ea802d23e312e0dda2379c88))
|
578 |
+
- make adjustments to how internal addon IDs are determined and fix some things ([a6515de](https://github.com/Viren070/AIOStreams/commit/a6515de2718138cefdad5c4c53617a745ff044c5))
|
579 |
+
- make behaviorHints optional in manifest schema ([313c6bc](https://github.com/Viren070/AIOStreams/commit/313c6bc14e119d62c65bd2cea61eca23af4f4463))
|
580 |
+
- make keyword pattern case insensitive ([795adb3](https://github.com/Viren070/AIOStreams/commit/795adb3e2521a766c92889cc0701e1a8b0d68d96))
|
581 |
+
- make object validation less strict for parsed streams ([e39e690](https://github.com/Viren070/AIOStreams/commit/e39e6900b452b565c6f4c6ed7de151eceb54d38d))
|
582 |
+
- **mediaflow:** add api_password query param when getting public IP ([00e305f](https://github.com/Viren070/AIOStreams/commit/00e305f4f31d9c78741fb0d8d2585b8478d732ea))
|
583 |
+
- **mediaflow:** include api_password in public IP endpoint URL only ([279ff00](https://github.com/Viren070/AIOStreams/commit/279ff003be87febed59ac6f8edb3f0d0d439659a))
|
584 |
+
- **mediafusion:** correctly return encoded user data, and fix parsing ([c6a6350](https://github.com/Viren070/AIOStreams/commit/c6a63502b6049fd403816114547be42e5f44b305))
|
585 |
+
- only add addons that support the type only when idPrefixes is undefined ([d7355cb](https://github.com/Viren070/AIOStreams/commit/d7355cb5983202d08c5d6f863cf5f2f742a6ad97))
|
586 |
+
- only allow p2p on its own addon in StremThruTorzPreset ([510c086](https://github.com/Viren070/AIOStreams/commit/510c086ab0dfbedd089e06ec063837f9e465695f))
|
587 |
+
- only carry out missing title check after checking addons and request types ([eff8d50](https://github.com/Viren070/AIOStreams/commit/eff8d50006d3814af7a4140b0ad9f599eea6bddc))
|
588 |
+
- only exclude a file with excludedLanguages if all its languages are excluded ([2dfb718](https://github.com/Viren070/AIOStreams/commit/2dfb718fa1bca8ae188c5ff55b2f7b1bf7fbbb10))
|
589 |
+
- only filter out resources using specified resources when length greater than 0 ([cd78ead](https://github.com/Viren070/AIOStreams/commit/cd78ead297b8641d4f45ca224d5455ec649ee429))
|
590 |
+
- only use the movie/series specific cached/uncached sort criteria if defined ([049f65b](https://github.com/Viren070/AIOStreams/commit/049f65b18069a0b8c8b8ae7d34e5981cfa34244e))
|
591 |
+
- override stream parser for torz to remove indexer ([f0a448b](https://github.com/Viren070/AIOStreams/commit/f0a448b489585e22af6bcfffbc3ff0a383e35085))
|
592 |
+
- **parser:** match against stream.description and apply fallback logic to stream.title ([a1d2fc9](https://github.com/Viren070/AIOStreams/commit/a1d2fc9981c967254dcb91d1779310c2fd1f8fba))
|
593 |
+
- **parser:** safely access parsedFile properties to handle potential undefined values ([e995f97](https://github.com/Viren070/AIOStreams/commit/e995f97e2f43063f7e69b179237279d5aaba51e8))
|
594 |
+
- pass user provided TMDB access token to TMDBMetadata ([d2f4dc1](https://github.com/Viren070/AIOStreams/commit/d2f4dc1b8dbe17c17e80ac4698398af5a3757cc9))
|
595 |
+
- potentially fix regex sorting ([9771c7b](https://github.com/Viren070/AIOStreams/commit/9771c7be7f8e19c25cebac4439c42a7ae6766459))
|
596 |
+
- potentially fix sorting ([887d285](https://github.com/Viren070/AIOStreams/commit/887d2850f23e883734f2b56d4545e546c07a5694))
|
597 |
+
- prefix addon instance ID to ensure uniquenes of stream id ([009d7d1](https://github.com/Viren070/AIOStreams/commit/009d7d1cf40a1e4041690d5c217b34003f7d51a2))
|
598 |
+
- prevent fetching from aiostreams instance of the same user ([963a3f7](https://github.com/Viren070/AIOStreams/commit/963a3f7064abf0387d0ce49ffb7773659ea88577))
|
599 |
+
- prevent mutating options object in OrionPreset ([f8b08b3](https://github.com/Viren070/AIOStreams/commit/f8b08b3093e49e50acd52aed439ed3e5c7a0674b))
|
600 |
+
- prevent pushing errors for general type support to avoid blocking requests to other addons ([b390534](https://github.com/Viren070/AIOStreams/commit/b390534dae906235836c3fc4a43b3db27dee8324))
|
601 |
+
- reduce timeout duration for resetting values in AddonModal to ensure new modals properly keep their initial values ([9213d78](https://github.com/Viren070/AIOStreams/commit/9213d781d176101f8e7826cc187e44188cf346c4))
|
602 |
+
- refine year matching logic in title filtering for movies ([21f1d3e](https://github.com/Viren070/AIOStreams/commit/21f1d3e0210c84936d2c06b238ede488715d0165))
|
603 |
+
- remove check of non-existent url option in OpenSubtitlesPreset ([dbd5dd6](https://github.com/Viren070/AIOStreams/commit/dbd5dd6bd73abf26ad4c408c17af653dae6ed949))
|
604 |
+
- remove debug logging in getServiceCredentialDefault ([27932a5](https://github.com/Viren070/AIOStreams/commit/27932a54ff683faa01052e5cec1cf450ec5d8603))
|
605 |
+
- remove emojis from filename ([b8bbb17](https://github.com/Viren070/AIOStreams/commit/b8bbb178a8c66eaad6fc5b1637492b1358f12645))
|
606 |
+
- remove log pollution ([5b72292](https://github.com/Viren070/AIOStreams/commit/5b7229299e0f0dfd80a57ed4367a554574b8a9d8))
|
607 |
+
- remove max connections limit from PostgreSQL pool configuration ([bff13dc](https://github.com/Viren070/AIOStreams/commit/bff13dc22c59bb358926867bceefceca1c36574d))
|
608 |
+
- remove unecessary formatBytes function and display actual max size ([5c9406f](https://github.com/Viren070/AIOStreams/commit/5c9406f88e13e538e3683b82c8045899498ec185))
|
609 |
+
- remove unnecessary UUID assignment in UserRepository class ([c8224bc](https://github.com/Viren070/AIOStreams/commit/c8224bc21e496686971e99176d48eb1c859d675e))
|
610 |
+
- remove unused regex environment variables from status route ([2fd0522](https://github.com/Viren070/AIOStreams/commit/2fd05220a480bd70fca5d383d7477be6e7eb5fb2))
|
611 |
+
- remove unused regex fields from StatusResponseSchema ([dfef789](https://github.com/Viren070/AIOStreams/commit/dfef7895b2ad0c2c0b879ad0ce7e1d4410431eeb))
|
612 |
+
- replace crypto random UUID generation with a simple counter for unique ID assignment in StreamParser ([11b2204](https://github.com/Viren070/AIOStreams/commit/11b220443c67c22de475ab22d32ced033e083740))
|
613 |
+
- replace hardcoded SUPPORTED_RESOURCES with supportedResources in NuvioStreamsPreset ([4eeeb59](https://github.com/Viren070/AIOStreams/commit/4eeeb59186668ad1b2d7975e21ea7b90b501bfa7))
|
614 |
+
- replace incorrect hardcoded SUPPORTED_RESOURCES with supportedResources in DebridioPreset ([ed73f5d](https://github.com/Viren070/AIOStreams/commit/ed73f5de6c66ef408f513f54cafee8d2a22e6965))
|
615 |
+
- restore TMDBMetadata import in main.ts and enable metadata export in index.ts ([2cd7d4d](https://github.com/Viren070/AIOStreams/commit/2cd7d4dfd1ada052dad8b21f79a2ffd24eafc178))
|
616 |
+
- return original URL when no modifications are made in CometStreamParser ([cbfb4b7](https://github.com/Viren070/AIOStreams/commit/cbfb4b7838f5a91a401ce7f4d5b5c1a566b222ee))
|
617 |
+
- return url when no modifications are needed in JackettioStreamParser ([4791f36](https://github.com/Viren070/AIOStreams/commit/4791f360da880758ab5d227d2ada8f27ad2f9c64))
|
618 |
+
- **rpdbCatalogs:** correct spelling of 'movies' to 'movie' ([9e1960a](https://github.com/Viren070/AIOStreams/commit/9e1960a6ddd19e6ad705cab30539d6f2c2107321))
|
619 |
+
- **rpdb:** improve id parsing logic and include type for tmdb ([18621ca](https://github.com/Viren070/AIOStreams/commit/18621ca646bb3765963849fd10e25866b253759d))
|
620 |
+
- safely access catalogs options and default to false for streamfusion ([9c48fad](https://github.com/Viren070/AIOStreams/commit/9c48fad6a620e30730b9da9a8074daf016e24105))
|
621 |
+
- save preferred values when adjusting from select menu ([2b329fe](https://github.com/Viren070/AIOStreams/commit/2b329fe6feabdcefcb4c4603a772ec8cf8791a0b))
|
622 |
+
- set default sizeK value to 1024 in StreamParser and remove overridden method in TorrentioParser ([a09dcea](https://github.com/Viren070/AIOStreams/commit/a09dcead9bc6107b25dd8829c66d0b49d1dc49e8))
|
623 |
+
- set public IP to undefined when empty ([32f90fb](https://github.com/Viren070/AIOStreams/commit/32f90fb0f3e5a067ba8f3486bfeb366387b28f01))
|
624 |
+
- simplify and improve validation checks ([dde5af0](https://github.com/Viren070/AIOStreams/commit/dde5af02d9dab1634a2c7cd9e9346b4707011848))
|
625 |
+
- simplify duration formatting in getTimeTakenSincePoint function ([f1afe5f](https://github.com/Viren070/AIOStreams/commit/f1afe5f5a26024b6fbc860abbba902da201996d7))
|
626 |
+
- truncate addon name and update modal value states to handle changes in props ([14f56d1](https://github.com/Viren070/AIOStreams/commit/14f56d12479580033123bbbd312b5bc4ff67f4df))
|
627 |
+
- update addon name formatting in AIOStreamsStreamParser to prefix aiostreams addon name ([eefa184](https://github.com/Viren070/AIOStreams/commit/eefa184b7c0e8e3a2f7779360da94254858f6e6f))
|
628 |
+
- update AIOStream schema export and enhance AIOStreamsStreamParser with validation ([edc310f](https://github.com/Viren070/AIOStreams/commit/edc310fe5f213b4e03976aeb815fd51c81be7976))
|
629 |
+
- update Bengali regex to not match ben the men ([90980c7](https://github.com/Viren070/AIOStreams/commit/90980c76363abdec3d1f53ad2b27eb4181bd8131))
|
630 |
+
- update cached sorting to prefer all streams that are not explicitly marked as uncached ([b16f36d](https://github.com/Viren070/AIOStreams/commit/b16f36d4ea80d4a842281814239aaa23430c5c65))
|
631 |
+
- update default apply mode for cached and uncached filters from 'and' to 'or' ([3fe5027](https://github.com/Viren070/AIOStreams/commit/3fe50274dcfdfaea68103f6477cbc30563327f65))
|
632 |
+
- update default value for ADDON_PASSWORD and SECRET_KEY ([65a4c91](https://github.com/Viren070/AIOStreams/commit/65a4c9177cc8da04990c82fbde939fa4c5452637))
|
633 |
+
- update Dockerfile to use default port fallback for healthcheck and expose ([0ffca95](https://github.com/Viren070/AIOStreams/commit/0ffca9560460a640b763c2a4cabdd3c4a420b6ca))
|
634 |
+
- update duration state to use milliseconds and adjust input handling ([3d43673](https://github.com/Viren070/AIOStreams/commit/3d43673a66f695a1a7547d95a1ef36cd45d27864))
|
635 |
+
- update error handling in OrionStreamParser to throw an error instead of returning an error stream for partial success ([bb30b4a](https://github.com/Viren070/AIOStreams/commit/bb30b4a19a66c6eb8c3b408e64eea33d927bd8ea))
|
636 |
+
- update error message for missing addons to suggest reinstallation ([78a0d7f](https://github.com/Viren070/AIOStreams/commit/78a0d7f788aaa4ea10e2e69ccbd5d79c72bb17d1))
|
637 |
+
- update formatter preview ([f3d84bc](https://github.com/Viren070/AIOStreams/commit/f3d84bc9778a345e837a698c68c2e28ea71752a4))
|
638 |
+
- update GDriveFormatter to use 'inLibrary' instead of 'personal' ([f6ef47f](https://github.com/Viren070/AIOStreams/commit/f6ef47f3a8f7c781a084ffb3d5ba26615edf77fa))
|
639 |
+
- update handling of default/forced values ([c60ef6f](https://github.com/Viren070/AIOStreams/commit/c60ef6fde9c0de6abc98f2cb2de2a7e981719f3e))
|
640 |
+
- update help text to include selected proxy name rather than mediaflow only ([af24d67](https://github.com/Viren070/AIOStreams/commit/af24d674d1c265f9fe9a37f4528548b25790638e))
|
641 |
+
- update MediaFlowProxy to conditionally include api_password in proxy URL for /proxy/ip endpoint ([d0faecc](https://github.com/Viren070/AIOStreams/commit/d0faecc563cd7d2c9ed52310ce658b13ee3fc076))
|
642 |
+
- update MediaFusion logo URL ([3648f94](https://github.com/Viren070/AIOStreams/commit/3648f94d0acdebfde842818335f473fb4564d0e7))
|
643 |
+
- update NameableRegex schema to allow empty name and remove useless regex check ([96d355f](https://github.com/Viren070/AIOStreams/commit/96d355ffdabeb4a308b0f99a9f9a198b8a7d8733))
|
644 |
+
- update Peerflix logo URL ([ab1c216](https://github.com/Viren070/AIOStreams/commit/ab1c21695e596d8fb482f299d31bf44f51ba78fa))
|
645 |
+
- update seeder condition in TorrentioFormatter to allow zero seeders ([c890671](https://github.com/Viren070/AIOStreams/commit/c890671a444f6d82e48d9fdce1308913779d7123))
|
646 |
+
- update service links ([fea2675](https://github.com/Viren070/AIOStreams/commit/fea26752ac521415bf8f23ae022d4ecad7b7e731))
|
647 |
+
- update size filter constraints to allow zero values ([4a8e9c3](https://github.com/Viren070/AIOStreams/commit/4a8e9c3f7d2d463c0e800e542ef63ad0dab813b7))
|
648 |
+
- update social link from Buy Me a Coffee to Ko-fi in DcUniversePreset ([671567c](https://github.com/Viren070/AIOStreams/commit/671567cb433a4912e472d02cf975a1f8037ff223))
|
649 |
+
- update table schema ([f3b4088](https://github.com/Viren070/AIOStreams/commit/f3b4088397a7a09bfc0199bcbf769262a0cb1f75))
|
650 |
+
- update user data merging logic in configuration import ([5ebb539](https://github.com/Viren070/AIOStreams/commit/5ebb539a3e2e5d623a3682dfeeb626781bb2dde0))
|
651 |
+
- update user data reset logic ([9bd9810](https://github.com/Viren070/AIOStreams/commit/9bd9810a7a11132c814024e5182229135e23b42f))
|
652 |
+
- use correct input change handlers ([6f3013c](https://github.com/Viren070/AIOStreams/commit/6f3013cdc2883ef9214538bb9cafba475f692604))
|
653 |
+
- use nullish coalescing for seeder info in formatter to allow values of 0 ([3e5d581](https://github.com/Viren070/AIOStreams/commit/3e5d581cb0861bfd09a26dbb4bfc318abb579d9a))
|
654 |
+
- use structuredClone for config decryption to ensure immutability ([a67603d](https://github.com/Viren070/AIOStreams/commit/a67603d669439465756809b3e1ee9c2637a7bcc5))
|
655 |
+
- wrap handling for join case in block ([85a7775](https://github.com/Viren070/AIOStreams/commit/85a777544593b9a76d7cb8930db8e0321e6511fa))
|
656 |
+
- wrap switch cases in blocks ([16b208b](https://github.com/Viren070/AIOStreams/commit/16b208b05b2450771834954cd54a193af79fdc2d))
|
657 |
+
- **wrapper:** allow empty arrays as valid input in wrapper class ([c64a4f4](https://github.com/Viren070/AIOStreams/commit/c64a4f43ceb1b1eb85658a919ce3759df81556a9))
|
658 |
+
- **wrapper:** enhance error logging for manifest and resource parsing by using formatZodError ([ffc974e](https://github.com/Viren070/AIOStreams/commit/ffc974ede622e970fc5f7396d4f1d1658726228a))
|
659 |
+
|
660 |
+
## [1.22.0](https://github.com/Viren070/AIOStreams/compare/v1.21.1...v1.22.0) (2025-05-22)
|
661 |
+
|
662 |
+
### Features
|
663 |
+
|
664 |
+
- pass `baseUrl` in Easynews++ config and add optional `EASYNEWS_PLUS_PLUS_PUBLIC_URL`. ([b41e210](https://github.com/Viren070/AIOStreams/commit/b41e210c04777b349629dc98f28982bfb2e54886))
|
665 |
+
- stremthru improvements ([#172](https://github.com/Viren070/AIOStreams/issues/172)) ([72b5ab6](https://github.com/Viren070/AIOStreams/commit/72b5ab648e511220d7ff8b4bf453db94bb952b30))
|
CONFIGURING.md
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
> [!NOTE]
|
2 |
+
> This table may be outdated, please look at [settings.ts](https://github.com/Viren070/AIOStreams/blob/main/packages/utils/src/settings.ts) for the full list of environment variables you can set.
|
3 |
+
|
4 |
+
| Environment Variable | Default Value | Description |
|
5 |
+
|------------------------------------|------------------------------------------------------|---------------------------------------------------------------------------------------------|
|
6 |
+
| `ADDON_NAME` | `AIOStreams` | The name of the addon. |
|
7 |
+
| `ADDON_ID` | `aiostreams.viren070.com` | The unique identifier for the addon. |
|
8 |
+
| `PORT` | `3000` | The port on which the server runs. |
|
9 |
+
| `BRANDING` | `undefined` | Custom branding for the addon, displayed at the top of the configuration page. **This is a BUILD TIME environment variable.** |
|
10 |
+
| `SECRET_KEY` | Empty string (`''`) | The secret key used for encryption or sensitive operations. `openssl rand -hex 32` or `[System.Guid]::NewGuid().ToString("N").Substring(0, 32) + [System.Guid]::NewGuid().ToString("N").Substring(0, 32)` can be used to generate a new secret key for Linux/MacoS and Windows respectively. |
|
11 |
+
| `CUSTOM_CONFIGS` | Empty string (`''`) | Custom configurations in JSON format, using the alias as the key, and the encoded/encrypted string as the value. e.g. {"default": "eyJyZXNvbHV0....", "rd": "E-affedc...}. <br/><br/>In this case, using /default/manifest.json would use the configuration stored at the `default` key.<br/><br/>To easily generate the value for this environment variable, head to /custom-config-generator on your instance to find a tool that outputs the necessary value based on your configurations. |
|
12 |
+
| `DISABLE_CUSTOM_CONFIG_GENERATOR_ROUTE` | `false` | Whether to disable the /custom-config-generator route |
|
13 |
+
| `COMET_URL` | `https://comet.elfhosted.com/` | The URL for the Comet addon. You can replace this with your self-hosted instance of Comet. |
|
14 |
+
| `MEDIAFUSION_URL` | `https://mediafusion.elfhosted.com/` | The URL for the MediaFusion addon |
|
15 |
+
| `MEDIAFUSION_API_PASSWORD` | Empty string (`''`) | The API_PASSWORD variable you set for your self-hosted MediaFusion instance. This is required if you want AIOStreams to generate configurations for MediaFusion based on the services you entered. If you provide the override url option for MediaFusion, this environment variable isn't required |
|
16 |
+
| `TORRENTIO_URL` | `https://torrentio.strem.fun/` | The URL for the Torrentio addon. |
|
17 |
+
| `TORBOX_STREMIO_URL` | `https://stremio.torbox.app/` | The URL for the Torbox Stremio addon. |
|
18 |
+
| `EASYNEWS_URL` | `https://ea627ddf0ee7-easynews.baby-beamup.club/` | The URL for the Easynews addon. |
|
19 |
+
| `EASYNEWS_PLUS_URL` | `https://b89262c192b0-stremio-easynews-addon.baby-beamup.club/` | The URL for the Easynews Plus addon. This can be replaced with your self-hosted instance |
|
20 |
+
| `ADDON_PROXY` | Empty string (`''`) | You can run the requests AIOStreams makes to other addons through a proxy such as https://github.com/cmj2002/warp-docker |
|
21 |
+
| `DEFAULT_MEDIAFLOW_URL` | Empty string (`''`) | You can set a default MediaFlow URL. All configurations made at an instance with this enabled will use this MediaFlow URL if it is not overriden by a user-set URL at the configure page |
|
22 |
+
| `DEFAULT_MEDIAFLOW_API_PASSWORD` | Empty string (`''`) | The API password for the default MediaFlow URL. |
|
23 |
+
| `DEFAULT_MEDIAFLOW_PUBLIC_IP` | Empty string (`''`) | Public IP for the default MediaFlow instance. This IP is forwarded to other addons |
|
24 |
+
| `MAX_ADDONS` | `15` | Maximum number of addons allowed. |
|
25 |
+
| `CACHE_STREAM_RESULTS` | `true` | Whether to cache the responses from addons for a specific requests. Only useful when the exact same request with the same debrid service configuration is repeated within a small timeframe. This can end up overwriting the MediaFlow public IPs depending on how many users are using the instance |
|
26 |
+
| `CACHE_STREAM_RESULTS_TTL` | `600` | The time to live (TTL) for cached stream responses in seconds. Cache that becomes older than this time is discarded |
|
27 |
+
| `CACHE_MEDIAFLOW_IP_TTL` | `900` | The time to live (TTL) for cached public IPs for the same MediaFlow URL and password. |
|
28 |
+
| `MAX_CACHE_SIZE` | `1024` | Maximum number of items the memory cache can hold. The cache stores streams from addon responses (for 10 minutes) and MediaFlow Public IPs (for 5 minutes). |
|
29 |
+
| `MAX_KEYWORD_FILTERS` | `30` | The maximum number of individual filters that you are allowed to enter for all keyword filters |
|
30 |
+
| `MAX_MOVIE_SIZE` | `161061273600` (150 GiB) | The maximum movie size that the user can set with the slider at the configuration page |
|
31 |
+
| `MAX_EPISODE_SIZE` | `16106127360` (15 GiB) | The maximum episode size that the user can set with the slider at the configuration page |
|
32 |
+
| `MAX_TIMEOUT` | `50000` | Maximum timeout that can be entered by the user in the configuration options |
|
33 |
+
| `MIN_TIMEOUT` | `1000` | Minimum timeout that can be entered by the user in the configuration options |
|
34 |
+
| `MEDIAFLOW_IP_TIMEOUT` | `30000` | The timeout for public IP requests to MediaFlow. When AIOStreams fails to get the IP, it will not make the request to the addon.
|
35 |
+
| `DEFAULT_TIMEOUT` | `15000` | The value of this environment variable applies to all addon requests by default, unless overriden by an addon specific environment variable. <br/><br/>What this means is that this value essentially controls the time you wait for AIOStreams to response. As AIOStreams barely takes any time for its post-sorting and filtering. If all timeouts are set to 5000ms, the addon is forced to respond within 5 seconds, as all addon requests are carried out concurrently. |
|
36 |
+
| `DEFAULT_TORRENTIO_TIMEOUT` | `5000` | Default timeout for Torrentio requests (in milliseconds). |
|
37 |
+
| `DEFAULT_TORBOX_TIMEOUT` | `15000` | Default timeout for Torbox requests (in milliseconds). |
|
38 |
+
| `DEFAULT_COMET_TIMEOUT` | `15000` | Default timeout for Comet requests (in milliseconds). |
|
39 |
+
| `DEFAULT_MEDIAFUSION_TIMEOUT` | `15000` | Default timeout for MediaFusion requests (in milliseconds). |
|
40 |
+
| `DEFAULT_EASYNEWS_TIMEMOUT` | `15000` | Default timeout for Easynews requests (in milliseconds). |
|
41 |
+
| `DEFAULT_EASYNEWS_PLUS_TIMEMOUT` | `15000` | Default timeout for Easynews Plus requests (in milliseconds). |
|
42 |
+
| `SHOW_DIE` | `true` | Whether to display the die emoji in AIOStreams results |
|
43 |
+
| `LOG_SENSITIVE_INFO` | `false` | Whether to log sensitive information. |
|
44 |
+
| `DISABLE_TORRENTIO` | `false` | Whether to disable adding Torrentio as an addon, through override URLs, custom addons, or through the public ElfHosted instance of StremThru |
|
45 |
+
| `DISABLE_TORRENTIO_MESSAGE` | `''The Torrentio addon has been disabled, please remove it to use this addon.'`| The message shown when `DISABLE_TORRENTIO` is `true` and Torrentio is present in the configuration |
|
Dockerfile
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM node:22-alpine AS builder
|
2 |
+
|
3 |
+
WORKDIR /build
|
4 |
+
|
5 |
+
# Copy LICENSE file.
|
6 |
+
COPY LICENSE ./
|
7 |
+
|
8 |
+
# Copy the relevant package.json and package-lock.json files.
|
9 |
+
COPY package*.json ./
|
10 |
+
COPY packages/server/package*.json ./packages/server/
|
11 |
+
COPY packages/core/package*.json ./packages/core/
|
12 |
+
COPY packages/frontend/package*.json ./packages/frontend/
|
13 |
+
|
14 |
+
# Install dependencies.
|
15 |
+
RUN npm install
|
16 |
+
|
17 |
+
# Copy source files.
|
18 |
+
COPY tsconfig.*json ./
|
19 |
+
|
20 |
+
COPY packages/server ./packages/server
|
21 |
+
COPY packages/core ./packages/core
|
22 |
+
COPY packages/frontend ./packages/frontend
|
23 |
+
COPY scripts ./scripts
|
24 |
+
COPY resources ./resources
|
25 |
+
|
26 |
+
|
27 |
+
# Build the project.
|
28 |
+
RUN npm run build
|
29 |
+
|
30 |
+
# Remove development dependencies.
|
31 |
+
RUN npm --workspaces prune --omit=dev
|
32 |
+
|
33 |
+
FROM node:22-alpine AS final
|
34 |
+
|
35 |
+
WORKDIR /app
|
36 |
+
|
37 |
+
# Copy the built files from the builder.
|
38 |
+
# The package.json files must be copied as well for NPM workspace symlinks between local packages to work.
|
39 |
+
COPY --from=builder /build/package*.json /build/LICENSE ./
|
40 |
+
|
41 |
+
COPY --from=builder /build/packages/core/package.*json ./packages/core/
|
42 |
+
COPY --from=builder /build/packages/frontend/package.*json ./packages/frontend/
|
43 |
+
COPY --from=builder /build/packages/server/package.*json ./packages/server/
|
44 |
+
|
45 |
+
COPY --from=builder /build/packages/core/dist ./packages/core/dist
|
46 |
+
COPY --from=builder /build/packages/frontend/out ./packages/frontend/out
|
47 |
+
COPY --from=builder /build/packages/server/dist ./packages/server/dist
|
48 |
+
|
49 |
+
COPY --from=builder /build/resources ./resources
|
50 |
+
|
51 |
+
COPY --from=builder /build/node_modules ./node_modules
|
52 |
+
|
53 |
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
54 |
+
CMD wget --no-verbose --tries=1 --spider http://localhost:${PORT:-3000}/api/v1/status || exit 1
|
55 |
+
|
56 |
+
EXPOSE ${PORT:-3000}
|
57 |
+
|
58 |
+
ENTRYPOINT ["npm", "run", "start"]
|
LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2024 Viren070
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE.
|
README.md
CHANGED
@@ -1,12 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
10 |
---
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p align="center">
|
2 |
+
<img src="https://raw.githubusercontent.com/Viren070/AIOStreams/main/packages/frontend/public/assets/logo.png" alt="AIOStreams Logo" width="200"/>
|
3 |
+
</p>
|
4 |
+
|
5 |
+
<h1 align="center">AIOStreams</h1>
|
6 |
+
|
7 |
+
<p align="center">
|
8 |
+
<strong>One addon to rule them all.</strong>
|
9 |
+
<br />
|
10 |
+
AIOStreams consolidates multiple Stremio addons and debrid services into a single, highly customisable super-addon.
|
11 |
+
</p>
|
12 |
+
|
13 |
+
<p align="center">
|
14 |
+
<a href="https://github.com/Viren070/AIOStreams/actions/workflows/deploy-docker.yml">
|
15 |
+
<img src="https://img.shields.io/github/actions/workflow/status/viren070/aiostreams/deploy-docker.yml?style=for-the-badge&logo=github" alt="Build Status">
|
16 |
+
</a>
|
17 |
+
<a href="https://github.com/Viren070/AIOStreams/releases/latest">
|
18 |
+
<img src="https://img.shields.io/github/v/release/viren070/aiostreams?style=for-the-badge&logo=github" alt="Latest Release">
|
19 |
+
</a>
|
20 |
+
<a href="https://github.com/Viren070/AIOStreams/stargazers">
|
21 |
+
<img src="https://img.shields.io/github/stars/Viren070/AIOStreams?style=for-the-badge&logo=github" alt="GitHub Stars">
|
22 |
+
</a>
|
23 |
+
<a href="https://hub.docker.com/r/viren070/aiostreams">
|
24 |
+
<img src="https://img.shields.io/docker/pulls/viren070/aiostreams?style=for-the-badge&logo=docker" alt="Docker Pulls">
|
25 |
+
</a>
|
26 |
+
<a href="https://discord.gg/aiostreams">
|
27 |
+
<img src="https://img.shields.io/badge/Discord-Join_Chat-7289DA?logo=discord&logoColor=white&style=for-the-badge" alt="Discord Server">
|
28 |
+
</a>
|
29 |
+
</p>
|
30 |
+
|
31 |
+
---
|
32 |
+
|
33 |
+
## ✨ What is AIOStreams?
|
34 |
+
|
35 |
+
AIOStreams was created to give users ultimate control over their Stremio experience. Instead of juggling multiple addons with different configurations and limitations, AIOStreams acts as a central hub. It fetches results from all your favorite sources, then filters, sorts, and formats them according to *your* rules before presenting them in a single, clean list.
|
36 |
+
|
37 |
+
Whether you're a casual user who wants a simple, unified stream list or a power user who wants to fine-tune every aspect of your results, AIOStreams has you covered.
|
38 |
+
|
39 |
+
|
40 |
+
<p align="center">
|
41 |
+
<img src="https://github.com/user-attachments/assets/6179efdb-abc9-4e0c-ae11-fb0e3ca9606a" alt="AIOStreams in action" width="750" />
|
42 |
+
</p>
|
43 |
+
|
44 |
+
## 🚀 Key Features
|
45 |
+
|
46 |
+
### 🔌 All Your Addons, One Interface
|
47 |
+
- **Unified Results**: Aggregate streams from multiple addons into one consistently sorted and formatted list.
|
48 |
+
- **Simplified Addon Management**: AIOStreams features a built-in addon marketplace. Many addons require you to install them multiple times to support different debrid services. AIOStreams handles this automatically. Just enable an addon from the marketplace, and AIOStreams dynamically applies your debrid keys, so you only have to configure it once.
|
49 |
+
- **Automatic Updates**: Because addon manifests are generated dynamically, you get the latest updates and fixes without ever needing to reconfigure or reinstall.
|
50 |
+
- **Custom Addon Support**: Add *any* Stremio addon by providing its configured URL. If it works in Stremio, it works here.
|
51 |
+
- **Full Stremio Support**: AIOStreams doesn't just manage streams; it supports all Stremio resources, including catalogs, metadata, and even addon catalogs.
|
52 |
+
|
53 |
+
<p align="center">
|
54 |
+
<img src="https://github.com/user-attachments/assets/eb47063c-7519-4619-804f-ad84a34d6591" alt="Addon Configuration" width="750"/>
|
55 |
+
</p>
|
56 |
+
|
57 |
+
### 🔬 Advanced Filtering & Sorting Engine
|
58 |
+
Because all addons are routed through AIOStreams, you only have to **configure your filters and sorting rules once**. This powerful, centralized engine offers far more options and flexibility than any individual addon.
|
59 |
+
|
60 |
+
- **Granular Filtering**: Define `include` (prevents filtering), `required`, or `excluded` rules for a huge range of properties:
|
61 |
+
- **Video/Audio**: Resolution, quality, encodes, visual tags (`HDR`, `DV`), audio tags (`Atmos`), and channels.
|
62 |
+
- **Source**: Stream type (`Debrid`, `Usenet`, `P2P`), language, seeder ranges, and cached/uncached status (can be applied to specific addons/services).
|
63 |
+
- **Preferred Lists**: Manually define and order a list of preferred properties to prioritize certain results, for example, always showing `HDR` streams first.
|
64 |
+
- **Keyword & Regex Filtering**: Filter by simple keywords or complex regex patterns matched against filenames, indexers and release groups for ultimate precision.
|
65 |
+
- **Accurate Title Matching**: Leverages the TMDB API to precisely match titles, years, and season/episode numbers, ensuring you always get the right content. This can be granularly applied to specific addons or content types.
|
66 |
+
- **Powerful Conditional Engine**: Create dynamic rules with a simple yet powerful expression language.
|
67 |
+
- *Example*: Only exclude 720p streams if more than five 1080p streams are available: `count(resolution(streams, '1080p')) > 5 ? resolution(streams, '720p') : false`.
|
68 |
+
- Check the wiki for a [full function reference](https://github.com/Viren070/AIOStreams/wiki/Stream-Expression-Language).
|
69 |
+
- **Customisable Deduplication**: Choose how duplicate streams are detected: by filename, infohash, and a unique "smart detect" hash generated from certain file attributes.
|
70 |
+
- **Sophisticated Sorting**:
|
71 |
+
- Build your perfect sort order using any combination of criteria.
|
72 |
+
- Define separate sorting logic for movies, series, anime, and even for cached vs. uncached results.
|
73 |
+
- The sorting system automatically uses the rankings from your "Preferred Lists".
|
74 |
+
|
75 |
+
### 🗂️ Unified Catalog Management
|
76 |
+
Take control of your Stremio home page. AIOStreams lets you manage catalogs from all your addons in one place.
|
77 |
+
- **Rename**: Rename both the name and the type of the catalog to whatever you want. (e.g. Changing Cinemeta's `Popular - Movies` to `Popular - 📺`)
|
78 |
+
- **Reorder & Disable**: Arrange catalogs in your preferred order or hide the ones you don't use.
|
79 |
+
- **Shuffle Catalogs**: Discover new content by shuffling the results of any catalog. You can even persist the shuffle for a set period.
|
80 |
+
- **Enhanced Posters**: Automatically apply high-quality posters from [RPDB](https://rpdb.net/) to catalogs that provide a supported metadata source, even if the original addon doesn't support it.
|
81 |
+
|
82 |
+
<p align="center">
|
83 |
+
|
84 |
+
<img src="https://github.com/user-attachments/assets/12c26705-a373-42b4-9164-0c23b9e9cbe6" alt="Filtering and Sorting Rules" width="750"/>
|
85 |
+
</p>
|
86 |
+
|
87 |
+
### 🎨 Total Customization
|
88 |
+
- **Custom Stream Formatting**: Design exactly how stream information is displayed using a powerful templating system.
|
89 |
+
- **Live Preview**: See your custom format changes in real-time as you build them.
|
90 |
+
- **Predefined Formats**: Get started quickly with built-in formats, some created by me and others inspired by other popular addons like Torrentio and the TorBox Stremio Addon.
|
91 |
+
- **[Custom Formatter Wiki](https://github.com/Viren070/AIOStreams/wiki/Custom-Formatter)**: Dive deep into the documentation to create your perfect stream title.
|
92 |
+
|
93 |
+
|
94 |
+
<p align="center">
|
95 |
+
<img src="https://github.com/user-attachments/assets/906cc3fc-16d1-4702-99c7-425b2445387b" alt="Custom Formatter UI" width="750"/>
|
96 |
+
</p>
|
97 |
+
|
98 |
+
<p align="center">
|
99 |
+
<sub>
|
100 |
+
This format was created by one of our community members in the
|
101 |
+
<a href="https://discord.gg/aiostreams">Discord Server</a>
|
102 |
+
</sub>
|
103 |
+
</p>
|
104 |
+
|
105 |
+
|
106 |
+
### 🛡️ Proxy & Performance
|
107 |
+
- **Proxy Integration**: Seamlessly proxy streams through **[MediaFlow Proxy](https://github.com/mhdzumair/mediaflow-proxy)** or **[StremThru](https://github.com/MunifTanjim/stremthru)**.
|
108 |
+
- **Bypass IP Restrictions**: Essential for services that limit simultaneous connections from different IP addresses.
|
109 |
+
- **Improve Compatibility**: Fixes playback issues with certain players (like Infuse) and addons.
|
110 |
+
|
111 |
+
And much much more...
|
112 |
+
|
113 |
+
## 🚀 Getting Started
|
114 |
+
|
115 |
+
Setting up AIOStreams is simple.
|
116 |
+
|
117 |
+
1. **Choose a Hosting Method**
|
118 |
+
- **🔓 Public Instance**: Use the **[Community Instance (Hosted by ElfHosted)](https://aiostreams.elfhosted.com/configure)**. It's free, but rate-limited and has Torrentio disabled.
|
119 |
+
- **🛠️ Self-Host / Paid Hosting**: For full control and no rate limits, host it yourself (Docker) or use a paid service like **[ElfHosted](https://store.elfhosted.com/product/aiostreams/elf/viren070/)** (using this link supports the project!).
|
120 |
+
|
121 |
+
2. **Configure Your Addon**
|
122 |
+
- Open the `/stremio/configure` page of your AIOStreams instance in a web browser.
|
123 |
+
- Enable the addons you use, add your debrid API keys, and set up your filtering, sorting, and formatting rules.
|
124 |
+
|
125 |
+
3. **Install**
|
126 |
+
- Click the "Install" button. This will open your Stremio addon compatible app and add your newly configured AIOStreams addon.
|
127 |
+
|
128 |
+
For detailed instructions, check out the Wiki:
|
129 |
+
- **[Deployment Guide](https://github.com/Viren070/AIOStreams/wiki/Deployment)**
|
130 |
+
- **[Configuration Guide](https://github.com/Viren070/AIOStreams/wiki/Configuration)**
|
131 |
+
|
132 |
---
|
133 |
+
|
134 |
+
## ❤️ Support the Project
|
135 |
+
|
136 |
+
AIOStreams is a passion project developed and maintained for free. If you find it useful, please consider supporting its development.
|
137 |
+
|
138 |
+
- ⭐ **Star the Repository** on [GitHub](https://github.com/Viren070/AIOStreams).
|
139 |
+
- ⭐ **Star the Addon** in the [Stremio Community Catalog](https://beta.stremio-addons.net/addons/aiostreams).
|
140 |
+
- 🤝 **Contribute**: Report issues, suggest features, or submit pull requests.
|
141 |
+
- ☕ **Donate**:
|
142 |
+
- **[Ko-fi](https://ko-fi.com/viren070)**
|
143 |
+
- **[GitHub Sponsors](https://github.com/sponsors/Viren070)**
|
144 |
+
|
145 |
---
|
146 |
|
147 |
+
## ⚠️ Disclaimer
|
148 |
+
|
149 |
+
AIOStreams is a tool for aggregating and managing data from other Stremio addons. It does not host, store, or distribute any content. The developer does not endorse or promote access to copyrighted content. Users are solely responsible for complying with all applicable laws and the terms of service for any addons or services they use with AIOStreams.
|
150 |
+
|
151 |
+
## 🙏 Credits
|
152 |
+
|
153 |
+
This project wouldn't be possible without the foundational work of many others in the community, especially those who develop the addons that AIOStreams integrates. Special thanks to the developers of all the integrated addons, the creators of [mhdzumair/mediaflow-proxy](https://github.com/mhdzumair/mediaflow-proxy) and [MunifTanjim/stremthru](https://github.com/MunifTanjim/stremthru), and the open-source projects that inspired parts of AIOStreams' design:
|
154 |
+
|
155 |
+
* UI Components and issue templates adapted with permission from [5rahim/seanime](https://github.com/5rahim/seanime) (which any anime enthusiast should definitely check out!)
|
156 |
+
* [sleeyax/stremio-easynews-addon](https://github.com/sleeyax/stremio-easynews-addon) for the projects initial structure
|
157 |
+
* Custom formatter system inspired by and adapted from [diced/zipline](https://github.com/diced/zipline).
|
158 |
+
* Condition engine powered by [expr-eval](https://github.com/silentmatt/expr-eval)
|
compose.yaml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
services:
|
2 |
+
aiostreams:
|
3 |
+
image: ghcr.io/viren070/aiostreams:latest
|
4 |
+
container_name: aiostreams
|
5 |
+
restart: unless-stopped
|
6 |
+
ports:
|
7 |
+
- 3000:3000
|
8 |
+
env_file:
|
9 |
+
- .env
|
10 |
+
volumes:
|
11 |
+
- ./data:/app/data
|
12 |
+
healthcheck:
|
13 |
+
test: wget -qO- http://localhost:3000/api/v1/status
|
14 |
+
interval: 1m
|
15 |
+
timeout: 10s
|
16 |
+
retries: 5
|
17 |
+
start_period: 10s
|
fetch-proxy.js
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const express = require('express');
|
2 |
+
const cors = require('cors');
|
3 |
+
const fetch = require('node-fetch');
|
4 |
+
|
5 |
+
const app = express();
|
6 |
+
app.use(cors());
|
7 |
+
app.use(express.json());
|
8 |
+
|
9 |
+
// Handle GET requests to /fetch?url=... (for Cloudflare Worker)
|
10 |
+
app.get('/fetch', async (req, res) => {
|
11 |
+
try {
|
12 |
+
const { url, method = 'GET' } = req.query;
|
13 |
+
|
14 |
+
if (!url) {
|
15 |
+
return res.status(400).json({ error: 'URL parameter is required' });
|
16 |
+
}
|
17 |
+
|
18 |
+
console.log(`GET /fetch - Proxying request to: ${url}`);
|
19 |
+
|
20 |
+
const response = await fetch(url, {
|
21 |
+
method: method.toUpperCase(),
|
22 |
+
headers: {
|
23 |
+
'User-Agent': 'AIOStreams-Proxy/1.0',
|
24 |
+
'Accept': '*/*',
|
25 |
+
},
|
26 |
+
});
|
27 |
+
|
28 |
+
const data = await response.text();
|
29 |
+
|
30 |
+
// Forward the status code and content
|
31 |
+
res.status(response.status);
|
32 |
+
|
33 |
+
// Forward important headers
|
34 |
+
const contentType = response.headers.get('content-type');
|
35 |
+
if (contentType) {
|
36 |
+
res.set('Content-Type', contentType);
|
37 |
+
}
|
38 |
+
|
39 |
+
res.send(data);
|
40 |
+
} catch (error) {
|
41 |
+
console.error('GET Proxy error:', error);
|
42 |
+
res.status(500).json({ error: error.message });
|
43 |
+
}
|
44 |
+
});
|
45 |
+
|
46 |
+
// Handle POST requests to / (existing functionality)
|
47 |
+
app.post('/', async (req, res) => {
|
48 |
+
try {
|
49 |
+
const { url, method = 'GET', headers = {}, body } = req.body;
|
50 |
+
|
51 |
+
if (!url) {
|
52 |
+
return res.status(400).json({ error: 'URL is required in request body' });
|
53 |
+
}
|
54 |
+
|
55 |
+
console.log(`POST / - Proxying request to: ${url}`);
|
56 |
+
|
57 |
+
const response = await fetch(url, {
|
58 |
+
method,
|
59 |
+
headers: {
|
60 |
+
'User-Agent': 'AIOStreams-Proxy/1.0',
|
61 |
+
...headers,
|
62 |
+
},
|
63 |
+
body: body ? JSON.stringify(body) : undefined,
|
64 |
+
});
|
65 |
+
|
66 |
+
const data = await response.text();
|
67 |
+
|
68 |
+
res.status(response.status).send(data);
|
69 |
+
} catch (error) {
|
70 |
+
console.error('POST Proxy error:', error);
|
71 |
+
res.status(500).json({ error: error.message });
|
72 |
+
}
|
73 |
+
});
|
74 |
+
|
75 |
+
// Health check endpoint
|
76 |
+
app.get('/health', (req, res) => {
|
77 |
+
res.json({ status: 'ok', timestamp: new Date().toISOString() });
|
78 |
+
});
|
79 |
+
|
80 |
+
// Root endpoint with usage info
|
81 |
+
app.get('/', (req, res) => {
|
82 |
+
res.json({
|
83 |
+
message: 'AIOStreams Fetch Proxy',
|
84 |
+
endpoints: {
|
85 |
+
'GET /fetch?url=<url>': 'Proxy a GET request to the specified URL',
|
86 |
+
'POST /': 'Proxy a request with full control (url, method, headers, body in JSON)',
|
87 |
+
'GET /health': 'Health check'
|
88 |
+
},
|
89 |
+
examples: {
|
90 |
+
get: '/fetch?url=https://example.com',
|
91 |
+
post: 'POST / with {"url": "https://example.com", "method": "GET"}'
|
92 |
+
}
|
93 |
+
});
|
94 |
+
});
|
95 |
+
|
96 |
+
const PORT = process.env.PORT || 3128;
|
97 |
+
app.listen(PORT, () => {
|
98 |
+
console.log(`Fetch proxy running on port ${PORT}`);
|
99 |
+
console.log(`Endpoints:`);
|
100 |
+
console.log(` GET /fetch?url=<url> - Simple proxy for GET requests`);
|
101 |
+
console.log(` POST / - Full proxy with method/headers/body control`);
|
102 |
+
console.log(` GET /health - Health check`);
|
103 |
+
});
|
nginx.conf
ADDED
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ===================================================================
|
2 |
+
# nginx.conf (or a file under /etc/nginx/conf.d/aiostreams.conf)
|
3 |
+
# ===================================================================
|
4 |
+
#
|
5 |
+
# This config listens on port 443 for aiostreams.bolabaden.org (HTTPS),
|
6 |
+
# and proxies all requests to one of three upstreams:
|
7 |
+
# - aiostreams-cf.bolabaden.org
|
8 |
+
# - aiostreams-koyeb.bolabaden.org
|
9 |
+
# - aiostreams.bolabaden.duckdns.org
|
10 |
+
#
|
11 |
+
# If any one of the three backends becomes unreachable (TCP error, 5xx, etc.),
|
12 |
+
# NGINX will mark it “down” for a short period and continue sending new requests
|
13 |
+
# to the remaining healthy backends. When it recovers, NGINX will automatically
|
14 |
+
# send traffic to it again.
|
15 |
+
#
|
16 |
+
# We use “ip_hash” so that each client IP tends to hit the same backend (session affinity).
|
17 |
+
# If that backend dies, NGINX will transparently route the next request to another healthy
|
18 |
+
# backend. No DNS‐level trickery is used here—NGINX does all proxying at L7.
|
19 |
+
#
|
20 |
+
# Replace the SSL certificate/key paths below with your actual .crt/.key files.
|
21 |
+
|
22 |
+
################################################################################
|
23 |
+
# 1) GLOBAL CONTEXT / EVENTS
|
24 |
+
################################################################################
|
25 |
+
|
26 |
+
user nginx;
|
27 |
+
worker_processes auto;
|
28 |
+
error_log /var/log/nginx/error.log notice;
|
29 |
+
pid /var/run/nginx.pid;
|
30 |
+
|
31 |
+
events {
|
32 |
+
worker_connections 1024;
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
################################################################################
|
37 |
+
# 2) HTTP CONTEXT
|
38 |
+
################################################################################
|
39 |
+
|
40 |
+
http {
|
41 |
+
# mime types, log format, etc. can be inherited from defaults.
|
42 |
+
include /etc/nginx/mime.types;
|
43 |
+
default_type application/octet-stream;
|
44 |
+
|
45 |
+
# Tuning timeouts for proxy connections:
|
46 |
+
send_timeout 30s;
|
47 |
+
keepalive_timeout 65s;
|
48 |
+
client_max_body_size 10m;
|
49 |
+
|
50 |
+
# ------------------------------------------------------------------------
|
51 |
+
# 2.a) Define the upstream block with all three backends
|
52 |
+
# “ip_hash” ensures session‐affinity by client IP. If that server fails,
|
53 |
+
# NGINX (passively) marks it down (max_fails + fail_timeout) and sends
|
54 |
+
# to the next available IP.
|
55 |
+
#
|
56 |
+
# Note: We are proxying to each backend over HTTPS (port 443),
|
57 |
+
# so we append “:443 ssl” to each server line. NGINX by default will
|
58 |
+
# initiate an SSL hand‐shake to the upstream.
|
59 |
+
# ------------------------------------------------------------------------
|
60 |
+
|
61 |
+
upstream aiostreams_pool {
|
62 |
+
# Use ip_hash for basic session affinity (same client IP → same backend):
|
63 |
+
ip_hash;
|
64 |
+
|
65 |
+
# Primary backends. max_fails=3 means that if 3 consecutive attempts
|
66 |
+
# to connect or pass data to a given backend fail within “fail_timeout”
|
67 |
+
# (30s), that backend is marked as unavailable for 30s.
|
68 |
+
server aiostreams-cf.bolabaden.org:443 max_fails=3 fail_timeout=30s;
|
69 |
+
server aiostreams-koyeb.bolabaden.org:443 max_fails=3 fail_timeout=30s;
|
70 |
+
server aiostreams.bolabaden.duckdns.org:443 max_fails=3 fail_timeout=30s;
|
71 |
+
}
|
72 |
+
|
73 |
+
|
74 |
+
# ------------------------------------------------------------------------
|
75 |
+
# 2.b) Redirect all HTTP (port 80) → HTTPS (port 443).
|
76 |
+
# This ensures clients typing “http://…” get automatically sent
|
77 |
+
# to the secure endpoint.
|
78 |
+
# ------------------------------------------------------------------------
|
79 |
+
server {
|
80 |
+
listen 80;
|
81 |
+
listen [::]:80;
|
82 |
+
server_name aiostreams.bolabaden.org;
|
83 |
+
|
84 |
+
# Redirect every request to https://... preserving URI:
|
85 |
+
return 301 https://$host$request_uri;
|
86 |
+
}
|
87 |
+
|
88 |
+
|
89 |
+
# ------------------------------------------------------------------------
|
90 |
+
# 2.c) Main HTTPS server block for aiostreams.bolabaden.org
|
91 |
+
# ------------------------------------------------------------------------
|
92 |
+
server {
|
93 |
+
listen 443 ssl http2;
|
94 |
+
listen [::]:443 ssl http2;
|
95 |
+
server_name aiostreams.bolabaden.org;
|
96 |
+
|
97 |
+
# --------------------------------------------------------------------
|
98 |
+
# SSL Certificate / Key
|
99 |
+
# --------------------------------------------------------------------
|
100 |
+
#
|
101 |
+
# You must replace these with the actual paths to your certificate
|
102 |
+
# and private key (e.g. from Let’s Encrypt or another CA).
|
103 |
+
#
|
104 |
+
ssl_certificate /etc/letsencrypt/live/aiostreams.bolabaden.org/fullchain.pem;
|
105 |
+
ssl_certificate_key /etc/letsencrypt/live/aiostreams.bolabaden.org/privkey.pem;
|
106 |
+
|
107 |
+
# (Optional but recommended)
|
108 |
+
# Tune SSL protocols/ciphers for security. Example:
|
109 |
+
ssl_protocols TLSv1.2 TLSv1.3;
|
110 |
+
ssl_ciphers HIGH:!aNULL:!MD5;
|
111 |
+
ssl_prefer_server_ciphers on;
|
112 |
+
|
113 |
+
# --------------------------------------------------------------------
|
114 |
+
# Access and Error Logs (optional, but recommended for debugging)
|
115 |
+
# --------------------------------------------------------------------
|
116 |
+
access_log /var/log/nginx/aiostreams.access.log combined;
|
117 |
+
error_log /var/log/nginx/aiostreams.error.log warn;
|
118 |
+
|
119 |
+
# --------------------------------------------------------------------
|
120 |
+
# Proxy Buffering / Timeouts (adjust to suit your app’s needs)
|
121 |
+
# --------------------------------------------------------------------
|
122 |
+
proxy_buffer_size 16k;
|
123 |
+
proxy_buffers 4 32k;
|
124 |
+
proxy_busy_buffers_size 64k;
|
125 |
+
proxy_connect_timeout 5s;
|
126 |
+
proxy_send_timeout 30s;
|
127 |
+
proxy_read_timeout 30s;
|
128 |
+
proxy_buffering on;
|
129 |
+
proxy_buffering off; # ← turn OFF if your app does streaming / WebSockets
|
130 |
+
|
131 |
+
# --------------------------------------------------------------------
|
132 |
+
# Main Location: proxy everything (/) to the upstream pool
|
133 |
+
# --------------------------------------------------------------------
|
134 |
+
location / {
|
135 |
+
# Pass requests to our upstream group:
|
136 |
+
proxy_pass https://aiostreams_pool;
|
137 |
+
|
138 |
+
# Preserve the original Host header so the backends see “aiostreams.bolabaden.org”
|
139 |
+
# (if your backends require the Host to match their TLS certificate, you can also
|
140 |
+
# use “proxy_ssl_name aiostreams-cf.bolabaden.org;” per-backend via “proxy_set_header Host …”)
|
141 |
+
proxy_set_header Host $host;
|
142 |
+
proxy_set_header X-Real-IP $remote_addr;
|
143 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
144 |
+
proxy_set_header X-Forwarded-Proto $scheme;
|
145 |
+
|
146 |
+
# If a backend fails with certain HTTP status codes or connection errors,
|
147 |
+
# retry on the next available upstream. Here we retry on: timeout, HTTP 500, 502, 503, 504.
|
148 |
+
proxy_next_upstream error timeout http_502 http_503 http_504;
|
149 |
+
|
150 |
+
# Number of retries before giving up:
|
151 |
+
proxy_next_upstream_tries 3;
|
152 |
+
|
153 |
+
# When proxying to an HTTPS upstream, ensure the upstream’s TLS name matches:
|
154 |
+
proxy_ssl_server_name on;
|
155 |
+
|
156 |
+
# (Optional) If your backends use self-signed certs, disable verification:
|
157 |
+
# proxy_ssl_verify off;
|
158 |
+
#
|
159 |
+
# Otherwise (recommended), keep verification ON and trust the system’s ca‐bundle:
|
160 |
+
proxy_ssl_verify on;
|
161 |
+
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-bundle.crt;
|
162 |
+
}
|
163 |
+
|
164 |
+
# --------------------------------------------------------------------
|
165 |
+
# (Optional) Handle ACME (Let’s Encrypt) HTTP-01 challenges if you
|
166 |
+
# want to auto-provision certificates. Skip if you manage certificates manually.
|
167 |
+
# --------------------------------------------------------------------
|
168 |
+
# location /.well-known/acme-challenge/ {
|
169 |
+
# root /var/www/letsencrypt;
|
170 |
+
# allow all;
|
171 |
+
# }
|
172 |
+
|
173 |
+
# --------------------------------------------------------------------
|
174 |
+
# (Optional) Return 404 for anything else:
|
175 |
+
# --------------------------------------------------------------------
|
176 |
+
error_page 404 /404.html;
|
177 |
+
location = /404.html {
|
178 |
+
internal;
|
179 |
+
root /usr/share/nginx/html;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
# ------------------------------------------------------------------------
|
184 |
+
# 2.d) (Optional) Upstream health check—passive only (built-in):
|
185 |
+
# NGINX will automatically mark a backend “down” after max_fails,
|
186 |
+
# and retry only after fail_timeout. If you need active health checks,
|
187 |
+
# you’d install the nginx‐upstream‐healthcheck module (third-party).
|
188 |
+
# ------------------------------------------------------------------------
|
189 |
+
}
|
190 |
+
|
191 |
+
|
192 |
+
################################################################################
|
193 |
+
# 3) NOTES ON HOW THIS WORKS
|
194 |
+
################################################################################
|
195 |
+
|
196 |
+
# 1) ip_hash
|
197 |
+
# - Guarantees “session affinity” by hashing the client’s IP and sending it
|
198 |
+
# to the same backend each time (so long as that backend is up).
|
199 |
+
# - If the chosen backend becomes unavailable (because of max_fails/fail_timeout),
|
200 |
+
# NGINX transparently sends the next request to a healthy backend.
|
201 |
+
# - No DNS changes are ever made; clients always talk to https://aiostreams.bolabaden.org,
|
202 |
+
# and NGINX does the upstream routing.
|
203 |
+
|
204 |
+
# 2) max_fails / fail_timeout
|
205 |
+
# - “max_fails=3 fail_timeout=30s” means:
|
206 |
+
# • If 3 consecutive attempts to connect (or receive a response) to that backend
|
207 |
+
# fail within 30s, that backend is marked “unhealthy” and is skipped for the
|
208 |
+
# next 30 seconds.
|
209 |
+
# • After 30s passes, NGINX will retry the backend on a new request.
|
210 |
+
# - This is a passive health check—based on traffic failures.
|
211 |
+
|
212 |
+
# 3) proxy_next_upstream
|
213 |
+
# - If NGINX sees a connection error, a timeout, or one of the configured status codes
|
214 |
+
# (5xx, 502, 503, 504), it immediately retries the request on the next healthy backend.
|
215 |
+
# - Use “proxy_next_upstream_tries 3;” to limit retries.
|
216 |
+
|
217 |
+
# 4) proxy_ssl_server_name
|
218 |
+
# - When proxying via HTTPS, NGINX by default will send “Host”=IP to the upstream,
|
219 |
+
# which may not match the certificate on the backend. “proxy_ssl_server_name on;”
|
220 |
+
# causes NGINX to send SNI = the hostname in the “proxy_pass” URL (e.g. aiostreams-cf.bolabaden.org).
|
221 |
+
|
222 |
+
# 5) If you require faster health checks (active probes), you could compile or install
|
223 |
+
# the “nginx_upstream_check_module” (third party). But the above passive checks
|
224 |
+
# are sufficient for most “any one of three must be up” scenarios.
|
225 |
+
|
226 |
+
# 6) SSL Certificates
|
227 |
+
# - This example assumes you store Let’s Encrypt certificates under /etc/letsencrypt/…
|
228 |
+
# - If you haven’t yet obtained a certificate for aiostreams.bolabaden.org, do:
|
229 |
+
# certbot certonly --webroot -w /var/www/html -d aiostreams.bolabaden.org
|
230 |
+
# then update the “ssl_certificate” paths above accordingly.
|
231 |
+
|
232 |
+
################################################################################
|
233 |
+
# END OF CONFIG
|
234 |
+
################################################################################
|
package-lock.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
package.json
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "aiostreams",
|
3 |
+
"version": "2.4.2",
|
4 |
+
"description": "AIOStreams consolidates multiple Stremio addons and debrid services into a single, easily configurable addon. It allows highly customisable filtering, sorting, and formatting of results and supports proxying all your streams through MediaFlow Proxy or StremThru for improved compatibility and IP restriction bypassing.",
|
5 |
+
"main": "dist/index.js",
|
6 |
+
"scripts": {
|
7 |
+
"test": "npm run test --workspaces",
|
8 |
+
"release": "commit-and-tag-version",
|
9 |
+
"format": "prettier --write .",
|
10 |
+
"metadata": "node scripts/generateMetadata.js",
|
11 |
+
"build": "npm -w packages/core run build && npm -w packages/server run build && npm -w packages/frontend run build",
|
12 |
+
"build:watch": "tsc --build --watch",
|
13 |
+
"start": "node packages/server/dist/server",
|
14 |
+
"start:addon": "npm run start",
|
15 |
+
"start:dev": "cross-env NODE_ENV=development tsx watch packages/server/src/server.ts",
|
16 |
+
"start:addon:dev": "npm run start:dev",
|
17 |
+
"start:frontend:dev": "npm -w packages/frontend run dev"
|
18 |
+
},
|
19 |
+
"author": "Viren070",
|
20 |
+
"license": "MIT",
|
21 |
+
"workspaces": [
|
22 |
+
"packages/*"
|
23 |
+
],
|
24 |
+
"devDependencies": {
|
25 |
+
"cross-env": "^7.0.3",
|
26 |
+
"prettier": "^3.3.2",
|
27 |
+
"tsx": "^4.16.2",
|
28 |
+
"typescript": "^5.5.3",
|
29 |
+
"vitest": "^2.1.5",
|
30 |
+
"ts-node": "^10.9.2"
|
31 |
+
},
|
32 |
+
"engines": {
|
33 |
+
"node": ">=20.0.0"
|
34 |
+
}
|
35 |
+
}
|
packages/addon/package.json
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@aiostreams/addon",
|
3 |
+
"version": "1.21.1",
|
4 |
+
"main": "dist/index.js",
|
5 |
+
"scripts": {
|
6 |
+
"test": "vitest run --passWithNoTests",
|
7 |
+
"test:watch": "vitest watch",
|
8 |
+
"build": "tsc",
|
9 |
+
"prepublish": "npm run build",
|
10 |
+
"start": "node dist/server.js",
|
11 |
+
"start:dev": "cross-env NODE_ENV=dev tsx watch src/server.ts"
|
12 |
+
},
|
13 |
+
"description": "Combine all your streams into one addon and display them with consistent formatting, sorting, and filtering.",
|
14 |
+
"dependencies": {
|
15 |
+
"@aiostreams/formatters": "^1.0.0",
|
16 |
+
"@aiostreams/types": "^1.0.0",
|
17 |
+
"@aiostreams/utils": "^1.0.0",
|
18 |
+
"@aiostreams/wrappers": "^1.0.0",
|
19 |
+
"dotenv": "^16.4.7",
|
20 |
+
"express": "^4.21.2"
|
21 |
+
},
|
22 |
+
"devDependencies": {
|
23 |
+
"@types/express": "^5.0.0"
|
24 |
+
}
|
25 |
+
}
|
packages/addon/src/addon.ts
ADDED
@@ -0,0 +1,1416 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import {
|
2 |
+
BaseWrapper,
|
3 |
+
getCometStreams,
|
4 |
+
getDebridioStreams,
|
5 |
+
getDMMCastStreams,
|
6 |
+
getEasynewsPlusPlusStreams,
|
7 |
+
getEasynewsPlusStreams,
|
8 |
+
getEasynewsStreams,
|
9 |
+
getJackettioStreams,
|
10 |
+
getMediafusionStreams,
|
11 |
+
getOrionStreams,
|
12 |
+
getPeerflixStreams,
|
13 |
+
getStremioJackettStreams,
|
14 |
+
getStremThruStoreStreams,
|
15 |
+
getTorboxStreams,
|
16 |
+
getTorrentioStreams,
|
17 |
+
} from '@aiostreams/wrappers';
|
18 |
+
import {
|
19 |
+
Stream,
|
20 |
+
ParsedStream,
|
21 |
+
StreamRequest,
|
22 |
+
Config,
|
23 |
+
ErrorStream,
|
24 |
+
} from '@aiostreams/types';
|
25 |
+
import {
|
26 |
+
gdriveFormat,
|
27 |
+
torrentioFormat,
|
28 |
+
torboxFormat,
|
29 |
+
imposterFormat,
|
30 |
+
customFormat,
|
31 |
+
} from '@aiostreams/formatters';
|
32 |
+
import {
|
33 |
+
addonDetails,
|
34 |
+
getMediaFlowConfig,
|
35 |
+
getMediaFlowPublicIp,
|
36 |
+
getTimeTakenSincePoint,
|
37 |
+
Settings,
|
38 |
+
createLogger,
|
39 |
+
generateMediaFlowStreams,
|
40 |
+
getStremThruConfig,
|
41 |
+
getStremThruPublicIp,
|
42 |
+
generateStremThruStreams,
|
43 |
+
safeRegexTest,
|
44 |
+
compileRegex,
|
45 |
+
formRegexFromKeywords,
|
46 |
+
} from '@aiostreams/utils';
|
47 |
+
import { errorStream } from './responses';
|
48 |
+
import { isMatch } from 'super-regex';
|
49 |
+
|
50 |
+
const logger = createLogger('addon');
|
51 |
+
|
52 |
+
export class AIOStreams {
|
53 |
+
private config: Config;
|
54 |
+
|
55 |
+
constructor(config: any) {
|
56 |
+
this.config = config;
|
57 |
+
}
|
58 |
+
|
59 |
+
private async retryGetIp<T>(
|
60 |
+
getter: () => Promise<T | null>,
|
61 |
+
label: string,
|
62 |
+
maxRetries: number = 3
|
63 |
+
): Promise<T> {
|
64 |
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
65 |
+
const result = await getter();
|
66 |
+
if (result) {
|
67 |
+
return result;
|
68 |
+
}
|
69 |
+
logger.warn(
|
70 |
+
`Failed to get ${label}, retrying... (${attempt}/${maxRetries})`
|
71 |
+
);
|
72 |
+
}
|
73 |
+
throw new Error(`Failed to get ${label} after ${maxRetries} attempts`);
|
74 |
+
}
|
75 |
+
|
76 |
+
private async getRequestingIp() {
|
77 |
+
let userIp = this.config.requestingIp;
|
78 |
+
const PRIVATE_IP_REGEX =
|
79 |
+
/^(::1|::ffff:(10|127|192|172)\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})|10\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})|127\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})|192\.168\.(\d{1,3})\.(\d{1,3})|172\.(1[6-9]|2[0-9]|3[0-1])\.(\d{1,3})\.(\d{1,3}))$/;
|
80 |
+
|
81 |
+
if (userIp && PRIVATE_IP_REGEX.test(userIp)) {
|
82 |
+
userIp = undefined;
|
83 |
+
}
|
84 |
+
const mediaflowConfig = getMediaFlowConfig(this.config);
|
85 |
+
const stremThruConfig = getStremThruConfig(this.config);
|
86 |
+
if (mediaflowConfig.mediaFlowEnabled) {
|
87 |
+
userIp = await this.retryGetIp(
|
88 |
+
() => getMediaFlowPublicIp(mediaflowConfig),
|
89 |
+
'MediaFlow public IP'
|
90 |
+
);
|
91 |
+
} else if (stremThruConfig.stremThruEnabled) {
|
92 |
+
userIp = await this.retryGetIp(
|
93 |
+
() => getStremThruPublicIp(stremThruConfig),
|
94 |
+
'StremThru public IP'
|
95 |
+
);
|
96 |
+
}
|
97 |
+
return userIp;
|
98 |
+
}
|
99 |
+
|
100 |
+
public async getStreams(streamRequest: StreamRequest): Promise<Stream[]> {
|
101 |
+
const streams: Stream[] = [];
|
102 |
+
const startTime = new Date().getTime();
|
103 |
+
|
104 |
+
try {
|
105 |
+
this.config.requestingIp = await this.getRequestingIp();
|
106 |
+
} catch (error) {
|
107 |
+
logger.error(error);
|
108 |
+
return [errorStream(`Failed to get Proxy IP`)];
|
109 |
+
}
|
110 |
+
|
111 |
+
const { parsedStreams, errorStreams } =
|
112 |
+
await this.getParsedStreams(streamRequest);
|
113 |
+
|
114 |
+
const skipReasons = {
|
115 |
+
excludeLanguages: 0,
|
116 |
+
excludeResolutions: 0,
|
117 |
+
excludeQualities: 0,
|
118 |
+
excludeEncodes: 0,
|
119 |
+
excludeAudioTags: 0,
|
120 |
+
excludeVisualTags: 0,
|
121 |
+
excludeStreamTypes: 0,
|
122 |
+
excludeUncached: 0,
|
123 |
+
sizeFilters: 0,
|
124 |
+
duplicateStreams: 0,
|
125 |
+
streamLimiters: 0,
|
126 |
+
excludeRegex: 0,
|
127 |
+
requiredRegex: 0,
|
128 |
+
};
|
129 |
+
|
130 |
+
logger.info(
|
131 |
+
`Got ${parsedStreams.length} parsed streams and ${errorStreams.length} error streams in ${getTimeTakenSincePoint(startTime)}`
|
132 |
+
);
|
133 |
+
|
134 |
+
const excludeRegexPattern = this.config.apiKey
|
135 |
+
? this.config.regexFilters?.excludePattern ||
|
136 |
+
Settings.DEFAULT_REGEX_EXCLUDE_PATTERN
|
137 |
+
: undefined;
|
138 |
+
const excludeRegex = excludeRegexPattern
|
139 |
+
? compileRegex(excludeRegexPattern, 'i')
|
140 |
+
: undefined;
|
141 |
+
|
142 |
+
const excludeKeywordsRegex = this.config.excludeFilters
|
143 |
+
? formRegexFromKeywords(this.config.excludeFilters)
|
144 |
+
: undefined;
|
145 |
+
|
146 |
+
const requiredRegexPattern = this.config.apiKey
|
147 |
+
? this.config.regexFilters?.includePattern ||
|
148 |
+
Settings.DEFAULT_REGEX_INCLUDE_PATTERN
|
149 |
+
: undefined;
|
150 |
+
const requiredRegex = requiredRegexPattern
|
151 |
+
? compileRegex(requiredRegexPattern, 'i')
|
152 |
+
: undefined;
|
153 |
+
|
154 |
+
const requiredKeywordsRegex = this.config.strictIncludeFilters
|
155 |
+
? formRegexFromKeywords(this.config.strictIncludeFilters)
|
156 |
+
: undefined;
|
157 |
+
|
158 |
+
const sortRegexPatterns = this.config.apiKey
|
159 |
+
? this.config.regexSortPatterns || Settings.DEFAULT_REGEX_SORT_PATTERNS
|
160 |
+
: undefined;
|
161 |
+
|
162 |
+
const sortRegexes: { name?: string; regex: RegExp }[] | undefined =
|
163 |
+
sortRegexPatterns
|
164 |
+
? sortRegexPatterns
|
165 |
+
.split(/\s+/)
|
166 |
+
.filter(Boolean)
|
167 |
+
.map((pattern) => {
|
168 |
+
const delimiter = '<::>';
|
169 |
+
const delimiterIndex = pattern.indexOf(delimiter);
|
170 |
+
if (delimiterIndex !== -1) {
|
171 |
+
const name = pattern
|
172 |
+
.slice(0, delimiterIndex)
|
173 |
+
.replace(/_/g, ' ');
|
174 |
+
const regexPattern = pattern.slice(
|
175 |
+
delimiterIndex + delimiter.length
|
176 |
+
);
|
177 |
+
|
178 |
+
const regex = compileRegex(regexPattern, 'i');
|
179 |
+
return { name, regex };
|
180 |
+
}
|
181 |
+
return { regex: compileRegex(pattern, 'i') };
|
182 |
+
})
|
183 |
+
: undefined;
|
184 |
+
|
185 |
+
excludeRegex ||
|
186 |
+
excludeKeywordsRegex ||
|
187 |
+
requiredRegex ||
|
188 |
+
requiredKeywordsRegex ||
|
189 |
+
sortRegexes
|
190 |
+
? logger.debug(
|
191 |
+
`The following regex patterns are being used:\n` +
|
192 |
+
`Exclude Regex: ${excludeRegex}\n` +
|
193 |
+
`Exclude Keywords: ${excludeKeywordsRegex}\n` +
|
194 |
+
`Required Regex: ${requiredRegex}\n` +
|
195 |
+
`Required Keywords: ${requiredKeywordsRegex}\n` +
|
196 |
+
`Sort Regexes: ${sortRegexes?.map((regex) => `${regex.name || 'Unnamed'}: ${regex.regex}`).join(' --> ')}\n`
|
197 |
+
)
|
198 |
+
: [];
|
199 |
+
|
200 |
+
const filterStartTime = new Date().getTime();
|
201 |
+
|
202 |
+
let filteredResults = parsedStreams.filter((parsedStream) => {
|
203 |
+
const streamTypeFilter = this.config.streamTypes?.find(
|
204 |
+
(streamType) => streamType[parsedStream.type] === false
|
205 |
+
);
|
206 |
+
if (this.config.streamTypes && streamTypeFilter) {
|
207 |
+
skipReasons.excludeStreamTypes++;
|
208 |
+
return false;
|
209 |
+
}
|
210 |
+
|
211 |
+
const resolutionFilter = this.config.resolutions?.find(
|
212 |
+
(resolution) => resolution[parsedStream.resolution] === false
|
213 |
+
);
|
214 |
+
if (resolutionFilter) {
|
215 |
+
skipReasons.excludeResolutions++;
|
216 |
+
return false;
|
217 |
+
}
|
218 |
+
|
219 |
+
const qualityFilter = this.config.qualities?.find(
|
220 |
+
(quality) => quality[parsedStream.quality] === false
|
221 |
+
);
|
222 |
+
if (this.config.qualities && qualityFilter) {
|
223 |
+
skipReasons.excludeQualities++;
|
224 |
+
return false;
|
225 |
+
}
|
226 |
+
|
227 |
+
// Check for HDR and DV tags in the parsed stream
|
228 |
+
const hasHDR = parsedStream.visualTags.some((tag) =>
|
229 |
+
tag.startsWith('HDR')
|
230 |
+
);
|
231 |
+
const hasDV = parsedStream.visualTags.includes('DV');
|
232 |
+
const hasHDRAndDV = hasHDR && hasDV;
|
233 |
+
const HDRAndDVEnabled = this.config.visualTags.some(
|
234 |
+
(visualTag) => visualTag['HDR+DV'] === true
|
235 |
+
);
|
236 |
+
|
237 |
+
const isTagDisabled = (tag: string) =>
|
238 |
+
this.config.visualTags.some((visualTag) => visualTag[tag] === false);
|
239 |
+
|
240 |
+
if (hasHDRAndDV) {
|
241 |
+
if (!HDRAndDVEnabled) {
|
242 |
+
skipReasons.excludeVisualTags++;
|
243 |
+
return false;
|
244 |
+
}
|
245 |
+
} else if (hasHDR) {
|
246 |
+
const specificHdrTags = parsedStream.visualTags.filter((tag) =>
|
247 |
+
tag.startsWith('HDR')
|
248 |
+
);
|
249 |
+
const disabledTags = specificHdrTags.filter(
|
250 |
+
(tag) => isTagDisabled(tag) === true
|
251 |
+
);
|
252 |
+
if (disabledTags.length > 0) {
|
253 |
+
skipReasons.excludeVisualTags++;
|
254 |
+
return;
|
255 |
+
}
|
256 |
+
} else if (hasDV && isTagDisabled('DV')) {
|
257 |
+
skipReasons.excludeVisualTags++;
|
258 |
+
return false;
|
259 |
+
}
|
260 |
+
|
261 |
+
// Check other visual tags for explicit disabling
|
262 |
+
for (const tag of parsedStream.visualTags) {
|
263 |
+
if (tag.startsWith('HDR') || tag === 'DV') continue;
|
264 |
+
if (isTagDisabled(tag)) {
|
265 |
+
skipReasons.excludeVisualTags++;
|
266 |
+
return false;
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
// apply excludedLanguages filter
|
271 |
+
const excludedLanguages = this.config.excludedLanguages;
|
272 |
+
if (excludedLanguages && parsedStream.languages.length > 0) {
|
273 |
+
if (
|
274 |
+
parsedStream.languages.every((lang) =>
|
275 |
+
excludedLanguages.includes(lang)
|
276 |
+
)
|
277 |
+
) {
|
278 |
+
skipReasons.excludeLanguages++;
|
279 |
+
return false;
|
280 |
+
}
|
281 |
+
} else if (
|
282 |
+
excludedLanguages &&
|
283 |
+
excludedLanguages.includes('Unknown') &&
|
284 |
+
parsedStream.languages.length === 0
|
285 |
+
) {
|
286 |
+
skipReasons.excludeLanguages++;
|
287 |
+
return false;
|
288 |
+
}
|
289 |
+
|
290 |
+
const audioTagFilter = parsedStream.audioTags.find((tag) =>
|
291 |
+
this.config.audioTags.some((audioTag) => audioTag[tag] === false)
|
292 |
+
);
|
293 |
+
if (audioTagFilter) {
|
294 |
+
skipReasons.excludeAudioTags++;
|
295 |
+
return false;
|
296 |
+
}
|
297 |
+
|
298 |
+
if (
|
299 |
+
parsedStream.encode &&
|
300 |
+
this.config.encodes.some(
|
301 |
+
(encode) => encode[parsedStream.encode] === false
|
302 |
+
)
|
303 |
+
) {
|
304 |
+
skipReasons.excludeEncodes++;
|
305 |
+
return false;
|
306 |
+
}
|
307 |
+
|
308 |
+
if (
|
309 |
+
this.config.onlyShowCachedStreams &&
|
310 |
+
parsedStream.provider &&
|
311 |
+
!parsedStream.provider.cached
|
312 |
+
) {
|
313 |
+
skipReasons.excludeUncached++;
|
314 |
+
return false;
|
315 |
+
}
|
316 |
+
|
317 |
+
if (
|
318 |
+
this.config.minSize &&
|
319 |
+
parsedStream.size &&
|
320 |
+
parsedStream.size < this.config.minSize
|
321 |
+
) {
|
322 |
+
skipReasons.sizeFilters++;
|
323 |
+
return false;
|
324 |
+
}
|
325 |
+
|
326 |
+
if (
|
327 |
+
this.config.maxSize &&
|
328 |
+
parsedStream.size &&
|
329 |
+
parsedStream.size > this.config.maxSize
|
330 |
+
) {
|
331 |
+
skipReasons.sizeFilters++;
|
332 |
+
return false;
|
333 |
+
}
|
334 |
+
|
335 |
+
if (
|
336 |
+
streamRequest.type === 'movie' &&
|
337 |
+
this.config.maxMovieSize &&
|
338 |
+
parsedStream.size &&
|
339 |
+
parsedStream.size > this.config.maxMovieSize
|
340 |
+
) {
|
341 |
+
skipReasons.sizeFilters++;
|
342 |
+
return false;
|
343 |
+
}
|
344 |
+
|
345 |
+
if (
|
346 |
+
streamRequest.type === 'movie' &&
|
347 |
+
this.config.minMovieSize &&
|
348 |
+
parsedStream.size &&
|
349 |
+
parsedStream.size < this.config.minMovieSize
|
350 |
+
) {
|
351 |
+
skipReasons.sizeFilters++;
|
352 |
+
return false;
|
353 |
+
}
|
354 |
+
|
355 |
+
if (
|
356 |
+
streamRequest.type === 'series' &&
|
357 |
+
this.config.maxEpisodeSize &&
|
358 |
+
parsedStream.size &&
|
359 |
+
parsedStream.size > this.config.maxEpisodeSize
|
360 |
+
) {
|
361 |
+
skipReasons.sizeFilters++;
|
362 |
+
return false;
|
363 |
+
}
|
364 |
+
|
365 |
+
if (
|
366 |
+
streamRequest.type === 'series' &&
|
367 |
+
this.config.minEpisodeSize &&
|
368 |
+
parsedStream.size &&
|
369 |
+
parsedStream.size < this.config.minEpisodeSize
|
370 |
+
) {
|
371 |
+
skipReasons.sizeFilters++;
|
372 |
+
return false;
|
373 |
+
}
|
374 |
+
|
375 |
+
// generate array of excludeTests. for each regex, only add to array if the filename or indexers are defined
|
376 |
+
let excludeTests: (boolean | null)[] = [];
|
377 |
+
let requiredTests: (boolean | null)[] = [];
|
378 |
+
|
379 |
+
const addToTests = (field: string | undefined) => {
|
380 |
+
if (field) {
|
381 |
+
excludeTests.push(
|
382 |
+
excludeRegex ? safeRegexTest(excludeRegex, field) : null,
|
383 |
+
excludeKeywordsRegex
|
384 |
+
? safeRegexTest(excludeKeywordsRegex, field)
|
385 |
+
: null
|
386 |
+
);
|
387 |
+
requiredTests.push(
|
388 |
+
requiredRegex ? safeRegexTest(requiredRegex, field) : null,
|
389 |
+
requiredKeywordsRegex
|
390 |
+
? safeRegexTest(requiredKeywordsRegex, field)
|
391 |
+
: null
|
392 |
+
);
|
393 |
+
}
|
394 |
+
};
|
395 |
+
|
396 |
+
addToTests(parsedStream.filename);
|
397 |
+
addToTests(parsedStream.folderName);
|
398 |
+
addToTests(parsedStream.indexers);
|
399 |
+
|
400 |
+
// filter out any null values as these are when the regex is not defined
|
401 |
+
excludeTests = excludeTests.filter((test) => test !== null);
|
402 |
+
requiredTests = requiredTests.filter((test) => test !== null);
|
403 |
+
|
404 |
+
if (excludeTests.length > 0 && excludeTests.some((test) => test)) {
|
405 |
+
skipReasons.excludeRegex++;
|
406 |
+
return false;
|
407 |
+
}
|
408 |
+
|
409 |
+
if (requiredTests.length > 0 && !requiredTests.some((test) => test)) {
|
410 |
+
skipReasons.requiredRegex++;
|
411 |
+
return false;
|
412 |
+
}
|
413 |
+
|
414 |
+
return true;
|
415 |
+
});
|
416 |
+
|
417 |
+
logger.info(
|
418 |
+
`Initial filter to ${filteredResults.length} streams in ${getTimeTakenSincePoint(filterStartTime)}`
|
419 |
+
);
|
420 |
+
|
421 |
+
if (this.config.cleanResults) {
|
422 |
+
const cleanedStreams: ParsedStream[] = [];
|
423 |
+
const initialStreams = filteredResults;
|
424 |
+
const normaliseFilename = (filename?: string): string | undefined =>
|
425 |
+
filename
|
426 |
+
? filename
|
427 |
+
?.replace(
|
428 |
+
/\.(mkv|mp4|avi|mov|wmv|flv|webm|m4v|mpg|mpeg|3gp|3g2|m2ts|ts|vob|ogv|ogm|divx|xvid|rm|rmvb|asf|mxf|mka|mks|mk3d|webm|f4v|f4p|f4a|f4b)$/i,
|
429 |
+
''
|
430 |
+
)
|
431 |
+
.replace(/[^\p{L}\p{N}+]/gu, '')
|
432 |
+
.replace(/\s+/g, '')
|
433 |
+
.toLowerCase()
|
434 |
+
: undefined;
|
435 |
+
|
436 |
+
const groupStreamsByKey = (
|
437 |
+
streams: ParsedStream[],
|
438 |
+
keyExtractor: (stream: ParsedStream) => string | undefined
|
439 |
+
): Record<string, ParsedStream[]> => {
|
440 |
+
return streams.reduce(
|
441 |
+
(acc, stream) => {
|
442 |
+
const key = keyExtractor(stream);
|
443 |
+
if (!key) {
|
444 |
+
if (!cleanedStreams.includes(stream)) {
|
445 |
+
cleanedStreams.push(stream);
|
446 |
+
}
|
447 |
+
return acc;
|
448 |
+
}
|
449 |
+
acc[key] = acc[key] || [];
|
450 |
+
acc[key].push(stream);
|
451 |
+
return acc;
|
452 |
+
},
|
453 |
+
{} as Record<string, ParsedStream[]>
|
454 |
+
);
|
455 |
+
};
|
456 |
+
|
457 |
+
const cleanResultsStartTime = new Date().getTime();
|
458 |
+
// Deduplication by normalised filename
|
459 |
+
const cleanResultsByFilenameStartTime = new Date().getTime();
|
460 |
+
logger.info(`Received ${initialStreams.length} streams to clean`);
|
461 |
+
const streamsGroupedByFilename = groupStreamsByKey(
|
462 |
+
initialStreams,
|
463 |
+
(stream) => normaliseFilename(stream.filename)
|
464 |
+
);
|
465 |
+
|
466 |
+
logger.info(
|
467 |
+
`Found ${Object.keys(streamsGroupedByFilename).length} unique filenames with ${
|
468 |
+
initialStreams.length -
|
469 |
+
Object.values(streamsGroupedByFilename).reduce(
|
470 |
+
(sum, group) => sum + group.length,
|
471 |
+
0
|
472 |
+
)
|
473 |
+
} streams not grouped`
|
474 |
+
);
|
475 |
+
|
476 |
+
// Process grouped streams by filename
|
477 |
+
const cleanedStreamsByFilename = await this.processGroupedStreams(
|
478 |
+
streamsGroupedByFilename
|
479 |
+
);
|
480 |
+
|
481 |
+
logger.info(
|
482 |
+
`Deduplicated streams by filename to ${cleanedStreamsByFilename.length} streams in ${getTimeTakenSincePoint(cleanResultsByFilenameStartTime)}`
|
483 |
+
);
|
484 |
+
|
485 |
+
// Deduplication by hash
|
486 |
+
const cleanResultsByHashStartTime = new Date().getTime();
|
487 |
+
|
488 |
+
const streamsGroupedByHash = groupStreamsByKey(
|
489 |
+
cleanedStreamsByFilename,
|
490 |
+
(stream) => stream._infoHash
|
491 |
+
);
|
492 |
+
logger.info(
|
493 |
+
`Found ${Object.keys(streamsGroupedByHash).length} unique hashes with ${cleanedStreamsByFilename.length - Object.values(streamsGroupedByHash).reduce((sum, group) => sum + group.length, 0)} streams not grouped`
|
494 |
+
);
|
495 |
+
|
496 |
+
// Process grouped streams by hash
|
497 |
+
const cleanedStreamsByHash =
|
498 |
+
await this.processGroupedStreams(streamsGroupedByHash);
|
499 |
+
|
500 |
+
logger.info(
|
501 |
+
`Deduplicated streams by hash to ${cleanedStreamsByHash.length} streams in ${getTimeTakenSincePoint(cleanResultsByHashStartTime)}`
|
502 |
+
);
|
503 |
+
|
504 |
+
cleanedStreams.push(...cleanedStreamsByHash);
|
505 |
+
logger.info(
|
506 |
+
`Deduplicated streams to ${cleanedStreams.length} streams in ${getTimeTakenSincePoint(cleanResultsStartTime)}`
|
507 |
+
);
|
508 |
+
skipReasons.duplicateStreams =
|
509 |
+
filteredResults.length - cleanedStreams.length;
|
510 |
+
filteredResults = cleanedStreams;
|
511 |
+
}
|
512 |
+
// pre compute highest indexes for regexSortPatterns
|
513 |
+
const startPrecomputeTime = new Date().getTime();
|
514 |
+
filteredResults.forEach((stream: ParsedStream) => {
|
515 |
+
if (sortRegexes) {
|
516 |
+
for (let i = 0; i < sortRegexes.length; i++) {
|
517 |
+
if (!stream.filename && !stream.folderName) continue;
|
518 |
+
const regex = sortRegexes[i];
|
519 |
+
if (
|
520 |
+
(stream.filename && isMatch(regex.regex, stream.filename)) ||
|
521 |
+
(stream.folderName && isMatch(regex.regex, stream.folderName))
|
522 |
+
) {
|
523 |
+
stream.regexMatched = {
|
524 |
+
name: regex.name,
|
525 |
+
pattern: regex.regex.source,
|
526 |
+
index: i,
|
527 |
+
};
|
528 |
+
break;
|
529 |
+
}
|
530 |
+
}
|
531 |
+
}
|
532 |
+
});
|
533 |
+
logger.info(
|
534 |
+
`Precomputed sortRegex indexes for ${filteredResults.length} streams in ${getTimeTakenSincePoint(
|
535 |
+
startPrecomputeTime
|
536 |
+
)}`
|
537 |
+
);
|
538 |
+
// Apply sorting
|
539 |
+
const sortStartTime = new Date().getTime();
|
540 |
+
// initially sort by filename to ensure consistent results
|
541 |
+
filteredResults.sort((a, b) =>
|
542 |
+
a.filename && b.filename ? a.filename.localeCompare(b.filename) : 0
|
543 |
+
);
|
544 |
+
|
545 |
+
// then apply our this.config sorting
|
546 |
+
filteredResults.sort((a, b) => {
|
547 |
+
for (const sortByField of this.config.sortBy) {
|
548 |
+
const field = Object.keys(sortByField).find(
|
549 |
+
(key) => typeof sortByField[key] === 'boolean'
|
550 |
+
);
|
551 |
+
if (!field) continue;
|
552 |
+
const value = sortByField[field];
|
553 |
+
|
554 |
+
if (value) {
|
555 |
+
const fieldComparison = this.compareByField(a, b, field);
|
556 |
+
if (fieldComparison !== 0) return fieldComparison;
|
557 |
+
}
|
558 |
+
}
|
559 |
+
|
560 |
+
return 0;
|
561 |
+
});
|
562 |
+
|
563 |
+
logger.info(`Sorted results in ${getTimeTakenSincePoint(sortStartTime)}`);
|
564 |
+
|
565 |
+
// apply config.maxResultsPerResolution
|
566 |
+
if (this.config.maxResultsPerResolution) {
|
567 |
+
const startTime = new Date().getTime();
|
568 |
+
const resolutionCounts = new Map();
|
569 |
+
|
570 |
+
const limitedResults = filteredResults.filter((result) => {
|
571 |
+
const resolution = result.resolution || 'Unknown';
|
572 |
+
const currentCount = resolutionCounts.get(resolution) || 0;
|
573 |
+
|
574 |
+
if (currentCount < this.config.maxResultsPerResolution!) {
|
575 |
+
resolutionCounts.set(resolution, currentCount + 1);
|
576 |
+
return true;
|
577 |
+
}
|
578 |
+
|
579 |
+
return false;
|
580 |
+
});
|
581 |
+
skipReasons.streamLimiters =
|
582 |
+
filteredResults.length - limitedResults.length;
|
583 |
+
filteredResults = limitedResults;
|
584 |
+
|
585 |
+
logger.info(
|
586 |
+
`Limited results to ${limitedResults.length} streams after applying maxResultsPerResolution in ${new Date().getTime() - startTime}ms`
|
587 |
+
);
|
588 |
+
}
|
589 |
+
|
590 |
+
const totalSkipped = Object.values(skipReasons).reduce(
|
591 |
+
(acc, val) => acc + val,
|
592 |
+
0
|
593 |
+
);
|
594 |
+
const reportLines = [
|
595 |
+
'╔═══════════════════════╤════════════╗',
|
596 |
+
'║ Skip Reason │ Count ║',
|
597 |
+
'╟───────────────────────┼────────────╢',
|
598 |
+
...Object.entries(skipReasons)
|
599 |
+
.filter(([reason, count]) => count > 0)
|
600 |
+
.map(
|
601 |
+
([reason, count]) =>
|
602 |
+
`║ ${reason.padEnd(21)} │ ${String(count).padStart(10)} ║`
|
603 |
+
),
|
604 |
+
'╟───────────────────────┼────────────╢',
|
605 |
+
`║ Total Skipped │ ${String(totalSkipped).padStart(10)} ║`,
|
606 |
+
'╚═══════════════════════╧════════════╝',
|
607 |
+
];
|
608 |
+
|
609 |
+
if (totalSkipped > 0) logger.info('\n' + reportLines.join('\n'));
|
610 |
+
|
611 |
+
// Create stream objects
|
612 |
+
const streamsStartTime = new Date().getTime();
|
613 |
+
const streamObjects = await this.createStreamObjects(filteredResults);
|
614 |
+
streams.push(...streamObjects.filter((s) => s !== null));
|
615 |
+
|
616 |
+
// Add error streams to the end
|
617 |
+
streams.push(
|
618 |
+
...errorStreams.map((e) => errorStream(e.error, e.addon.name))
|
619 |
+
);
|
620 |
+
|
621 |
+
logger.info(
|
622 |
+
`Created ${streams.length} stream objects in ${getTimeTakenSincePoint(streamsStartTime)}`
|
623 |
+
);
|
624 |
+
logger.info(
|
625 |
+
`Total time taken to get streams: ${getTimeTakenSincePoint(startTime)}`
|
626 |
+
);
|
627 |
+
return streams;
|
628 |
+
}
|
629 |
+
|
630 |
+
private shouldProxyStream(
|
631 |
+
stream: ParsedStream,
|
632 |
+
mediaFlowConfig: ReturnType<typeof getMediaFlowConfig>,
|
633 |
+
stremThruConfig: ReturnType<typeof getStremThruConfig>
|
634 |
+
): boolean {
|
635 |
+
if (!stream.url) return false;
|
636 |
+
|
637 |
+
const streamProvider = stream.provider ? stream.provider.id : 'none';
|
638 |
+
|
639 |
+
// // now check if mediaFlowConfig.proxiedAddons or mediaFlowConfig.proxiedServices is not null
|
640 |
+
// logger.info(this.config.mediaFlowConfig?.proxiedAddons);
|
641 |
+
// logger.info(stream.addon.id);
|
642 |
+
if (
|
643 |
+
mediaFlowConfig.mediaFlowEnabled &&
|
644 |
+
(!mediaFlowConfig.proxiedAddons?.length ||
|
645 |
+
mediaFlowConfig.proxiedAddons.includes(stream.addon.id)) &&
|
646 |
+
(!mediaFlowConfig.proxiedServices?.length ||
|
647 |
+
mediaFlowConfig.proxiedServices.includes(streamProvider))
|
648 |
+
) {
|
649 |
+
return true;
|
650 |
+
}
|
651 |
+
|
652 |
+
if (
|
653 |
+
stremThruConfig.stremThruEnabled &&
|
654 |
+
(!stremThruConfig.proxiedAddons?.length ||
|
655 |
+
stremThruConfig.proxiedAddons.includes(stream.addon.id)) &&
|
656 |
+
(!stremThruConfig.proxiedServices?.length ||
|
657 |
+
stremThruConfig.proxiedServices.includes(streamProvider))
|
658 |
+
) {
|
659 |
+
return true;
|
660 |
+
}
|
661 |
+
|
662 |
+
return false;
|
663 |
+
}
|
664 |
+
|
665 |
+
private getFormattedText(parsedStream: ParsedStream): {
|
666 |
+
name: string;
|
667 |
+
description: string;
|
668 |
+
} {
|
669 |
+
switch (this.config.formatter) {
|
670 |
+
case 'gdrive': {
|
671 |
+
return gdriveFormat(parsedStream, false);
|
672 |
+
}
|
673 |
+
case 'minimalistic-gdrive': {
|
674 |
+
return gdriveFormat(parsedStream, true);
|
675 |
+
}
|
676 |
+
case 'imposter': {
|
677 |
+
return imposterFormat(parsedStream);
|
678 |
+
}
|
679 |
+
case 'torrentio': {
|
680 |
+
return torrentioFormat(parsedStream);
|
681 |
+
}
|
682 |
+
case 'torbox': {
|
683 |
+
return torboxFormat(parsedStream);
|
684 |
+
}
|
685 |
+
default: {
|
686 |
+
if (
|
687 |
+
this.config.formatter.startsWith('custom:') &&
|
688 |
+
this.config.formatter.length > 7
|
689 |
+
) {
|
690 |
+
const jsonString = this.config.formatter.slice(7);
|
691 |
+
const formatter = JSON.parse(jsonString);
|
692 |
+
if (formatter.name && formatter.description) {
|
693 |
+
try {
|
694 |
+
return customFormat(parsedStream, formatter);
|
695 |
+
} catch (error: any) {
|
696 |
+
logger.error(
|
697 |
+
`Error in custom formatter: ${error.message || error}, falling back to default formatter`
|
698 |
+
);
|
699 |
+
return gdriveFormat(parsedStream, false);
|
700 |
+
}
|
701 |
+
}
|
702 |
+
}
|
703 |
+
|
704 |
+
return gdriveFormat(parsedStream, false);
|
705 |
+
}
|
706 |
+
}
|
707 |
+
}
|
708 |
+
|
709 |
+
private async createStreamObjects(
|
710 |
+
parsedStreams: ParsedStream[]
|
711 |
+
): Promise<Stream[]> {
|
712 |
+
const mediaFlowConfig = getMediaFlowConfig(this.config);
|
713 |
+
const stremThruConfig = getStremThruConfig(this.config);
|
714 |
+
|
715 |
+
// Identify streams that require proxying
|
716 |
+
const streamsToProxy = parsedStreams
|
717 |
+
.map((stream, index) => ({ stream, index }))
|
718 |
+
.filter(
|
719 |
+
({ stream }) =>
|
720 |
+
stream.url &&
|
721 |
+
this.shouldProxyStream(stream, mediaFlowConfig, stremThruConfig)
|
722 |
+
);
|
723 |
+
|
724 |
+
const proxiedUrls = streamsToProxy.length
|
725 |
+
? mediaFlowConfig.mediaFlowEnabled
|
726 |
+
? await generateMediaFlowStreams(
|
727 |
+
mediaFlowConfig,
|
728 |
+
streamsToProxy.map(({ stream }) => ({
|
729 |
+
url: stream.url!,
|
730 |
+
filename: stream.filename,
|
731 |
+
headers: stream.stream?.behaviorHints?.proxyHeaders,
|
732 |
+
}))
|
733 |
+
)
|
734 |
+
: stremThruConfig.stremThruEnabled
|
735 |
+
? await generateStremThruStreams(
|
736 |
+
stremThruConfig,
|
737 |
+
streamsToProxy.map(({ stream }) => ({
|
738 |
+
url: stream.url!,
|
739 |
+
filename: stream.filename,
|
740 |
+
headers: stream.stream?.behaviorHints?.proxyHeaders,
|
741 |
+
}))
|
742 |
+
)
|
743 |
+
: null
|
744 |
+
: null;
|
745 |
+
|
746 |
+
const removeIndexes = new Set<number>();
|
747 |
+
|
748 |
+
// Apply proxied URLs and mark as proxied
|
749 |
+
streamsToProxy.forEach(({ stream, index }, i) => {
|
750 |
+
const proxiedUrl = proxiedUrls?.[i];
|
751 |
+
if (proxiedUrl) {
|
752 |
+
stream.url = proxiedUrl;
|
753 |
+
stream.proxied = true;
|
754 |
+
} else {
|
755 |
+
removeIndexes.add(index);
|
756 |
+
}
|
757 |
+
});
|
758 |
+
|
759 |
+
// Remove streams that failed to proxy
|
760 |
+
if (removeIndexes.size > 0) {
|
761 |
+
logger.error(
|
762 |
+
`Failed to proxy ${removeIndexes.size} streams, removing them from the final list`
|
763 |
+
);
|
764 |
+
parsedStreams = parsedStreams.filter(
|
765 |
+
(_, index) => !removeIndexes.has(index)
|
766 |
+
);
|
767 |
+
}
|
768 |
+
|
769 |
+
// Build final Stream objects
|
770 |
+
const proxyBingeGroupPrefix = mediaFlowConfig.mediaFlowEnabled
|
771 |
+
? 'mfp.'
|
772 |
+
: stremThruConfig.stremThruEnabled
|
773 |
+
? 'st.'
|
774 |
+
: '';
|
775 |
+
const streamObjects: Stream[] = await Promise.all(
|
776 |
+
parsedStreams.map((parsedStream) => {
|
777 |
+
const { name, description } = this.getFormattedText(parsedStream);
|
778 |
+
|
779 |
+
const combinedTags = [
|
780 |
+
parsedStream.resolution,
|
781 |
+
parsedStream.quality,
|
782 |
+
parsedStream.encode,
|
783 |
+
...parsedStream.visualTags,
|
784 |
+
...parsedStream.audioTags,
|
785 |
+
...parsedStream.languages,
|
786 |
+
];
|
787 |
+
|
788 |
+
return {
|
789 |
+
url: parsedStream.url,
|
790 |
+
externalUrl: parsedStream.externalUrl,
|
791 |
+
infoHash: parsedStream.torrent?.infoHash,
|
792 |
+
fileIdx: parsedStream.torrent?.fileIdx,
|
793 |
+
name,
|
794 |
+
description,
|
795 |
+
subtitles: parsedStream.stream?.subtitles,
|
796 |
+
sources: parsedStream.torrent?.sources,
|
797 |
+
behaviorHints: {
|
798 |
+
videoSize: parsedStream.size
|
799 |
+
? Math.floor(parsedStream.size)
|
800 |
+
: undefined,
|
801 |
+
filename: parsedStream.filename,
|
802 |
+
bingeGroup: `${parsedStream.proxied ? proxyBingeGroupPrefix : ''}${Settings.ADDON_ID}|${parsedStream.addon.name}|${combinedTags.join('|')}`,
|
803 |
+
proxyHeaders: parsedStream.stream?.behaviorHints?.proxyHeaders,
|
804 |
+
notWebReady: parsedStream.stream?.behaviorHints?.notWebReady,
|
805 |
+
},
|
806 |
+
};
|
807 |
+
})
|
808 |
+
);
|
809 |
+
|
810 |
+
return streamObjects;
|
811 |
+
}
|
812 |
+
|
813 |
+
private compareLanguages(a: ParsedStream, b: ParsedStream) {
|
814 |
+
if (this.config.prioritiseLanguage) {
|
815 |
+
const aHasPrioritisedLanguage = a.languages.includes(
|
816 |
+
this.config.prioritiseLanguage
|
817 |
+
);
|
818 |
+
const bHasPrioritisedLanguage = b.languages.includes(
|
819 |
+
this.config.prioritiseLanguage
|
820 |
+
);
|
821 |
+
|
822 |
+
if (aHasPrioritisedLanguage && !bHasPrioritisedLanguage) return -1;
|
823 |
+
if (!aHasPrioritisedLanguage && bHasPrioritisedLanguage) return 1;
|
824 |
+
}
|
825 |
+
return 0;
|
826 |
+
}
|
827 |
+
|
828 |
+
private compareByField(a: ParsedStream, b: ParsedStream, field: string) {
|
829 |
+
if (field === 'resolution') {
|
830 |
+
return (
|
831 |
+
this.config.resolutions.findIndex(
|
832 |
+
(resolution) => resolution[a.resolution]
|
833 |
+
) -
|
834 |
+
this.config.resolutions.findIndex(
|
835 |
+
(resolution) => resolution[b.resolution]
|
836 |
+
)
|
837 |
+
);
|
838 |
+
} else if (field === 'regexSort') {
|
839 |
+
const regexSortPatterns =
|
840 |
+
this.config.regexSortPatterns || Settings.DEFAULT_REGEX_SORT_PATTERNS;
|
841 |
+
if (!regexSortPatterns) return 0;
|
842 |
+
try {
|
843 |
+
// Get direction once
|
844 |
+
const direction = this.config.sortBy.find(
|
845 |
+
(sort) => Object.keys(sort)[0] === 'regexSort'
|
846 |
+
)?.direction;
|
847 |
+
|
848 |
+
// Early exit if no filename to test
|
849 |
+
if (!a.filename && !b.filename) return 0;
|
850 |
+
if (!a.filename) return direction === 'asc' ? -1 : 1;
|
851 |
+
if (!b.filename) return direction === 'asc' ? 1 : -1;
|
852 |
+
|
853 |
+
const aHighestIndex = a.regexMatched?.index;
|
854 |
+
const bHighestIndex = b.regexMatched?.index;
|
855 |
+
|
856 |
+
// If both have a regex match, sort by the highest index
|
857 |
+
if (aHighestIndex !== undefined && bHighestIndex !== undefined) {
|
858 |
+
return direction === 'asc'
|
859 |
+
? bHighestIndex - aHighestIndex
|
860 |
+
: aHighestIndex - bHighestIndex;
|
861 |
+
}
|
862 |
+
// If one has a regex match and the other doesn't, sort by the one that does
|
863 |
+
if (aHighestIndex !== undefined) return direction === 'asc' ? 1 : -1;
|
864 |
+
if (bHighestIndex !== undefined) return direction === 'asc' ? -1 : 1;
|
865 |
+
|
866 |
+
// If both have no regex match, they are equal
|
867 |
+
return 0;
|
868 |
+
} catch (e) {
|
869 |
+
return 0;
|
870 |
+
}
|
871 |
+
} else if (field === 'cached') {
|
872 |
+
let aCanbeCached = a.provider;
|
873 |
+
let bCanbeCached = b.provider;
|
874 |
+
let aCached = a.provider?.cached;
|
875 |
+
let bCached = b.provider?.cached;
|
876 |
+
|
877 |
+
// prioritise non debrid/usenet p2p over uncached
|
878 |
+
if (aCanbeCached && !bCanbeCached && !aCached) return 1;
|
879 |
+
if (!aCanbeCached && bCanbeCached && !bCached) return -1;
|
880 |
+
if (aCanbeCached && bCanbeCached) {
|
881 |
+
if (aCached === bCached) return 0;
|
882 |
+
// prioritise a false value over undefined
|
883 |
+
if (aCached === false && bCached === undefined) return -1;
|
884 |
+
if (aCached === undefined && bCached === false) return 1;
|
885 |
+
return this.config.sortBy.find(
|
886 |
+
(sort) => Object.keys(sort)[0] === 'cached'
|
887 |
+
)?.direction === 'asc'
|
888 |
+
? aCached
|
889 |
+
? 1
|
890 |
+
: -1 // uncached > cached
|
891 |
+
: aCached
|
892 |
+
? -1
|
893 |
+
: 1; // cached > uncached
|
894 |
+
}
|
895 |
+
} else if (field === 'personal') {
|
896 |
+
// depending on direction, sort by personal or not personal
|
897 |
+
const direction = this.config.sortBy.find(
|
898 |
+
(sort) => Object.keys(sort)[0] === 'personal'
|
899 |
+
)?.direction;
|
900 |
+
if (direction === 'asc') {
|
901 |
+
// prefer not personal over personal
|
902 |
+
return a.personal === b.personal ? 0 : a.personal ? 1 : -1;
|
903 |
+
}
|
904 |
+
if (direction === 'desc') {
|
905 |
+
// prefer personal over not personal
|
906 |
+
return a.personal === b.personal ? 0 : a.personal ? -1 : 1;
|
907 |
+
}
|
908 |
+
} else if (field === 'service') {
|
909 |
+
// sort files with providers by name
|
910 |
+
let aProvider = a.provider?.id;
|
911 |
+
let bProvider = b.provider?.id;
|
912 |
+
|
913 |
+
if (aProvider && bProvider) {
|
914 |
+
const aIndex = this.config.services.findIndex(
|
915 |
+
(service) => service.id === aProvider
|
916 |
+
);
|
917 |
+
const bIndex = this.config.services.findIndex(
|
918 |
+
(service) => service.id === bProvider
|
919 |
+
);
|
920 |
+
return aIndex - bIndex;
|
921 |
+
}
|
922 |
+
} else if (field === 'size') {
|
923 |
+
return this.config.sortBy.find((sort) => Object.keys(sort)[0] === 'size')
|
924 |
+
?.direction === 'asc'
|
925 |
+
? (a.size || 0) - (b.size || 0)
|
926 |
+
: (b.size || 0) - (a.size || 0);
|
927 |
+
} else if (field === 'seeders') {
|
928 |
+
if (
|
929 |
+
a.torrent?.seeders !== undefined &&
|
930 |
+
b.torrent?.seeders !== undefined
|
931 |
+
) {
|
932 |
+
return this.config.sortBy.find(
|
933 |
+
(sort) => Object.keys(sort)[0] === 'seeders'
|
934 |
+
)?.direction === 'asc'
|
935 |
+
? a.torrent.seeders - b.torrent.seeders
|
936 |
+
: b.torrent.seeders - a.torrent.seeders;
|
937 |
+
} else if (
|
938 |
+
a.torrent?.seeders !== undefined &&
|
939 |
+
b.torrent?.seeders === undefined
|
940 |
+
) {
|
941 |
+
return -1;
|
942 |
+
} else if (
|
943 |
+
a.torrent?.seeders === undefined &&
|
944 |
+
b.torrent?.seeders !== undefined
|
945 |
+
) {
|
946 |
+
return 1;
|
947 |
+
}
|
948 |
+
} else if (field === 'streamType') {
|
949 |
+
return (
|
950 |
+
(this.config.streamTypes?.findIndex(
|
951 |
+
(streamType) => streamType[a.type]
|
952 |
+
) ?? -1) -
|
953 |
+
(this.config.streamTypes?.findIndex(
|
954 |
+
(streamType) => streamType[b.type]
|
955 |
+
) ?? -1)
|
956 |
+
);
|
957 |
+
} else if (field === 'quality') {
|
958 |
+
return (
|
959 |
+
this.config.qualities.findIndex((quality) => quality[a.quality]) -
|
960 |
+
this.config.qualities.findIndex((quality) => quality[b.quality])
|
961 |
+
);
|
962 |
+
} else if (field === 'visualTag') {
|
963 |
+
// Find the highest priority visual tag in each file
|
964 |
+
const getIndexOfTag = (tag: string) =>
|
965 |
+
this.config.visualTags.findIndex((t) => t[tag]);
|
966 |
+
|
967 |
+
const getHighestPriorityTagIndex = (tags: string[]) => {
|
968 |
+
// Check if the file contains both any HDR tag and DV
|
969 |
+
const hasHDR = tags.some((tag) => tag.startsWith('HDR'));
|
970 |
+
const hasDV = tags.includes('DV');
|
971 |
+
|
972 |
+
if (hasHDR && hasDV) {
|
973 |
+
// Sort according to the position of the HDR+DV tag
|
974 |
+
const hdrDvIndex = this.config.visualTags.findIndex(
|
975 |
+
(t) => t['HDR+DV']
|
976 |
+
);
|
977 |
+
if (hdrDvIndex !== -1) {
|
978 |
+
return hdrDvIndex;
|
979 |
+
}
|
980 |
+
}
|
981 |
+
|
982 |
+
// If the file contains multiple HDR tags, look at the HDR tag that has the highest priority
|
983 |
+
const hdrTagIndices = tags
|
984 |
+
.filter((tag) => tag.startsWith('HDR'))
|
985 |
+
.map((tag) => getIndexOfTag(tag));
|
986 |
+
if (hdrTagIndices.length > 0) {
|
987 |
+
return Math.min(...hdrTagIndices);
|
988 |
+
}
|
989 |
+
|
990 |
+
// Always consider the highest priority visual tag when a file has multiple visual tags
|
991 |
+
return tags.reduce(
|
992 |
+
(minIndex, tag) => Math.min(minIndex, getIndexOfTag(tag)),
|
993 |
+
this.config.visualTags.length
|
994 |
+
);
|
995 |
+
};
|
996 |
+
|
997 |
+
const aVisualTagIndex = getHighestPriorityTagIndex(a.visualTags);
|
998 |
+
const bVisualTagIndex = getHighestPriorityTagIndex(b.visualTags);
|
999 |
+
|
1000 |
+
// Sort by the visual tag index
|
1001 |
+
return aVisualTagIndex - bVisualTagIndex;
|
1002 |
+
} else if (field === 'audioTag') {
|
1003 |
+
// Find the highest priority audio tag in each file
|
1004 |
+
const getIndexOfTag = (tag: string) =>
|
1005 |
+
this.config.audioTags.findIndex((t) => t[tag]);
|
1006 |
+
const aAudioTagIndex = a.audioTags.reduce(
|
1007 |
+
(minIndex, tag) => Math.min(minIndex, getIndexOfTag(tag)),
|
1008 |
+
this.config.audioTags.length
|
1009 |
+
);
|
1010 |
+
|
1011 |
+
const bAudioTagIndex = b.audioTags.reduce(
|
1012 |
+
(minIndex, tag) => Math.min(minIndex, getIndexOfTag(tag)),
|
1013 |
+
this.config.audioTags.length
|
1014 |
+
);
|
1015 |
+
// Sort by the audio tag index
|
1016 |
+
return aAudioTagIndex - bAudioTagIndex;
|
1017 |
+
} else if (field === 'encode') {
|
1018 |
+
return (
|
1019 |
+
this.config.encodes.findIndex((encode) => encode[a.encode]) -
|
1020 |
+
this.config.encodes.findIndex((encode) => encode[b.encode])
|
1021 |
+
);
|
1022 |
+
} else if (field === 'addon') {
|
1023 |
+
const aAddon = a.addon.id;
|
1024 |
+
const bAddon = b.addon.id;
|
1025 |
+
|
1026 |
+
const addonIds = this.config.addons.map((addon) => {
|
1027 |
+
return `${addon.id}-${JSON.stringify(addon.options)}`;
|
1028 |
+
});
|
1029 |
+
return addonIds.indexOf(aAddon) - addonIds.indexOf(bAddon);
|
1030 |
+
} else if (field === 'language') {
|
1031 |
+
if (this.config.prioritiseLanguage) {
|
1032 |
+
return this.compareLanguages(a, b);
|
1033 |
+
}
|
1034 |
+
if (!this.config.prioritisedLanguages) {
|
1035 |
+
return 0;
|
1036 |
+
}
|
1037 |
+
// else, we look at the array of prioritisedLanguages.
|
1038 |
+
// any file with a language in the prioritisedLanguages array should be prioritised
|
1039 |
+
// if both files contain a prioritisedLanguage, we compare the index of the highest priority language
|
1040 |
+
|
1041 |
+
const aHasPrioritisedLanguage =
|
1042 |
+
a.languages.some((lang) =>
|
1043 |
+
this.config.prioritisedLanguages?.includes(lang)
|
1044 |
+
) ||
|
1045 |
+
(a.languages.length === 0 &&
|
1046 |
+
this.config.prioritisedLanguages?.includes('Unknown'));
|
1047 |
+
const bHasPrioritisedLanguage =
|
1048 |
+
b.languages.some((lang) =>
|
1049 |
+
this.config.prioritisedLanguages?.includes(lang)
|
1050 |
+
) ||
|
1051 |
+
(b.languages.length === 0 &&
|
1052 |
+
this.config.prioritisedLanguages?.includes('Unknown'));
|
1053 |
+
|
1054 |
+
if (aHasPrioritisedLanguage && !bHasPrioritisedLanguage) return -1;
|
1055 |
+
if (!aHasPrioritisedLanguage && bHasPrioritisedLanguage) return 1;
|
1056 |
+
|
1057 |
+
if (aHasPrioritisedLanguage && bHasPrioritisedLanguage) {
|
1058 |
+
const getHighestPriorityLanguageIndex = (languages: string[]) => {
|
1059 |
+
if (languages.length === 0) {
|
1060 |
+
const unknownIndex =
|
1061 |
+
this.config.prioritisedLanguages!.indexOf('Unknown');
|
1062 |
+
return unknownIndex !== -1
|
1063 |
+
? unknownIndex
|
1064 |
+
: this.config.prioritisedLanguages!.length;
|
1065 |
+
}
|
1066 |
+
return languages.reduce((minIndex, lang) => {
|
1067 |
+
const index =
|
1068 |
+
this.config.prioritisedLanguages?.indexOf(lang) ??
|
1069 |
+
this.config.prioritisedLanguages!.length;
|
1070 |
+
return index !== -1 ? Math.min(minIndex, index) : minIndex;
|
1071 |
+
}, this.config.prioritisedLanguages!.length);
|
1072 |
+
};
|
1073 |
+
|
1074 |
+
const aHighestPriorityLanguageIndex = getHighestPriorityLanguageIndex(
|
1075 |
+
a.languages
|
1076 |
+
);
|
1077 |
+
const bHighestPriorityLanguageIndex = getHighestPriorityLanguageIndex(
|
1078 |
+
b.languages
|
1079 |
+
);
|
1080 |
+
|
1081 |
+
return aHighestPriorityLanguageIndex - bHighestPriorityLanguageIndex;
|
1082 |
+
}
|
1083 |
+
}
|
1084 |
+
return 0;
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
private async getParsedStreams(
|
1088 |
+
streamRequest: StreamRequest
|
1089 |
+
): Promise<{ parsedStreams: ParsedStream[]; errorStreams: ErrorStream[] }> {
|
1090 |
+
const parsedStreams: ParsedStream[] = [];
|
1091 |
+
const errorStreams: ErrorStream[] = [];
|
1092 |
+
const formatError = (error: string) =>
|
1093 |
+
typeof error === 'string'
|
1094 |
+
? error
|
1095 |
+
.replace(/- |: /g, '\n')
|
1096 |
+
.split('\n')
|
1097 |
+
.map((line: string) => line.trim())
|
1098 |
+
.join('\n')
|
1099 |
+
.trim()
|
1100 |
+
: error;
|
1101 |
+
|
1102 |
+
const addonPromises = this.config.addons.map(async (addon) => {
|
1103 |
+
const addonName =
|
1104 |
+
addon.options.name ||
|
1105 |
+
addon.options.overrideName ||
|
1106 |
+
addonDetails.find((addonDetail) => addonDetail.id === addon.id)?.name ||
|
1107 |
+
addon.id;
|
1108 |
+
const addonId = `${addon.id}-${JSON.stringify(addon.options)}`;
|
1109 |
+
try {
|
1110 |
+
const startTime = new Date().getTime();
|
1111 |
+
const { addonStreams, addonErrors } = await this.getStreamsFromAddon(
|
1112 |
+
addon,
|
1113 |
+
addonId,
|
1114 |
+
streamRequest
|
1115 |
+
);
|
1116 |
+
parsedStreams.push(...addonStreams);
|
1117 |
+
errorStreams.push(
|
1118 |
+
...[...new Set(addonErrors)].map((error) => ({
|
1119 |
+
error: formatError(error),
|
1120 |
+
addon: { id: addonId, name: addonName },
|
1121 |
+
}))
|
1122 |
+
);
|
1123 |
+
logger.info(
|
1124 |
+
`Got ${addonStreams.length} streams ${addonErrors.length > 0 ? `and ${addonErrors.length} errors ` : ''}from addon ${addonName} in ${getTimeTakenSincePoint(startTime)}`
|
1125 |
+
);
|
1126 |
+
} catch (error: any) {
|
1127 |
+
logger.error(`Failed to get streams from ${addonName}: ${error}`);
|
1128 |
+
errorStreams.push({
|
1129 |
+
error: formatError(error.message ?? error ?? 'Unknown error'),
|
1130 |
+
addon: {
|
1131 |
+
id: addonId,
|
1132 |
+
name: addonName,
|
1133 |
+
},
|
1134 |
+
});
|
1135 |
+
}
|
1136 |
+
});
|
1137 |
+
|
1138 |
+
await Promise.all(addonPromises);
|
1139 |
+
return { parsedStreams, errorStreams };
|
1140 |
+
}
|
1141 |
+
|
1142 |
+
private async getStreamsFromAddon(
|
1143 |
+
addon: Config['addons'][0],
|
1144 |
+
addonId: string,
|
1145 |
+
streamRequest: StreamRequest
|
1146 |
+
): Promise<{ addonStreams: ParsedStream[]; addonErrors: string[] }> {
|
1147 |
+
switch (addon.id) {
|
1148 |
+
case 'torbox': {
|
1149 |
+
return await getTorboxStreams(
|
1150 |
+
this.config,
|
1151 |
+
addon.options,
|
1152 |
+
streamRequest,
|
1153 |
+
addonId
|
1154 |
+
);
|
1155 |
+
}
|
1156 |
+
case 'torrentio': {
|
1157 |
+
return await getTorrentioStreams(
|
1158 |
+
this.config,
|
1159 |
+
addon.options,
|
1160 |
+
streamRequest,
|
1161 |
+
addonId
|
1162 |
+
);
|
1163 |
+
}
|
1164 |
+
case 'comet': {
|
1165 |
+
return await getCometStreams(
|
1166 |
+
this.config,
|
1167 |
+
addon.options,
|
1168 |
+
streamRequest,
|
1169 |
+
addonId
|
1170 |
+
);
|
1171 |
+
}
|
1172 |
+
case 'mediafusion': {
|
1173 |
+
return await getMediafusionStreams(
|
1174 |
+
this.config,
|
1175 |
+
addon.options,
|
1176 |
+
streamRequest,
|
1177 |
+
addonId
|
1178 |
+
);
|
1179 |
+
}
|
1180 |
+
case 'stremio-jackett': {
|
1181 |
+
return await getStremioJackettStreams(
|
1182 |
+
this.config,
|
1183 |
+
addon.options,
|
1184 |
+
streamRequest,
|
1185 |
+
addonId
|
1186 |
+
);
|
1187 |
+
}
|
1188 |
+
case 'jackettio': {
|
1189 |
+
return await getJackettioStreams(
|
1190 |
+
this.config,
|
1191 |
+
addon.options,
|
1192 |
+
streamRequest,
|
1193 |
+
addonId
|
1194 |
+
);
|
1195 |
+
}
|
1196 |
+
case 'orion-stremio-addon': {
|
1197 |
+
return await getOrionStreams(
|
1198 |
+
this.config,
|
1199 |
+
addon.options,
|
1200 |
+
streamRequest,
|
1201 |
+
addonId
|
1202 |
+
);
|
1203 |
+
}
|
1204 |
+
case 'easynews': {
|
1205 |
+
return await getEasynewsStreams(
|
1206 |
+
this.config,
|
1207 |
+
addon.options,
|
1208 |
+
streamRequest,
|
1209 |
+
addonId
|
1210 |
+
);
|
1211 |
+
}
|
1212 |
+
case 'easynews-plus': {
|
1213 |
+
return await getEasynewsPlusStreams(
|
1214 |
+
this.config,
|
1215 |
+
addon.options,
|
1216 |
+
streamRequest,
|
1217 |
+
addonId
|
1218 |
+
);
|
1219 |
+
}
|
1220 |
+
case 'easynews-plus-plus': {
|
1221 |
+
return await getEasynewsPlusPlusStreams(
|
1222 |
+
this.config,
|
1223 |
+
addon.options,
|
1224 |
+
streamRequest,
|
1225 |
+
addonId
|
1226 |
+
);
|
1227 |
+
}
|
1228 |
+
case 'debridio': {
|
1229 |
+
return await getDebridioStreams(
|
1230 |
+
this.config,
|
1231 |
+
addon.options,
|
1232 |
+
streamRequest,
|
1233 |
+
addonId
|
1234 |
+
);
|
1235 |
+
}
|
1236 |
+
case 'peerflix': {
|
1237 |
+
return await getPeerflixStreams(
|
1238 |
+
this.config,
|
1239 |
+
addon.options,
|
1240 |
+
streamRequest,
|
1241 |
+
addonId
|
1242 |
+
);
|
1243 |
+
}
|
1244 |
+
case 'stremthru-store': {
|
1245 |
+
return await getStremThruStoreStreams(
|
1246 |
+
this.config,
|
1247 |
+
addon.options,
|
1248 |
+
streamRequest,
|
1249 |
+
addonId
|
1250 |
+
);
|
1251 |
+
}
|
1252 |
+
case 'dmm-cast': {
|
1253 |
+
return await getDMMCastStreams(
|
1254 |
+
this.config,
|
1255 |
+
addon.options,
|
1256 |
+
streamRequest,
|
1257 |
+
addonId
|
1258 |
+
);
|
1259 |
+
}
|
1260 |
+
case 'gdrive': {
|
1261 |
+
if (!addon.options.addonUrl) {
|
1262 |
+
throw new Error('The addon URL was undefined for GDrive');
|
1263 |
+
}
|
1264 |
+
const wrapper = new BaseWrapper(
|
1265 |
+
addon.options.overrideName || 'GDrive',
|
1266 |
+
addon.options.addonUrl,
|
1267 |
+
addonId,
|
1268 |
+
this.config,
|
1269 |
+
addon.options.indexerTimeout
|
1270 |
+
? parseInt(addon.options.indexerTimeout)
|
1271 |
+
: Settings.DEFAULT_GDRIVE_TIMEOUT
|
1272 |
+
);
|
1273 |
+
return await wrapper.getParsedStreams(streamRequest);
|
1274 |
+
}
|
1275 |
+
default: {
|
1276 |
+
if (!addon.options.url) {
|
1277 |
+
throw new Error(
|
1278 |
+
`The addon URL was undefined for ${addon.options.name}`
|
1279 |
+
);
|
1280 |
+
}
|
1281 |
+
const wrapper = new BaseWrapper(
|
1282 |
+
addon.options.name || 'Custom',
|
1283 |
+
addon.options.url.trim(),
|
1284 |
+
addonId,
|
1285 |
+
this.config,
|
1286 |
+
addon.options.indexerTimeout
|
1287 |
+
? parseInt(addon.options.indexerTimeout)
|
1288 |
+
: undefined
|
1289 |
+
);
|
1290 |
+
return wrapper.getParsedStreams(streamRequest);
|
1291 |
+
}
|
1292 |
+
}
|
1293 |
+
}
|
1294 |
+
private async processGroupedStreams(
|
1295 |
+
groupedStreams: Record<string, ParsedStream[]>
|
1296 |
+
) {
|
1297 |
+
const uniqueStreams: ParsedStream[] = [];
|
1298 |
+
Object.values(groupedStreams).forEach((groupedStreams) => {
|
1299 |
+
if (groupedStreams.length === 1) {
|
1300 |
+
uniqueStreams.push(groupedStreams[0]);
|
1301 |
+
return;
|
1302 |
+
}
|
1303 |
+
|
1304 |
+
/*logger.info(
|
1305 |
+
`==================\nDetermining unique streams for ${groupedStreams[0].filename} from ${groupedStreams.length} total duplicates`
|
1306 |
+
);
|
1307 |
+
logger.info(
|
1308 |
+
groupedStreams.map(
|
1309 |
+
(stream) =>
|
1310 |
+
`Addon ID: ${stream.addon.id}, Provider ID: ${stream.provider?.id}, Provider Cached: ${stream.provider?.cached}, type: ${stream.torrent ? 'torrent' : 'usenet'}`
|
1311 |
+
)
|
1312 |
+
);
|
1313 |
+
logger.info('==================');*/
|
1314 |
+
// Separate streams into categories
|
1315 |
+
const cachedStreams = groupedStreams.filter(
|
1316 |
+
(stream) => stream.provider?.cached || (!stream.provider && stream.url)
|
1317 |
+
);
|
1318 |
+
const uncachedStreams = groupedStreams.filter(
|
1319 |
+
(stream) => stream.provider && !stream.provider.cached
|
1320 |
+
);
|
1321 |
+
const noProviderStreams = groupedStreams.filter(
|
1322 |
+
(stream) => !stream.provider && stream.torrent?.infoHash
|
1323 |
+
);
|
1324 |
+
|
1325 |
+
// Select uncached streams by addon priority (one per provider)
|
1326 |
+
const selectedUncachedStreams = Object.values(
|
1327 |
+
uncachedStreams.reduce(
|
1328 |
+
(acc, stream) => {
|
1329 |
+
acc[stream.provider!.id] = acc[stream.provider!.id] || [];
|
1330 |
+
acc[stream.provider!.id].push(stream);
|
1331 |
+
return acc;
|
1332 |
+
},
|
1333 |
+
{} as Record<string, ParsedStream[]>
|
1334 |
+
)
|
1335 |
+
).map((providerGroup) => {
|
1336 |
+
return providerGroup.sort((a, b) => {
|
1337 |
+
const aIndex = this.config.addons.findIndex(
|
1338 |
+
(addon) =>
|
1339 |
+
`${addon.id}-${JSON.stringify(addon.options)}` === a.addon.id
|
1340 |
+
);
|
1341 |
+
const bIndex = this.config.addons.findIndex(
|
1342 |
+
(addon) =>
|
1343 |
+
`${addon.id}-${JSON.stringify(addon.options)}` === b.addon.id
|
1344 |
+
);
|
1345 |
+
return aIndex - bIndex;
|
1346 |
+
})[0];
|
1347 |
+
});
|
1348 |
+
//selectedUncachedStreams.forEach(stream => logger.info(`Selected uncached stream for provider ${stream.provider!.id}: Addon ID: ${stream.addon.id}`));
|
1349 |
+
|
1350 |
+
// Select cached streams by provider and addon priority
|
1351 |
+
const selectedCachedStream = cachedStreams.sort((a, b) => {
|
1352 |
+
const aProviderIndex = this.config.services.findIndex(
|
1353 |
+
(service) => service.id === a.provider?.id
|
1354 |
+
);
|
1355 |
+
const bProviderIndex = this.config.services.findIndex(
|
1356 |
+
(service) => service.id === b.provider?.id
|
1357 |
+
);
|
1358 |
+
|
1359 |
+
if (aProviderIndex !== bProviderIndex) {
|
1360 |
+
return aProviderIndex - bProviderIndex;
|
1361 |
+
}
|
1362 |
+
|
1363 |
+
const aAddonIndex = this.config.addons.findIndex(
|
1364 |
+
(addon) =>
|
1365 |
+
`${addon.id}-${JSON.stringify(addon.options)}` === a.addon.id
|
1366 |
+
);
|
1367 |
+
const bAddonIndex = this.config.addons.findIndex(
|
1368 |
+
(addon) =>
|
1369 |
+
`${addon.id}-${JSON.stringify(addon.options)}` === b.addon.id
|
1370 |
+
);
|
1371 |
+
|
1372 |
+
if (aAddonIndex !== bAddonIndex) {
|
1373 |
+
return aAddonIndex - bAddonIndex;
|
1374 |
+
}
|
1375 |
+
|
1376 |
+
// now look at the type of stream. prefer usenet over torrents
|
1377 |
+
if (a.torrent?.seeders && !b.torrent?.seeders) return 1;
|
1378 |
+
if (!a.torrent?.seeders && b.torrent?.seeders) return -1;
|
1379 |
+
return 0;
|
1380 |
+
})[0];
|
1381 |
+
// Select one non-provider stream (highest addon priority)
|
1382 |
+
const selectedNoProviderStream = noProviderStreams.sort((a, b) => {
|
1383 |
+
const aIndex = this.config.addons.findIndex(
|
1384 |
+
(addon) =>
|
1385 |
+
`${addon.id}-${JSON.stringify(addon.options)}` === a.addon.id
|
1386 |
+
);
|
1387 |
+
const bIndex = this.config.addons.findIndex(
|
1388 |
+
(addon) =>
|
1389 |
+
`${addon.id}-${JSON.stringify(addon.options)}` === b.addon.id
|
1390 |
+
);
|
1391 |
+
|
1392 |
+
if (aIndex !== bIndex) {
|
1393 |
+
return aIndex - bIndex;
|
1394 |
+
}
|
1395 |
+
|
1396 |
+
// now look at the type of stream. prefer usenet over torrents
|
1397 |
+
if (a.torrent?.seeders && !b.torrent?.seeders) return 1;
|
1398 |
+
if (!a.torrent?.seeders && b.torrent?.seeders) return -1;
|
1399 |
+
return 0;
|
1400 |
+
})[0];
|
1401 |
+
|
1402 |
+
// Combine selected streams for this group
|
1403 |
+
if (selectedNoProviderStream) {
|
1404 |
+
//logger.info(`Selected no provider stream: Addon ID: ${selectedNoProviderStream.addon.id}`);
|
1405 |
+
uniqueStreams.push(selectedNoProviderStream);
|
1406 |
+
}
|
1407 |
+
if (selectedCachedStream) {
|
1408 |
+
//logger.info(`Selected cached stream for provider ${selectedCachedStream.provider!.id} from Addon ID: ${selectedCachedStream.addon.id}`);
|
1409 |
+
uniqueStreams.push(selectedCachedStream);
|
1410 |
+
}
|
1411 |
+
uniqueStreams.push(...selectedUncachedStreams);
|
1412 |
+
});
|
1413 |
+
|
1414 |
+
return uniqueStreams;
|
1415 |
+
}
|
1416 |
+
}
|
packages/addon/src/config.ts
ADDED
@@ -0,0 +1,537 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { AddonDetail, Config } from '@aiostreams/types';
|
2 |
+
import {
|
3 |
+
addonDetails,
|
4 |
+
isValueEncrypted,
|
5 |
+
parseAndDecryptString,
|
6 |
+
serviceDetails,
|
7 |
+
Settings,
|
8 |
+
unminifyConfig,
|
9 |
+
} from '@aiostreams/utils';
|
10 |
+
|
11 |
+
export const allowedFormatters = [
|
12 |
+
'gdrive',
|
13 |
+
'minimalistic-gdrive',
|
14 |
+
'torrentio',
|
15 |
+
'torbox',
|
16 |
+
'imposter',
|
17 |
+
'custom',
|
18 |
+
];
|
19 |
+
|
20 |
+
export const allowedLanguages = [
|
21 |
+
'Multi',
|
22 |
+
'English',
|
23 |
+
'Japanese',
|
24 |
+
'Chinese',
|
25 |
+
'Russian',
|
26 |
+
'Arabic',
|
27 |
+
'Portuguese',
|
28 |
+
'Spanish',
|
29 |
+
'French',
|
30 |
+
'German',
|
31 |
+
'Italian',
|
32 |
+
'Korean',
|
33 |
+
'Hindi',
|
34 |
+
'Bengali',
|
35 |
+
'Punjabi',
|
36 |
+
'Marathi',
|
37 |
+
'Gujarati',
|
38 |
+
'Tamil',
|
39 |
+
'Telugu',
|
40 |
+
'Kannada',
|
41 |
+
'Malayalam',
|
42 |
+
'Thai',
|
43 |
+
'Vietnamese',
|
44 |
+
'Indonesian',
|
45 |
+
'Turkish',
|
46 |
+
'Hebrew',
|
47 |
+
'Persian',
|
48 |
+
'Ukrainian',
|
49 |
+
'Greek',
|
50 |
+
'Lithuanian',
|
51 |
+
'Latvian',
|
52 |
+
'Estonian',
|
53 |
+
'Polish',
|
54 |
+
'Czech',
|
55 |
+
'Slovak',
|
56 |
+
'Hungarian',
|
57 |
+
'Romanian',
|
58 |
+
'Bulgarian',
|
59 |
+
'Serbian',
|
60 |
+
'Croatian',
|
61 |
+
'Slovenian',
|
62 |
+
'Dutch',
|
63 |
+
'Danish',
|
64 |
+
'Finnish',
|
65 |
+
'Swedish',
|
66 |
+
'Norwegian',
|
67 |
+
'Malay',
|
68 |
+
'Latino',
|
69 |
+
'Unknown',
|
70 |
+
'Dual Audio',
|
71 |
+
'Dubbed',
|
72 |
+
];
|
73 |
+
|
74 |
+
export function validateConfig(
|
75 |
+
config: Config,
|
76 |
+
environment: 'client' | 'server' = 'server'
|
77 |
+
): {
|
78 |
+
valid: boolean;
|
79 |
+
errorCode: string | null;
|
80 |
+
errorMessage: string | null;
|
81 |
+
} {
|
82 |
+
config = unminifyConfig(config);
|
83 |
+
const createResponse = (
|
84 |
+
valid: boolean,
|
85 |
+
errorCode: string | null,
|
86 |
+
errorMessage: string | null
|
87 |
+
) => {
|
88 |
+
return { valid, errorCode, errorMessage };
|
89 |
+
};
|
90 |
+
|
91 |
+
if (config.addons.length < 1) {
|
92 |
+
return createResponse(
|
93 |
+
false,
|
94 |
+
'noAddons',
|
95 |
+
'At least one addon must be selected'
|
96 |
+
);
|
97 |
+
}
|
98 |
+
|
99 |
+
if (config.addons.length > Settings.MAX_ADDONS) {
|
100 |
+
return createResponse(
|
101 |
+
false,
|
102 |
+
'tooManyAddons',
|
103 |
+
`You can only select a maximum of ${Settings.MAX_ADDONS} addons`
|
104 |
+
);
|
105 |
+
}
|
106 |
+
// check for apiKey if Settings.API_KEY is set
|
107 |
+
if (environment === 'server' && Settings.API_KEY) {
|
108 |
+
const { apiKey } = config;
|
109 |
+
if (!apiKey) {
|
110 |
+
return createResponse(
|
111 |
+
false,
|
112 |
+
'missingApiKey',
|
113 |
+
'The AIOStreams API key is required'
|
114 |
+
);
|
115 |
+
}
|
116 |
+
let decryptedApiKey = apiKey;
|
117 |
+
if (isValueEncrypted(apiKey)) {
|
118 |
+
const decryptionResult = parseAndDecryptString(apiKey);
|
119 |
+
if (decryptionResult === null) {
|
120 |
+
return createResponse(
|
121 |
+
false,
|
122 |
+
'decryptionFailed',
|
123 |
+
'Failed to decrypt the AIOStreams API key'
|
124 |
+
);
|
125 |
+
} else if (decryptionResult === '') {
|
126 |
+
return createResponse(
|
127 |
+
false,
|
128 |
+
'emptyDecryption',
|
129 |
+
'Decrypted API key is empty'
|
130 |
+
);
|
131 |
+
}
|
132 |
+
decryptedApiKey = decryptionResult;
|
133 |
+
}
|
134 |
+
if (decryptedApiKey !== Settings.API_KEY) {
|
135 |
+
return createResponse(
|
136 |
+
false,
|
137 |
+
'invalidApiKey',
|
138 |
+
'Invalid AIOStreams API key. Please use the one defined in your environment variables'
|
139 |
+
);
|
140 |
+
}
|
141 |
+
}
|
142 |
+
const duplicateAddons = config.addons.filter(
|
143 |
+
(addon, index) =>
|
144 |
+
config.addons.findIndex(
|
145 |
+
(a) =>
|
146 |
+
a.id === addon.id &&
|
147 |
+
JSON.stringify(a.options) === JSON.stringify(addon.options)
|
148 |
+
) !== index
|
149 |
+
);
|
150 |
+
|
151 |
+
if (duplicateAddons.length > 0) {
|
152 |
+
return createResponse(
|
153 |
+
false,
|
154 |
+
'duplicateAddons',
|
155 |
+
'Duplicate addons found. Please remove any duplicates'
|
156 |
+
);
|
157 |
+
}
|
158 |
+
|
159 |
+
for (const addon of config.addons) {
|
160 |
+
if (Settings.DISABLE_TORRENTIO && addon.id === 'torrentio') {
|
161 |
+
return createResponse(
|
162 |
+
false,
|
163 |
+
'torrentioDisabled',
|
164 |
+
Settings.DISABLE_TORRENTIO_MESSAGE
|
165 |
+
);
|
166 |
+
}
|
167 |
+
|
168 |
+
const details = addonDetails.find(
|
169 |
+
(detail: AddonDetail) => detail.id === addon.id
|
170 |
+
);
|
171 |
+
if (!details) {
|
172 |
+
return createResponse(
|
173 |
+
false,
|
174 |
+
'invalidAddon',
|
175 |
+
`Invalid addon: ${addon.id}`
|
176 |
+
);
|
177 |
+
}
|
178 |
+
if (details.requiresService) {
|
179 |
+
const supportedServices = details.supportedServices;
|
180 |
+
const isAtLeastOneServiceEnabled = config.services.some(
|
181 |
+
(service) => supportedServices.includes(service.id) && service.enabled
|
182 |
+
);
|
183 |
+
const isOverrideUrlSet = addon.options?.overrideUrl;
|
184 |
+
if (!isAtLeastOneServiceEnabled && !isOverrideUrlSet) {
|
185 |
+
return createResponse(
|
186 |
+
false,
|
187 |
+
'missingService',
|
188 |
+
`${addon.options?.name || details.name} requires at least one of the following services to be enabled: ${supportedServices
|
189 |
+
.map(
|
190 |
+
(service) =>
|
191 |
+
serviceDetails.find((detail) => detail.id === service)?.name ||
|
192 |
+
service
|
193 |
+
)
|
194 |
+
.join(', ')}`
|
195 |
+
);
|
196 |
+
}
|
197 |
+
}
|
198 |
+
if (details.options) {
|
199 |
+
for (const option of details.options) {
|
200 |
+
if (option.required && !addon.options[option.id]) {
|
201 |
+
return createResponse(
|
202 |
+
false,
|
203 |
+
'missingRequiredOption',
|
204 |
+
`Option ${option.label} is required for addon ${addon.id}`
|
205 |
+
);
|
206 |
+
}
|
207 |
+
|
208 |
+
if (
|
209 |
+
option.id.toLowerCase().includes('url') &&
|
210 |
+
addon.options[option.id] &&
|
211 |
+
((isValueEncrypted(addon.options[option.id]) &&
|
212 |
+
environment === 'server') ||
|
213 |
+
!isValueEncrypted(addon.options[option.id]))
|
214 |
+
) {
|
215 |
+
const url = parseAndDecryptString(addon.options[option.id] ?? '');
|
216 |
+
if (url === null) {
|
217 |
+
return createResponse(
|
218 |
+
false,
|
219 |
+
'decryptionFailed',
|
220 |
+
`Failed to decrypt URL for ${option.label}`
|
221 |
+
);
|
222 |
+
} else if (url === '') {
|
223 |
+
return createResponse(
|
224 |
+
false,
|
225 |
+
'emptyDecryption',
|
226 |
+
`Decrypted URL for ${option.label} is empty`
|
227 |
+
);
|
228 |
+
}
|
229 |
+
if (
|
230 |
+
Settings.DISABLE_TORRENTIO &&
|
231 |
+
url.match(/torrentio\.strem\.fun/) !== null
|
232 |
+
) {
|
233 |
+
// if torrentio is disabled, don't allow the user to set URLs with torrentio.strem.fun
|
234 |
+
return createResponse(
|
235 |
+
false,
|
236 |
+
'torrentioDisabled',
|
237 |
+
Settings.DISABLE_TORRENTIO_MESSAGE
|
238 |
+
);
|
239 |
+
} else if (
|
240 |
+
Settings.DISABLE_TORRENTIO &&
|
241 |
+
url.match(/stremthru\.elfhosted\.com/) !== null
|
242 |
+
) {
|
243 |
+
// if torrentio is disabled, we need to inspect the stremthru URL to see if it's using torrentio
|
244 |
+
try {
|
245 |
+
const parsedUrl = new URL(url);
|
246 |
+
// get the component before manifest.json
|
247 |
+
const pathComponents = parsedUrl.pathname.split('/');
|
248 |
+
if (pathComponents.includes('manifest.json')) {
|
249 |
+
const index = pathComponents.indexOf('manifest.json');
|
250 |
+
const componentBeforeManifest = pathComponents[index - 1];
|
251 |
+
// base64 decode the component before manifest.json
|
252 |
+
const decodedComponent = atob(componentBeforeManifest);
|
253 |
+
const stremthruData = JSON.parse(decodedComponent);
|
254 |
+
if (stremthruData?.manifest_url?.match(/torrentio.strem.fun/)) {
|
255 |
+
return createResponse(
|
256 |
+
false,
|
257 |
+
'torrentioDisabled',
|
258 |
+
Settings.DISABLE_TORRENTIO_MESSAGE
|
259 |
+
);
|
260 |
+
}
|
261 |
+
}
|
262 |
+
} catch (_) {
|
263 |
+
// ignore
|
264 |
+
}
|
265 |
+
} else {
|
266 |
+
try {
|
267 |
+
new URL(url);
|
268 |
+
} catch (_) {
|
269 |
+
return createResponse(
|
270 |
+
false,
|
271 |
+
'invalidUrl',
|
272 |
+
` Invalid URL for ${option.label}`
|
273 |
+
);
|
274 |
+
}
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
if (option.type === 'number' && addon.options[option.id]) {
|
279 |
+
const input = addon.options[option.id];
|
280 |
+
if (input !== undefined && !parseInt(input)) {
|
281 |
+
return createResponse(
|
282 |
+
false,
|
283 |
+
'invalidNumber',
|
284 |
+
`${option.label} must be a number`
|
285 |
+
);
|
286 |
+
} else if (input !== undefined) {
|
287 |
+
const value = parseInt(input);
|
288 |
+
const { min, max } = option.constraints || {};
|
289 |
+
if (
|
290 |
+
(min !== undefined && value < min) ||
|
291 |
+
(max !== undefined && value > max)
|
292 |
+
) {
|
293 |
+
return createResponse(
|
294 |
+
false,
|
295 |
+
'invalidNumber',
|
296 |
+
`${option.label} must be between ${min} and ${max}`
|
297 |
+
);
|
298 |
+
}
|
299 |
+
}
|
300 |
+
}
|
301 |
+
}
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
if (!allowedFormatters.includes(config.formatter)) {
|
306 |
+
if (config.formatter.startsWith('custom') && config.formatter.length > 7) {
|
307 |
+
const jsonString = config.formatter.slice(7);
|
308 |
+
const data = JSON.parse(jsonString);
|
309 |
+
if (!data.name || !data.description) {
|
310 |
+
return createResponse(
|
311 |
+
false,
|
312 |
+
'invalidCustomFormatter',
|
313 |
+
'Invalid custom formatter: name and description are required'
|
314 |
+
);
|
315 |
+
}
|
316 |
+
} else {
|
317 |
+
return createResponse(
|
318 |
+
false,
|
319 |
+
'invalidFormatter',
|
320 |
+
`Invalid formatter: ${config.formatter}`
|
321 |
+
);
|
322 |
+
}
|
323 |
+
}
|
324 |
+
for (const service of config.services) {
|
325 |
+
if (service.enabled) {
|
326 |
+
const serviceDetail = serviceDetails.find(
|
327 |
+
(detail) => detail.id === service.id
|
328 |
+
);
|
329 |
+
if (!serviceDetail) {
|
330 |
+
return createResponse(
|
331 |
+
false,
|
332 |
+
'invalidService',
|
333 |
+
`Invalid service: ${service.id}`
|
334 |
+
);
|
335 |
+
}
|
336 |
+
for (const credential of serviceDetail.credentials) {
|
337 |
+
if (!service.credentials[credential.id]) {
|
338 |
+
return createResponse(
|
339 |
+
false,
|
340 |
+
'missingCredential',
|
341 |
+
`${credential.label} is required for ${service.name}`
|
342 |
+
);
|
343 |
+
}
|
344 |
+
}
|
345 |
+
}
|
346 |
+
}
|
347 |
+
|
348 |
+
// need at least one visual tag, resolution, quality
|
349 |
+
|
350 |
+
if (
|
351 |
+
!config.visualTags.some((tag) => Object.values(tag)[0]) ||
|
352 |
+
!config.resolutions.some((resolution) => Object.values(resolution)[0]) ||
|
353 |
+
!config.qualities.some((quality) => Object.values(quality)[0])
|
354 |
+
) {
|
355 |
+
return createResponse(
|
356 |
+
false,
|
357 |
+
'noFilters',
|
358 |
+
'At least one visual tag, resolution, and quality must be selected'
|
359 |
+
);
|
360 |
+
}
|
361 |
+
|
362 |
+
for (const [min, max] of [
|
363 |
+
[config.minMovieSize, config.maxMovieSize],
|
364 |
+
[config.minEpisodeSize, config.maxEpisodeSize],
|
365 |
+
[config.minSize, config.maxSize],
|
366 |
+
]) {
|
367 |
+
if (min && max) {
|
368 |
+
if (min >= max) {
|
369 |
+
return createResponse(
|
370 |
+
false,
|
371 |
+
'invalidSizeRange',
|
372 |
+
"Your minimum size limit can't be greater than or equal to your maximum size limit"
|
373 |
+
);
|
374 |
+
}
|
375 |
+
}
|
376 |
+
}
|
377 |
+
|
378 |
+
if (config.maxResultsPerResolution && config.maxResultsPerResolution < 1) {
|
379 |
+
return createResponse(
|
380 |
+
false,
|
381 |
+
'invalidMaxResultsPerResolution',
|
382 |
+
'Max results per resolution must be greater than 0'
|
383 |
+
);
|
384 |
+
}
|
385 |
+
|
386 |
+
if (
|
387 |
+
config.mediaFlowConfig?.mediaFlowEnabled &&
|
388 |
+
config.stremThruConfig?.stremThruEnabled
|
389 |
+
) {
|
390 |
+
return createResponse(
|
391 |
+
false,
|
392 |
+
'multipleProxyServices',
|
393 |
+
'Multiple proxy services are not allowed'
|
394 |
+
);
|
395 |
+
}
|
396 |
+
if (config.mediaFlowConfig?.mediaFlowEnabled) {
|
397 |
+
if (!config.mediaFlowConfig.proxyUrl) {
|
398 |
+
return createResponse(
|
399 |
+
false,
|
400 |
+
'missingProxyUrl',
|
401 |
+
'Proxy URL is required if MediaFlow is enabled'
|
402 |
+
);
|
403 |
+
}
|
404 |
+
if (!config.mediaFlowConfig.apiPassword) {
|
405 |
+
return createResponse(
|
406 |
+
false,
|
407 |
+
'missingApiPassword',
|
408 |
+
'API Password is required if MediaFlow is enabled'
|
409 |
+
);
|
410 |
+
}
|
411 |
+
}
|
412 |
+
|
413 |
+
if (config.stremThruConfig?.stremThruEnabled) {
|
414 |
+
if (!config.stremThruConfig.url) {
|
415 |
+
return createResponse(
|
416 |
+
false,
|
417 |
+
'missingUrl',
|
418 |
+
'URL is required if Stremthru is enabled'
|
419 |
+
);
|
420 |
+
}
|
421 |
+
if (!config.stremThruConfig.credential) {
|
422 |
+
return createResponse(
|
423 |
+
false,
|
424 |
+
'missingCredential',
|
425 |
+
'Credential is required if StremThru is enabled'
|
426 |
+
);
|
427 |
+
}
|
428 |
+
}
|
429 |
+
|
430 |
+
if (
|
431 |
+
(config.excludeFilters?.length ?? 0) > Settings.MAX_KEYWORD_FILTERS ||
|
432 |
+
(config.strictIncludeFilters?.length ?? 0) > Settings.MAX_KEYWORD_FILTERS
|
433 |
+
) {
|
434 |
+
return createResponse(
|
435 |
+
false,
|
436 |
+
'tooManyFilters',
|
437 |
+
`You can only have a maximum of ${Settings.MAX_KEYWORD_FILTERS} filters`
|
438 |
+
);
|
439 |
+
}
|
440 |
+
|
441 |
+
const filters = [
|
442 |
+
...(config.excludeFilters || []),
|
443 |
+
...(config.strictIncludeFilters || []),
|
444 |
+
];
|
445 |
+
filters.forEach((filter) => {
|
446 |
+
if (filter.length > 20) {
|
447 |
+
return createResponse(
|
448 |
+
false,
|
449 |
+
'invalidFilter',
|
450 |
+
'One of your filters is too long'
|
451 |
+
);
|
452 |
+
}
|
453 |
+
if (!filter) {
|
454 |
+
return createResponse(
|
455 |
+
false,
|
456 |
+
'invalidFilter',
|
457 |
+
'Filters must not be empty'
|
458 |
+
);
|
459 |
+
}
|
460 |
+
});
|
461 |
+
|
462 |
+
if (config.regexFilters) {
|
463 |
+
if (!config.apiKey) {
|
464 |
+
return createResponse(
|
465 |
+
false,
|
466 |
+
'missingApiKey',
|
467 |
+
'Regex filtering requires an API key to be set'
|
468 |
+
);
|
469 |
+
}
|
470 |
+
|
471 |
+
if (config.regexFilters.excludePattern) {
|
472 |
+
try {
|
473 |
+
new RegExp(config.regexFilters.excludePattern);
|
474 |
+
} catch (e) {
|
475 |
+
return createResponse(
|
476 |
+
false,
|
477 |
+
'invalidExcludeRegex',
|
478 |
+
'Invalid exclude regex pattern'
|
479 |
+
);
|
480 |
+
}
|
481 |
+
}
|
482 |
+
|
483 |
+
if (config.regexFilters.includePattern) {
|
484 |
+
try {
|
485 |
+
new RegExp(config.regexFilters.includePattern);
|
486 |
+
} catch (e) {
|
487 |
+
return createResponse(
|
488 |
+
false,
|
489 |
+
'invalidIncludeRegex',
|
490 |
+
'Invalid include regex pattern'
|
491 |
+
);
|
492 |
+
}
|
493 |
+
}
|
494 |
+
}
|
495 |
+
|
496 |
+
if (config.regexSortPatterns) {
|
497 |
+
if (!config.apiKey) {
|
498 |
+
return createResponse(
|
499 |
+
false,
|
500 |
+
'missingApiKey',
|
501 |
+
'Regex sorting requires an API key to be set'
|
502 |
+
);
|
503 |
+
}
|
504 |
+
|
505 |
+
// Split the pattern by spaces and validate each one
|
506 |
+
const patterns = config.regexSortPatterns.split(/\s+/).filter(Boolean);
|
507 |
+
// Enforce an upper bound on the number of patterns
|
508 |
+
if (patterns.length > Settings.MAX_REGEX_SORT_PATTERNS) {
|
509 |
+
return createResponse(
|
510 |
+
false,
|
511 |
+
'tooManyRegexSortPatterns',
|
512 |
+
`You can specify at most ${Settings.MAX_REGEX_SORT_PATTERNS} regex sort patterns`
|
513 |
+
);
|
514 |
+
}
|
515 |
+
|
516 |
+
for (const pattern of patterns) {
|
517 |
+
const delimiter = '<::>';
|
518 |
+
const delimiterIndex = pattern.indexOf(delimiter);
|
519 |
+
let name: string = 'Unamed';
|
520 |
+
let regexPattern = pattern;
|
521 |
+
if (delimiterIndex !== -1) {
|
522 |
+
name = pattern.slice(0, delimiterIndex).replace(/_/g, ' ');
|
523 |
+
regexPattern = pattern.slice(delimiterIndex + delimiter.length);
|
524 |
+
}
|
525 |
+
try {
|
526 |
+
new RegExp(regexPattern);
|
527 |
+
} catch (e) {
|
528 |
+
return createResponse(
|
529 |
+
false,
|
530 |
+
'invalidRegexSortPattern',
|
531 |
+
`Invalid regex sort pattern: ${name ? `"${name}" ` : ''}${regexPattern}`
|
532 |
+
);
|
533 |
+
}
|
534 |
+
}
|
535 |
+
}
|
536 |
+
return createResponse(true, null, null);
|
537 |
+
}
|
packages/addon/src/index.ts
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export * from './addon';
|
2 |
+
export * from './config';
|
3 |
+
export * from './manifest';
|
4 |
+
export * from './responses';
|
packages/addon/src/manifest.ts
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Config } from '@aiostreams/types';
|
2 |
+
import { version, description } from '../../../package.json';
|
3 |
+
import { getTextHash, Settings } from '@aiostreams/utils';
|
4 |
+
|
5 |
+
const manifest = (config?: Config, configPresent?: boolean) => {
|
6 |
+
let addonId = Settings.ADDON_ID;
|
7 |
+
if (config && Settings.DETERMINISTIC_ADDON_ID) {
|
8 |
+
addonId =
|
9 |
+
addonId += `.${getTextHash(JSON.stringify(config)).substring(0, 12)}`;
|
10 |
+
}
|
11 |
+
return {
|
12 |
+
name: config?.overrideName || Settings.ADDON_NAME,
|
13 |
+
id: addonId,
|
14 |
+
version: version,
|
15 |
+
description: description,
|
16 |
+
catalogs: [],
|
17 |
+
resources: ['stream'],
|
18 |
+
background:
|
19 |
+
'https://raw.githubusercontent.com/Viren070/AIOStreams/refs/heads/main/packages/frontend/public/assets/background.png',
|
20 |
+
logo: 'https://raw.githubusercontent.com/Viren070/AIOStreams/refs/heads/main/packages/frontend/public/assets/logo.png',
|
21 |
+
types: ['movie', 'series'],
|
22 |
+
behaviorHints: {
|
23 |
+
configurable: true,
|
24 |
+
configurationRequired: config || configPresent ? false : true,
|
25 |
+
},
|
26 |
+
stremioAddonsConfig:
|
27 |
+
Settings.STREMIO_ADDONS_CONFIG_ISSUER &&
|
28 |
+
Settings.STREMIO_ADDONS_CONFIG_SIGNATURE
|
29 |
+
? {
|
30 |
+
issuer: Settings.STREMIO_ADDONS_CONFIG_ISSUER,
|
31 |
+
signature: Settings.STREMIO_ADDONS_CONFIG_SIGNATURE,
|
32 |
+
}
|
33 |
+
: undefined,
|
34 |
+
};
|
35 |
+
};
|
36 |
+
|
37 |
+
export default manifest;
|
packages/addon/src/responses.ts
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Settings } from '@aiostreams/utils';
|
2 |
+
|
3 |
+
export const errorResponse = (
|
4 |
+
errorMessage: string,
|
5 |
+
origin?: string,
|
6 |
+
path?: string,
|
7 |
+
externalUrl?: string
|
8 |
+
) => {
|
9 |
+
return {
|
10 |
+
streams: [errorStream(errorMessage, 'Error', origin, path, externalUrl)],
|
11 |
+
};
|
12 |
+
};
|
13 |
+
|
14 |
+
export const errorStream = (
|
15 |
+
errorMessage: string,
|
16 |
+
errorTitle?: string,
|
17 |
+
origin?: string,
|
18 |
+
path?: string,
|
19 |
+
externalUrl?: string
|
20 |
+
) => {
|
21 |
+
return {
|
22 |
+
externalUrl:
|
23 |
+
(origin && path ? origin + path : undefined) ||
|
24 |
+
externalUrl ||
|
25 |
+
'https://github.com/Viren070/AIOStreams',
|
26 |
+
name: `[❌] ${Settings.ADDON_NAME}\n${errorTitle || 'Error'}`,
|
27 |
+
description: errorMessage,
|
28 |
+
};
|
29 |
+
};
|
packages/addon/src/server.ts
ADDED
@@ -0,0 +1,645 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import express, { Request, Response } from 'express';
|
2 |
+
|
3 |
+
import path from 'path';
|
4 |
+
import { AIOStreams } from './addon';
|
5 |
+
import { Config, StreamRequest } from '@aiostreams/types';
|
6 |
+
import { validateConfig } from './config';
|
7 |
+
import manifest from './manifest';
|
8 |
+
import { errorResponse } from './responses';
|
9 |
+
import {
|
10 |
+
Settings,
|
11 |
+
addonDetails,
|
12 |
+
parseAndDecryptString,
|
13 |
+
Cache,
|
14 |
+
unminifyConfig,
|
15 |
+
minifyConfig,
|
16 |
+
crushJson,
|
17 |
+
compressData,
|
18 |
+
encryptData,
|
19 |
+
decompressData,
|
20 |
+
decryptData,
|
21 |
+
uncrushJson,
|
22 |
+
loadSecretKey,
|
23 |
+
createLogger,
|
24 |
+
getTimeTakenSincePoint,
|
25 |
+
isValueEncrypted,
|
26 |
+
maskSensitiveInfo,
|
27 |
+
} from '@aiostreams/utils';
|
28 |
+
|
29 |
+
const logger = createLogger('server');
|
30 |
+
|
31 |
+
const app = express();
|
32 |
+
//logger.info(`Starting server and loading settings...`);
|
33 |
+
logger.info('Starting server and loading settings...', { func: 'init' });
|
34 |
+
Object.entries(Settings).forEach(([key, value]) => {
|
35 |
+
switch (key) {
|
36 |
+
case 'SECRET_KEY':
|
37 |
+
if (value) {
|
38 |
+
logger.info(`${key} = ${value.replace(/./g, '*').slice(0, 64)}`);
|
39 |
+
}
|
40 |
+
break;
|
41 |
+
|
42 |
+
case 'BRANDING':
|
43 |
+
case 'CUSTOM_CONFIGS':
|
44 |
+
// Skip CUSTOM_CONFIGS processing here, handled later
|
45 |
+
break;
|
46 |
+
|
47 |
+
default:
|
48 |
+
logger.info(`${key} = ${value}`);
|
49 |
+
}
|
50 |
+
});
|
51 |
+
|
52 |
+
// attempt to load the secret key
|
53 |
+
try {
|
54 |
+
if (Settings.SECRET_KEY) loadSecretKey(true);
|
55 |
+
} catch (error: any) {
|
56 |
+
// determine command to run based on system OS
|
57 |
+
const command =
|
58 |
+
process.platform === 'win32'
|
59 |
+
? '[System.Guid]::NewGuid().ToString("N").Substring(0, 32) + [System.Guid]::NewGuid().ToString("N").Substring(0, 32)'
|
60 |
+
: 'openssl rand -hex 32';
|
61 |
+
logger.error(
|
62 |
+
`The secret key is invalid. You will not be able to generate configurations. You can generate a new secret key by running the following command\n${command}`
|
63 |
+
);
|
64 |
+
}
|
65 |
+
|
66 |
+
// Built-in middleware for parsing JSON
|
67 |
+
app.use(express.json());
|
68 |
+
// Built-in middleware for parsing URL-encoded data
|
69 |
+
app.use(express.urlencoded({ extended: true }));
|
70 |
+
|
71 |
+
// unhandled errors
|
72 |
+
app.use((err: any, req: Request, res: Response, next: any) => {
|
73 |
+
logger.error(`${err.message}`);
|
74 |
+
res.status(500).send('Internal server error');
|
75 |
+
});
|
76 |
+
|
77 |
+
app.use((req, res, next) => {
|
78 |
+
res.append('Access-Control-Allow-Origin', '*');
|
79 |
+
res.append('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
|
80 |
+
const start = Date.now();
|
81 |
+
res.on('finish', () => {
|
82 |
+
logger.info(
|
83 |
+
`${req.method} ${req.path
|
84 |
+
.replace(/\/ey[JI][\w\=]+/g, '/*******')
|
85 |
+
.replace(
|
86 |
+
/\/(E2?|B)?-[\w-\%]+/g,
|
87 |
+
'/*******'
|
88 |
+
)} - ${getIp(req) ? maskSensitiveInfo(getIp(req)!) : 'Unknown IP'} - ${res.statusCode} - ${getTimeTakenSincePoint(start)}`
|
89 |
+
);
|
90 |
+
});
|
91 |
+
next();
|
92 |
+
});
|
93 |
+
|
94 |
+
app.get('/', (req, res) => {
|
95 |
+
res.redirect('/configure');
|
96 |
+
});
|
97 |
+
|
98 |
+
app.get(
|
99 |
+
['/_next/*', '/assets/*', '/icon.ico', '/configure.txt'],
|
100 |
+
(req, res) => {
|
101 |
+
res.sendFile(path.join(__dirname, '../../frontend/out', req.path));
|
102 |
+
}
|
103 |
+
);
|
104 |
+
|
105 |
+
if (!Settings.DISABLE_CUSTOM_CONFIG_GENERATOR_ROUTE) {
|
106 |
+
app.get('/custom-config-generator', (req, res) => {
|
107 |
+
res.sendFile(
|
108 |
+
path.join(__dirname, '../../frontend/out/custom-config-generator.html')
|
109 |
+
);
|
110 |
+
});
|
111 |
+
}
|
112 |
+
|
113 |
+
app.get('/configure', (req, res) => {
|
114 |
+
res.sendFile(path.join(__dirname, '../../frontend/out/configure.html'));
|
115 |
+
});
|
116 |
+
|
117 |
+
app.get('/:config/configure', (req, res) => {
|
118 |
+
const config = req.params.config;
|
119 |
+
if (config.startsWith('eyJ') || config.startsWith('eyI')) {
|
120 |
+
return res.sendFile(
|
121 |
+
path.join(__dirname, '../../frontend/out/configure.html')
|
122 |
+
);
|
123 |
+
}
|
124 |
+
try {
|
125 |
+
let configJson = extractJsonConfig(config);
|
126 |
+
let configString = config;
|
127 |
+
if (Settings.CUSTOM_CONFIGS) {
|
128 |
+
const customConfig = extractCustomConfig(config);
|
129 |
+
if (customConfig) {
|
130 |
+
configJson = customConfig;
|
131 |
+
configString = decodeURIComponent(Settings.CUSTOM_CONFIGS[config]);
|
132 |
+
}
|
133 |
+
}
|
134 |
+
if (isValueEncrypted(configString)) {
|
135 |
+
logger.info(`Encrypted config detected, encrypting credentials`);
|
136 |
+
configJson = encryptInfoInConfig(configJson);
|
137 |
+
}
|
138 |
+
const base64Config = Buffer.from(JSON.stringify(configJson)).toString(
|
139 |
+
'base64'
|
140 |
+
);
|
141 |
+
res.redirect(`/${encodeURIComponent(base64Config)}/configure`);
|
142 |
+
} catch (error: any) {
|
143 |
+
logger.error(`Failed to extract config: ${error.message}`);
|
144 |
+
res.status(400).send('Invalid config');
|
145 |
+
}
|
146 |
+
});
|
147 |
+
|
148 |
+
app.get('/manifest.json', (req, res) => {
|
149 |
+
res.status(200).json(manifest());
|
150 |
+
});
|
151 |
+
|
152 |
+
app.get('/:config/manifest.json', (req, res) => {
|
153 |
+
const config = decodeURIComponent(req.params.config);
|
154 |
+
let configJson: Config;
|
155 |
+
try {
|
156 |
+
configJson = extractJsonConfig(config);
|
157 |
+
logger.info(`Extracted config for manifest request`);
|
158 |
+
configJson = decryptEncryptedInfoFromConfig(configJson);
|
159 |
+
if (Settings.LOG_SENSITIVE_INFO) {
|
160 |
+
logger.info(`Final config: ${JSON.stringify(configJson)}`);
|
161 |
+
}
|
162 |
+
logger.info(`Successfully removed or decrypted sensitive info`);
|
163 |
+
const { valid, errorMessage } = validateConfig(configJson);
|
164 |
+
if (!valid) {
|
165 |
+
logger.error(
|
166 |
+
`Received invalid config for manifest request: ${errorMessage}`
|
167 |
+
);
|
168 |
+
res.status(400).json({ error: 'Invalid config', message: errorMessage });
|
169 |
+
return;
|
170 |
+
}
|
171 |
+
} catch (error: any) {
|
172 |
+
logger.error(`Failed to extract config: ${error.message}`);
|
173 |
+
res.status(400).json({ error: 'Invalid config' });
|
174 |
+
return;
|
175 |
+
}
|
176 |
+
res.status(200).json(manifest(configJson));
|
177 |
+
});
|
178 |
+
|
179 |
+
// Route for /stream
|
180 |
+
app.get('/stream/:type/:id', (req: Request, res: Response) => {
|
181 |
+
res
|
182 |
+
.status(200)
|
183 |
+
.json(
|
184 |
+
errorResponse(
|
185 |
+
'You must configure this addon to use it',
|
186 |
+
rootUrl(req),
|
187 |
+
'/configure'
|
188 |
+
)
|
189 |
+
);
|
190 |
+
});
|
191 |
+
|
192 |
+
app.get('/:config/stream/:type/:id.json', (req, res: Response): void => {
|
193 |
+
const { config, type, id } = req.params;
|
194 |
+
let configJson: Config;
|
195 |
+
try {
|
196 |
+
configJson = extractJsonConfig(config);
|
197 |
+
logger.info(`Extracted config for stream request`);
|
198 |
+
configJson = decryptEncryptedInfoFromConfig(configJson);
|
199 |
+
if (Settings.LOG_SENSITIVE_INFO) {
|
200 |
+
logger.info(`Final config: ${JSON.stringify(configJson)}`);
|
201 |
+
}
|
202 |
+
logger.info(`Successfully removed or decrypted sensitive info`);
|
203 |
+
} catch (error: any) {
|
204 |
+
logger.error(`Failed to extract config: ${error.message}`);
|
205 |
+
res.json(
|
206 |
+
errorResponse(
|
207 |
+
`${error.message}, please check the logs or click this stream to create an issue on GitHub`,
|
208 |
+
rootUrl(req),
|
209 |
+
undefined,
|
210 |
+
'https://github.com/Viren070/AIOStreams/issues/new?template=bug_report.yml'
|
211 |
+
)
|
212 |
+
);
|
213 |
+
return;
|
214 |
+
}
|
215 |
+
|
216 |
+
logger.info(`Requesting streams for ${type} ${id}`);
|
217 |
+
|
218 |
+
if (type !== 'movie' && type !== 'series') {
|
219 |
+
logger.error(`Invalid type for stream request`);
|
220 |
+
res.json(
|
221 |
+
errorResponse(
|
222 |
+
'Invalid type for stream request, must be movie or series',
|
223 |
+
rootUrl(req),
|
224 |
+
'/'
|
225 |
+
)
|
226 |
+
);
|
227 |
+
return;
|
228 |
+
}
|
229 |
+
let streamRequest: StreamRequest = { id, type };
|
230 |
+
|
231 |
+
try {
|
232 |
+
const { valid, errorCode, errorMessage } = validateConfig(configJson);
|
233 |
+
if (!valid) {
|
234 |
+
logger.error(`Received invalid config: ${errorCode} - ${errorMessage}`);
|
235 |
+
res.json(
|
236 |
+
errorResponse(errorMessage ?? 'Unknown', rootUrl(req), '/configure')
|
237 |
+
);
|
238 |
+
return;
|
239 |
+
}
|
240 |
+
configJson.requestingIp = getIp(req);
|
241 |
+
const aioStreams = new AIOStreams(configJson);
|
242 |
+
aioStreams
|
243 |
+
.getStreams(streamRequest)
|
244 |
+
.then((streams) => {
|
245 |
+
res.json({ streams: streams });
|
246 |
+
})
|
247 |
+
.catch((error: any) => {
|
248 |
+
logger.error(`Internal addon error: ${error.message}`);
|
249 |
+
res.json(
|
250 |
+
errorResponse(
|
251 |
+
'An unexpected error occurred, please check the logs or create an issue on GitHub',
|
252 |
+
rootUrl(req),
|
253 |
+
undefined,
|
254 |
+
'https://github.com/Viren070/AIOStreams/issues/new?template=bug_report.yml'
|
255 |
+
)
|
256 |
+
);
|
257 |
+
});
|
258 |
+
} catch (error: any) {
|
259 |
+
logger.error(`Internal addon error: ${error.message}`);
|
260 |
+
res.json(
|
261 |
+
errorResponse(
|
262 |
+
'An unexpected error occurred, please check the logs or create an issue on GitHub',
|
263 |
+
rootUrl(req),
|
264 |
+
undefined,
|
265 |
+
'https://github.com/Viren070/AIOStreams/issues/new?template=bug_report.yml'
|
266 |
+
)
|
267 |
+
);
|
268 |
+
}
|
269 |
+
});
|
270 |
+
|
271 |
+
app.post('/encrypt-user-data', (req, res) => {
|
272 |
+
const { data } = req.body;
|
273 |
+
let finalString: string = '';
|
274 |
+
if (!data) {
|
275 |
+
logger.error('/encrypt-user-data: No data provided');
|
276 |
+
res.json({ success: false, message: 'No data provided' });
|
277 |
+
return;
|
278 |
+
}
|
279 |
+
// First, validate the config
|
280 |
+
try {
|
281 |
+
const config = JSON.parse(data);
|
282 |
+
const { valid, errorCode, errorMessage } = validateConfig(config);
|
283 |
+
if (!valid) {
|
284 |
+
logger.error(
|
285 |
+
`generateConfig: Invalid config: ${errorCode} - ${errorMessage}`
|
286 |
+
);
|
287 |
+
res.json({ success: false, message: errorMessage, error: errorMessage });
|
288 |
+
return;
|
289 |
+
}
|
290 |
+
} catch (error: any) {
|
291 |
+
logger.error(`/encrypt-user-data: Invalid JSON: ${error.message}`);
|
292 |
+
res.json({ success: false, message: 'Malformed configuration' });
|
293 |
+
return;
|
294 |
+
}
|
295 |
+
|
296 |
+
try {
|
297 |
+
const minified = minifyConfig(JSON.parse(data));
|
298 |
+
const crushed = crushJson(JSON.stringify(minified));
|
299 |
+
const compressed = compressData(crushed);
|
300 |
+
if (!Settings.SECRET_KEY) {
|
301 |
+
// use base64 encoding if no secret key is set
|
302 |
+
finalString = `B-${encodeURIComponent(compressed.toString('base64'))}`;
|
303 |
+
} else {
|
304 |
+
const { iv, data } = encryptData(compressed);
|
305 |
+
finalString = `E2-${encodeURIComponent(iv)}-${encodeURIComponent(data)}`;
|
306 |
+
}
|
307 |
+
|
308 |
+
logger.info(
|
309 |
+
`|INF| server > /encrypt-user-data: Encrypted user data, compression report:`
|
310 |
+
);
|
311 |
+
logger.info(`+--------------------------------------------+`);
|
312 |
+
logger.info(`| Original: ${data.length} bytes`);
|
313 |
+
logger.info(`| URL Encoded: ${encodeURIComponent(data).length} bytes`);
|
314 |
+
logger.info(`| Minified: ${JSON.stringify(minified).length} bytes`);
|
315 |
+
logger.info(`| Crushed: ${crushed.length} bytes`);
|
316 |
+
logger.info(`| Compressed: ${compressed.length} bytes`);
|
317 |
+
logger.info(`| Final String: ${finalString.length} bytes`);
|
318 |
+
logger.info(
|
319 |
+
`| Ratio: ${((finalString.length / data.length) * 100).toFixed(2)}%`
|
320 |
+
);
|
321 |
+
logger.info(
|
322 |
+
`| Reduction: ${data.length - finalString.length} bytes (${(((data.length - finalString.length) / data.length) * 100).toFixed(2)}%)`
|
323 |
+
);
|
324 |
+
logger.info(`+--------------------------------------------+`);
|
325 |
+
|
326 |
+
res.json({ success: true, data: finalString });
|
327 |
+
} catch (error: any) {
|
328 |
+
logger.error(`/encrypt-user-data: ${error.message}`);
|
329 |
+
logger.error(error);
|
330 |
+
res.json({ success: false, message: error.message });
|
331 |
+
}
|
332 |
+
});
|
333 |
+
|
334 |
+
app.get('/get-addon-config', (req, res) => {
|
335 |
+
res.status(200).json({
|
336 |
+
success: true,
|
337 |
+
maxMovieSize: Settings.MAX_MOVIE_SIZE,
|
338 |
+
maxEpisodeSize: Settings.MAX_EPISODE_SIZE,
|
339 |
+
torrentioDisabled: Settings.DISABLE_TORRENTIO,
|
340 |
+
apiKeyRequired: !!Settings.API_KEY,
|
341 |
+
});
|
342 |
+
});
|
343 |
+
|
344 |
+
app.get('/health', (req, res) => {
|
345 |
+
res.status(200).json({ status: 'ok' });
|
346 |
+
});
|
347 |
+
|
348 |
+
// define 404
|
349 |
+
app.use((req, res) => {
|
350 |
+
res.status(404).sendFile(path.join(__dirname, '../../frontend/out/404.html'));
|
351 |
+
});
|
352 |
+
|
353 |
+
app.listen(Settings.PORT, () => {
|
354 |
+
logger.info(`Listening on port ${Settings.PORT}`);
|
355 |
+
});
|
356 |
+
|
357 |
+
function getIp(req: Request): string | undefined {
|
358 |
+
return (
|
359 |
+
req.get('X-Client-IP') ||
|
360 |
+
req.get('X-Forwarded-For')?.split(',')[0].trim() ||
|
361 |
+
req.get('X-Real-IP') ||
|
362 |
+
req.get('CF-Connecting-IP') ||
|
363 |
+
req.get('True-Client-IP') ||
|
364 |
+
req.get('X-Forwarded')?.split(',')[0].trim() ||
|
365 |
+
req.get('Forwarded-For')?.split(',')[0].trim() ||
|
366 |
+
req.ip
|
367 |
+
);
|
368 |
+
}
|
369 |
+
function extractJsonConfig(config: string): Config {
|
370 |
+
if (
|
371 |
+
config.startsWith('eyJ') ||
|
372 |
+
config.startsWith('eyI') ||
|
373 |
+
config.startsWith('B-') ||
|
374 |
+
isValueEncrypted(config)
|
375 |
+
) {
|
376 |
+
return extractEncryptedOrEncodedConfig(config, 'Config');
|
377 |
+
}
|
378 |
+
if (Settings.CUSTOM_CONFIGS) {
|
379 |
+
const customConfig = extractCustomConfig(config);
|
380 |
+
if (customConfig) return customConfig;
|
381 |
+
}
|
382 |
+
throw new Error('Config was in an unexpected format');
|
383 |
+
}
|
384 |
+
|
385 |
+
function extractCustomConfig(config: string): Config | undefined {
|
386 |
+
const customConfig = Settings.CUSTOM_CONFIGS[config];
|
387 |
+
if (!customConfig) return undefined;
|
388 |
+
logger.info(
|
389 |
+
`Found custom config for alias ${config}, attempting to extract config`
|
390 |
+
);
|
391 |
+
return extractEncryptedOrEncodedConfig(
|
392 |
+
decodeURIComponent(customConfig),
|
393 |
+
`CustomConfig ${config}`
|
394 |
+
);
|
395 |
+
}
|
396 |
+
|
397 |
+
function extractEncryptedOrEncodedConfig(
|
398 |
+
config: string,
|
399 |
+
label: string
|
400 |
+
): Config {
|
401 |
+
let decodedConfig: Config;
|
402 |
+
try {
|
403 |
+
if (config.startsWith('E-')) {
|
404 |
+
// compressed and encrypted (hex)
|
405 |
+
logger.info(`Extracting encrypted (v1) config`);
|
406 |
+
const parts = config.split('-');
|
407 |
+
if (parts.length !== 3) {
|
408 |
+
throw new Error('Invalid encrypted config format');
|
409 |
+
}
|
410 |
+
const iv = Buffer.from(decodeURIComponent(parts[1]), 'hex');
|
411 |
+
const data = Buffer.from(decodeURIComponent(parts[2]), 'hex');
|
412 |
+
decodedConfig = JSON.parse(decompressData(decryptData(data, iv)));
|
413 |
+
} else if (config.startsWith('E2-')) {
|
414 |
+
// minified, crushed, compressed and encrypted (base64)
|
415 |
+
logger.info(`Extracting encrypted (v2) config`);
|
416 |
+
const parts = config.split('-');
|
417 |
+
if (parts.length !== 3) {
|
418 |
+
throw new Error('Invalid encrypted config format');
|
419 |
+
}
|
420 |
+
const iv = Buffer.from(decodeURIComponent(parts[1]), 'base64');
|
421 |
+
const data = Buffer.from(decodeURIComponent(parts[2]), 'base64');
|
422 |
+
const compressedCrushedJson = decryptData(data, iv);
|
423 |
+
const crushedJson = decompressData(compressedCrushedJson);
|
424 |
+
const minifiedConfig = uncrushJson(crushedJson);
|
425 |
+
decodedConfig = unminifyConfig(JSON.parse(minifiedConfig));
|
426 |
+
} else if (config.startsWith('B-')) {
|
427 |
+
// minifed, crushed, compressed, base64 encoded
|
428 |
+
logger.info(`Extracting base64 encoded and compressed config`);
|
429 |
+
decodedConfig = unminifyConfig(
|
430 |
+
JSON.parse(
|
431 |
+
uncrushJson(decompressData(Buffer.from(config.slice(2), 'base64')))
|
432 |
+
)
|
433 |
+
);
|
434 |
+
} else {
|
435 |
+
// plain base64 encoded
|
436 |
+
logger.info(`Extracting plain base64 encoded config`);
|
437 |
+
decodedConfig = JSON.parse(
|
438 |
+
Buffer.from(config, 'base64').toString('utf-8')
|
439 |
+
);
|
440 |
+
}
|
441 |
+
return decodedConfig;
|
442 |
+
} catch (error: any) {
|
443 |
+
logger.error(`Failed to parse ${label}: ${error.message}`, {
|
444 |
+
func: 'extractJsonConfig',
|
445 |
+
});
|
446 |
+
logger.error(error, { func: 'extractJsonConfig' });
|
447 |
+
throw new Error(`Failed to parse ${label}`);
|
448 |
+
}
|
449 |
+
}
|
450 |
+
|
451 |
+
function decryptEncryptedInfoFromConfig(config: Config): Config {
|
452 |
+
if (config.services) {
|
453 |
+
config.services.forEach(
|
454 |
+
(service) =>
|
455 |
+
service.credentials &&
|
456 |
+
processObjectValues(
|
457 |
+
service.credentials,
|
458 |
+
`service ${service.id}`,
|
459 |
+
true,
|
460 |
+
(key, value) => isValueEncrypted(value)
|
461 |
+
)
|
462 |
+
);
|
463 |
+
}
|
464 |
+
|
465 |
+
if (config.mediaFlowConfig) {
|
466 |
+
decryptMediaFlowConfig(config.mediaFlowConfig);
|
467 |
+
}
|
468 |
+
if (config.stremThruConfig) {
|
469 |
+
decryptStremThruConfig(config.stremThruConfig);
|
470 |
+
}
|
471 |
+
|
472 |
+
if (config.apiKey) {
|
473 |
+
config.apiKey = decryptValue(config.apiKey, 'aioStreams apiKey');
|
474 |
+
}
|
475 |
+
|
476 |
+
if (config.addons) {
|
477 |
+
config.addons.forEach((addon) => {
|
478 |
+
if (addon.options) {
|
479 |
+
processObjectValues(
|
480 |
+
addon.options,
|
481 |
+
`addon ${addon.id}`,
|
482 |
+
true,
|
483 |
+
(key, value) =>
|
484 |
+
isValueEncrypted(value) &&
|
485 |
+
// Decrypt only if the option is secret
|
486 |
+
(
|
487 |
+
addonDetails.find((addonDetail) => addonDetail.id === addon.id)
|
488 |
+
?.options ?? []
|
489 |
+
).some((option) => option.id === key && option.secret)
|
490 |
+
);
|
491 |
+
}
|
492 |
+
});
|
493 |
+
}
|
494 |
+
return config;
|
495 |
+
}
|
496 |
+
|
497 |
+
function decryptMediaFlowConfig(mediaFlowConfig: {
|
498 |
+
apiPassword: string;
|
499 |
+
proxyUrl: string;
|
500 |
+
publicIp: string;
|
501 |
+
}): void {
|
502 |
+
const { apiPassword, proxyUrl, publicIp } = mediaFlowConfig;
|
503 |
+
mediaFlowConfig.apiPassword = decryptValue(
|
504 |
+
apiPassword,
|
505 |
+
'MediaFlow apiPassword'
|
506 |
+
);
|
507 |
+
mediaFlowConfig.proxyUrl = decryptValue(proxyUrl, 'MediaFlow proxyUrl');
|
508 |
+
mediaFlowConfig.publicIp = decryptValue(publicIp, 'MediaFlow publicIp');
|
509 |
+
}
|
510 |
+
|
511 |
+
function decryptStremThruConfig(
|
512 |
+
stremThruConfig: Config['stremThruConfig']
|
513 |
+
): void {
|
514 |
+
if (!stremThruConfig) return;
|
515 |
+
const { url, credential, publicIp } = stremThruConfig;
|
516 |
+
stremThruConfig.url = decryptValue(url, 'StremThru url');
|
517 |
+
stremThruConfig.credential = decryptValue(credential, 'StremThru credential');
|
518 |
+
stremThruConfig.publicIp = decryptValue(publicIp, 'StremThru publicIp');
|
519 |
+
}
|
520 |
+
|
521 |
+
function encryptInfoInConfig(config: Config): Config {
|
522 |
+
if (config.services) {
|
523 |
+
config.services.forEach(
|
524 |
+
(service) =>
|
525 |
+
service.credentials &&
|
526 |
+
processObjectValues(
|
527 |
+
service.credentials,
|
528 |
+
`service ${service.id}`,
|
529 |
+
false,
|
530 |
+
() => true
|
531 |
+
)
|
532 |
+
);
|
533 |
+
}
|
534 |
+
|
535 |
+
if (config.mediaFlowConfig) {
|
536 |
+
encryptMediaFlowConfig(config.mediaFlowConfig);
|
537 |
+
}
|
538 |
+
|
539 |
+
if (config.stremThruConfig) {
|
540 |
+
encryptStremThruConfig(config.stremThruConfig);
|
541 |
+
}
|
542 |
+
|
543 |
+
if (config.apiKey) {
|
544 |
+
// we can either remove the api key for better security or encrypt it for usability
|
545 |
+
// removing it means the user has to enter it every time upon reconfiguration.
|
546 |
+
config.apiKey = encryptValue(config.apiKey, 'aioStreams apiKey');
|
547 |
+
}
|
548 |
+
|
549 |
+
if (config.addons) {
|
550 |
+
config.addons.forEach((addon) => {
|
551 |
+
if (addon.options) {
|
552 |
+
processObjectValues(
|
553 |
+
addon.options,
|
554 |
+
`addon ${addon.id}`,
|
555 |
+
false,
|
556 |
+
(key) => {
|
557 |
+
const addonDetail = addonDetails.find(
|
558 |
+
(addonDetail) => addonDetail.id === addon.id
|
559 |
+
);
|
560 |
+
if (!addonDetail) return false;
|
561 |
+
const optionDetail = addonDetail.options?.find(
|
562 |
+
(option) => option.id === key
|
563 |
+
);
|
564 |
+
// Encrypt only if the option is secret
|
565 |
+
return optionDetail?.secret ?? false;
|
566 |
+
}
|
567 |
+
);
|
568 |
+
}
|
569 |
+
});
|
570 |
+
}
|
571 |
+
return config;
|
572 |
+
}
|
573 |
+
|
574 |
+
function encryptMediaFlowConfig(mediaFlowConfig: {
|
575 |
+
apiPassword: string;
|
576 |
+
proxyUrl: string;
|
577 |
+
publicIp: string;
|
578 |
+
}): void {
|
579 |
+
const { apiPassword, proxyUrl, publicIp } = mediaFlowConfig;
|
580 |
+
mediaFlowConfig.apiPassword = encryptValue(
|
581 |
+
apiPassword,
|
582 |
+
'MediaFlow apiPassword'
|
583 |
+
);
|
584 |
+
mediaFlowConfig.proxyUrl = encryptValue(proxyUrl, 'MediaFlow proxyUrl');
|
585 |
+
mediaFlowConfig.publicIp = encryptValue(publicIp, 'MediaFlow publicIp');
|
586 |
+
}
|
587 |
+
|
588 |
+
function encryptStremThruConfig(
|
589 |
+
stremThruConfig: Config['stremThruConfig']
|
590 |
+
): void {
|
591 |
+
if (!stremThruConfig) return;
|
592 |
+
const { url, credential, publicIp } = stremThruConfig;
|
593 |
+
stremThruConfig.url = encryptValue(url, 'StremThru url');
|
594 |
+
stremThruConfig.credential = encryptValue(credential, 'StremThru credential');
|
595 |
+
stremThruConfig.publicIp = encryptValue(publicIp, 'StremThru publicIp');
|
596 |
+
}
|
597 |
+
|
598 |
+
function processObjectValues(
|
599 |
+
obj: Record<string, any>,
|
600 |
+
labelPrefix: string,
|
601 |
+
decrypt: boolean,
|
602 |
+
condition: (key: string, value: any) => boolean
|
603 |
+
): void {
|
604 |
+
Object.keys(obj).forEach((key) => {
|
605 |
+
const value = obj[key];
|
606 |
+
if (condition(key, value)) {
|
607 |
+
logger.debug(`Processing ${labelPrefix} ${key}`);
|
608 |
+
obj[key] = decrypt
|
609 |
+
? decryptValue(value, `${labelPrefix} ${key}`)
|
610 |
+
: encryptValue(value, `${labelPrefix} ${key}`);
|
611 |
+
}
|
612 |
+
});
|
613 |
+
}
|
614 |
+
|
615 |
+
function encryptValue(value: any, label: string): any {
|
616 |
+
if (value && !isValueEncrypted(value)) {
|
617 |
+
try {
|
618 |
+
const { iv, data } = encryptData(compressData(value));
|
619 |
+
return `E2-${iv}-${data}`;
|
620 |
+
} catch (error: any) {
|
621 |
+
logger.error(`Failed to encrypt ${label}`, { func: 'encryptValue' });
|
622 |
+
logger.error(error, { func: 'encryptValue' });
|
623 |
+
return '';
|
624 |
+
}
|
625 |
+
}
|
626 |
+
return value;
|
627 |
+
}
|
628 |
+
|
629 |
+
function decryptValue(value: any, label: string): any {
|
630 |
+
try {
|
631 |
+
if (!isValueEncrypted(value)) return value;
|
632 |
+
const decrypted = parseAndDecryptString(value);
|
633 |
+
if (decrypted === null) throw new Error('Decryption failed');
|
634 |
+
return decrypted;
|
635 |
+
} catch (error: any) {
|
636 |
+
logger.error(`Failed to decrypt ${label}: ${error.message}`, {
|
637 |
+
func: 'decryptValue',
|
638 |
+
});
|
639 |
+
logger.error(error, { func: 'decryptValue' });
|
640 |
+
throw new Error('Failed to decrypt config');
|
641 |
+
}
|
642 |
+
}
|
643 |
+
|
644 |
+
const rootUrl = (req: Request) =>
|
645 |
+
`${req.protocol}://${req.hostname}${req.hostname === 'localhost' ? `:${Settings.PORT}` : ''}`;
|
packages/addon/tsconfig.json
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"extends": "../../tsconfig.base.json",
|
3 |
+
"compilerOptions": {
|
4 |
+
"rootDir": "src",
|
5 |
+
"outDir": "dist",
|
6 |
+
"resolveJsonModule": true
|
7 |
+
},
|
8 |
+
"references": [
|
9 |
+
{
|
10 |
+
"path": "../wrappers"
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"path": "../formatters"
|
14 |
+
},
|
15 |
+
{
|
16 |
+
"path": "../types"
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"path": "../utils"
|
20 |
+
}
|
21 |
+
]
|
22 |
+
}
|
packages/cloudflare-loadbalancer/COMPARISON.md
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AIOStreams Load Balancing: Cloudflare Worker vs. NGINX
|
2 |
+
|
3 |
+
This document compares the two load balancing approaches used for AIOStreams:
|
4 |
+
|
5 |
+
1. **NGINX Load Balancer** (configured in `nginx.conf`)
|
6 |
+
2. **Cloudflare Worker Load Balancer** (in `packages/cloudflare-loadbalancer`)
|
7 |
+
|
8 |
+
## Deployment Models
|
9 |
+
|
10 |
+
### NGINX Approach
|
11 |
+
|
12 |
+
- **Self-hosted**: Requires a dedicated server running NGINX.
|
13 |
+
- **Single Point of Failure**: The NGINX server itself becomes a potential point of failure.
|
14 |
+
- **Traditional HTTP Proxy**: Uses L7 (HTTP) load balancing.
|
15 |
+
- **SSL Termination**: Handles HTTPS connections directly with certificates stored on the server.
|
16 |
+
|
17 |
+
### Cloudflare Worker Approach
|
18 |
+
|
19 |
+
- **Serverless**: No dedicated infrastructure required.
|
20 |
+
- **Globally Distributed**: Runs on Cloudflare's edge network in 300+ locations worldwide.
|
21 |
+
- **High Availability**: No single point of failure in the load balancer itself.
|
22 |
+
- **Zero Maintenance**: No server patching, scaling, or management required.
|
23 |
+
|
24 |
+
## Feature Comparison
|
25 |
+
|
26 |
+
| Feature | NGINX | Cloudflare Worker |
|
27 |
+
| --------------------- | ------------------------ | -------------------------- |
|
28 |
+
| Load Balancing | ✅ (ip_hash) | ✅ (client IP hash) |
|
29 |
+
| Health Checks | ✅ (passive only) | ✅ (passive only) |
|
30 |
+
| Failover | ✅ | ✅ |
|
31 |
+
| WebSocket Support | ✅ | ✅ |
|
32 |
+
| Session Affinity | ✅ (ip_hash) | ✅ (cookies) |
|
33 |
+
| HTTP→HTTPS Redirect | ✅ | ✅ |
|
34 |
+
| Global Distribution | ❌ | ✅ |
|
35 |
+
| SSL Management | Manual | Automatic (via Cloudflare) |
|
36 |
+
| DDoS Protection | Limited | ✅ (via Cloudflare) |
|
37 |
+
| Deployment Complexity | Higher | Lower |
|
38 |
+
| Operational Costs | Server + bandwidth costs | Cloudflare Workers pricing |
|
39 |
+
|
40 |
+
## When to Use Each Approach
|
41 |
+
|
42 |
+
### Use the NGINX Approach When:
|
43 |
+
|
44 |
+
- You need complete control over the load balancing infrastructure.
|
45 |
+
- You want to avoid any third-party dependencies.
|
46 |
+
- You already have servers running in a datacenter with NGINX expertise.
|
47 |
+
- You need advanced customization of HTTP headers, rewriting rules, etc.
|
48 |
+
|
49 |
+
### Use the Cloudflare Worker Approach When:
|
50 |
+
|
51 |
+
- You want global low-latency access without managing infrastructure.
|
52 |
+
- You prefer a serverless, maintenance-free deployment.
|
53 |
+
- You need built-in DDoS protection and security features.
|
54 |
+
- You want to minimize operational complexity and management.
|
55 |
+
|
56 |
+
## Hybrid Approach
|
57 |
+
|
58 |
+
You can also use both approaches together:
|
59 |
+
|
60 |
+
1. **Primary Traffic**: Route through the Cloudflare Worker for global distribution and DDoS protection.
|
61 |
+
2. **Fallback**: If Cloudflare has issues, DNS can be updated to point directly to your NGINX load balancer.
|
62 |
+
|
63 |
+
This gives you the benefits of Cloudflare's global network while maintaining the ability to operate independently if needed.
|
64 |
+
|
65 |
+
## Conclusion
|
66 |
+
|
67 |
+
Both approaches effectively solve the load balancing needs of AIOStreams, but with different operational models. The Cloudflare Worker provides a modern, serverless approach with global distribution, while the NGINX configuration offers traditional self-hosted load balancing with maximum control.
|
packages/cloudflare-loadbalancer/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AIOStreams Cloudflare Load Balancer
|
2 |
+
|
3 |
+
A Cloudflare Worker that load balances traffic across multiple AIOStreams backends, providing high availability and redundancy.
|
4 |
+
|
5 |
+
## Features
|
6 |
+
|
7 |
+
- **Load Balancing**: Routes traffic among three backend services:
|
8 |
+
- `aiostreams-cf.example.com`
|
9 |
+
- `aiostreams-koyeb.example.com`
|
10 |
+
- `aiostreams.example.duckdns.org`
|
11 |
+
|
12 |
+
- **Sticky Sessions**: Maintains session affinity using cookies, ensuring users stay on the same backend throughout their session.
|
13 |
+
|
14 |
+
- **Health Checking**: Automatically detects backend failures and routes traffic away from unhealthy instances.
|
15 |
+
|
16 |
+
- **Automatic Failover**: If a backend is unresponsive or returns 5xx errors, requests are retried with another backend.
|
17 |
+
|
18 |
+
- **Consistent Hashing**: Uses client IP for consistent backend selection when no sticky session exists.
|
19 |
+
|
20 |
+
- **WebSocket Support**: Properly handles WebSocket connections, maintaining the upgrade flow.
|
21 |
+
|
22 |
+
- **HTTP-to-HTTPS Redirection**: Automatically redirects HTTP requests to HTTPS.
|
23 |
+
|
24 |
+
- **Header Preservation**: Maintains all request headers and adds proper proxy headers for backends.
|
25 |
+
|
26 |
+
## Configuration
|
27 |
+
|
28 |
+
The worker is configured via environment variables in `wrangler.toml`:
|
29 |
+
|
30 |
+
| Variable | Description |
|
31 |
+
| --------------------- | ------------------------------------------------------------------ |
|
32 |
+
| `PRIMARY_DOMAIN` | Domain name this worker is handling (e.g., aiostreams.example.com) |
|
33 |
+
| `BACKEND_CF` | Hostname for Cloudflare backend |
|
34 |
+
| `BACKEND_KOYEB` | Hostname for Koyeb backend |
|
35 |
+
| `BACKEND_DUCK` | Hostname for DuckDNS backend |
|
36 |
+
| `STICKY_SESSIONS` | Enable/disable sticky sessions (true/false) |
|
37 |
+
| `SESSION_COOKIE_NAME` | Cookie name for session stickiness |
|
38 |
+
| `SESSION_COOKIE_TTL` | Session cookie time-to-live in seconds (default: 86400) |
|
39 |
+
| `BACKEND_DOWN_TIME` | How long to mark a backend as down after a failure (ms) |
|
40 |
+
| `MAX_RETRIES` | Maximum number of retry attempts |
|
41 |
+
|
42 |
+
## Deployment
|
43 |
+
|
44 |
+
Deploy the worker to Cloudflare:
|
45 |
+
|
46 |
+
```bash
|
47 |
+
cd packages/cloudflare-loadbalancer
|
48 |
+
npm install
|
49 |
+
npm run deploy
|
50 |
+
```
|
51 |
+
|
52 |
+
## How It Works
|
53 |
+
|
54 |
+
1. When a request arrives at the worker (configured for the domain in `PRIMARY_DOMAIN`), the worker chooses a backend based on:
|
55 |
+
- Existing session cookie (if sticky sessions enabled)
|
56 |
+
- Client IP hash (for consistent backend selection)
|
57 |
+
- Backend health status
|
58 |
+
|
59 |
+
2. The worker forwards the request to the selected backend, preserving all headers, query parameters, and request body.
|
60 |
+
|
61 |
+
3. If the backend fails or returns a 5xx error, the worker retries with another backend.
|
62 |
+
|
63 |
+
4. For sticky sessions, the worker sets a cookie to ensure subsequent requests from the same client go to the same backend.
|
64 |
+
|
65 |
+
## Fault Tolerance
|
66 |
+
|
67 |
+
- The worker maintains a temporary in-memory health status for each backend.
|
68 |
+
- Failed backends are marked as "down" for a configurable period.
|
69 |
+
- If all backends are down, the worker will reset all health statuses and try again.
|
70 |
+
- A maximum retry count prevents excessive attempts when all backends are failing.
|
packages/cloudflare-loadbalancer/deploy.sh
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
# AIOStreams Cloudflare Load Balancer Deployment Script
|
4 |
+
|
5 |
+
echo "=== AIOStreams Cloudflare Load Balancer Deployment ==="
|
6 |
+
echo "Installing dependencies..."
|
7 |
+
npm install
|
8 |
+
|
9 |
+
echo "Building and deploying worker..."
|
10 |
+
npx wrangler deploy
|
11 |
+
|
12 |
+
echo "=== Deployment Complete ==="
|
13 |
+
echo "Your load balancer is now deployed to Cloudflare."
|
14 |
+
echo "Make sure to set up appropriate DNS records pointing aiostreams.example.com to your worker."
|
15 |
+
echo ""
|
16 |
+
echo "Test your deployment with:"
|
17 |
+
echo "curl -I https://aiostreams.example.com"
|
packages/cloudflare-loadbalancer/package.json
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@aiostreams/cloudflare-loadbalancer",
|
3 |
+
"version": "1.0.0",
|
4 |
+
"description": "Cloudflare Worker that routes traffic between multiple AIOStreams backends",
|
5 |
+
"scripts": {
|
6 |
+
"deploy": "wrangler deploy",
|
7 |
+
"dev": "wrangler dev",
|
8 |
+
"start": "wrangler dev",
|
9 |
+
"test": "vitest",
|
10 |
+
"cf-typegen": "wrangler types"
|
11 |
+
},
|
12 |
+
"dependencies": {},
|
13 |
+
"devDependencies": {
|
14 |
+
"@cloudflare/workers-types": "^4.20241224.0",
|
15 |
+
"esbuild": "^0.25.5",
|
16 |
+
"typescript": "^5.5.2",
|
17 |
+
"wrangler": "^4.18.0"
|
18 |
+
}
|
19 |
+
}
|
packages/cloudflare-loadbalancer/src/index.ts
ADDED
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export interface Env {
|
2 |
+
// Environment variables
|
3 |
+
BACKEND_CF: string;
|
4 |
+
BACKEND_KOYEB: string;
|
5 |
+
BACKEND_DUCK: string;
|
6 |
+
STICKY_SESSIONS: boolean;
|
7 |
+
SESSION_COOKIE_NAME: string;
|
8 |
+
BACKEND_DOWN_TIME: string;
|
9 |
+
MAX_RETRIES: string;
|
10 |
+
// Optional duration for sticky session cookie in seconds (default: 1 day)
|
11 |
+
SESSION_COOKIE_TTL?: string;
|
12 |
+
// Primary domain that the worker is handling
|
13 |
+
PRIMARY_DOMAIN: string;
|
14 |
+
}
|
15 |
+
|
16 |
+
// Store for tracking backend health status
|
17 |
+
interface HealthStatus {
|
18 |
+
isDown: boolean;
|
19 |
+
lastFailure: number;
|
20 |
+
}
|
21 |
+
|
22 |
+
// Health status for each backend
|
23 |
+
const backendHealth = new Map<string, HealthStatus>();
|
24 |
+
|
25 |
+
// Helper function to choose a backend
|
26 |
+
function chooseBackend(request: Request, env: Env): string {
|
27 |
+
const backendOptions = [
|
28 |
+
env.BACKEND_CF,
|
29 |
+
env.BACKEND_KOYEB,
|
30 |
+
env.BACKEND_DUCK
|
31 |
+
];
|
32 |
+
|
33 |
+
// Filter out any backends that are marked as down
|
34 |
+
const availableBackends = backendOptions.filter(backend => {
|
35 |
+
const health = backendHealth.get(backend);
|
36 |
+
if (!health) return true;
|
37 |
+
|
38 |
+
if (health.isDown) {
|
39 |
+
// Check if the backend has been down long enough to retry
|
40 |
+
const downTime = parseInt(env.BACKEND_DOWN_TIME) || 30000;
|
41 |
+
if (Date.now() - health.lastFailure > downTime) {
|
42 |
+
// Reset the backend status
|
43 |
+
backendHealth.set(backend, { isDown: false, lastFailure: 0 });
|
44 |
+
return true;
|
45 |
+
}
|
46 |
+
return false;
|
47 |
+
}
|
48 |
+
|
49 |
+
return true;
|
50 |
+
});
|
51 |
+
|
52 |
+
// If no backends are available, reset all backends and try again
|
53 |
+
if (availableBackends.length === 0) {
|
54 |
+
backendOptions.forEach(backend => {
|
55 |
+
backendHealth.set(backend, { isDown: false, lastFailure: 0 });
|
56 |
+
});
|
57 |
+
return backendOptions[0];
|
58 |
+
}
|
59 |
+
|
60 |
+
// Check for sticky session cookie if enabled
|
61 |
+
if (env.STICKY_SESSIONS) {
|
62 |
+
const cookies = request.headers.get('Cookie') || '';
|
63 |
+
const cookieRegex = new RegExp(`${env.SESSION_COOKIE_NAME}=([^;]+)`);
|
64 |
+
const match = cookies.match(cookieRegex);
|
65 |
+
|
66 |
+
if (match && match[1]) {
|
67 |
+
const preferredBackend = match[1];
|
68 |
+
// Check if the preferred backend is available
|
69 |
+
if (availableBackends.includes(preferredBackend)) {
|
70 |
+
return preferredBackend;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
// Use client IP for consistent hashing if no cookie or preferred backend is down
|
76 |
+
const clientIP = request.headers.get('CF-Connecting-IP') ||
|
77 |
+
request.headers.get('X-Real-IP') ||
|
78 |
+
request.headers.get('X-Forwarded-For')?.split(',')[0].trim() ||
|
79 |
+
'unknown';
|
80 |
+
|
81 |
+
// Simple hash function for the client IP
|
82 |
+
const hashCode = (str: string) => {
|
83 |
+
let hash = 0;
|
84 |
+
for (let i = 0; i < str.length; i++) {
|
85 |
+
const char = str.charCodeAt(i);
|
86 |
+
hash = ((hash << 5) - hash) + char;
|
87 |
+
hash = hash & hash; // Convert to 32bit integer
|
88 |
+
}
|
89 |
+
return Math.abs(hash);
|
90 |
+
};
|
91 |
+
|
92 |
+
const index = hashCode(clientIP) % availableBackends.length;
|
93 |
+
return availableBackends[index];
|
94 |
+
}
|
95 |
+
|
96 |
+
// Mark a backend as down
|
97 |
+
function markBackendDown(backend: string, env: Env): void {
|
98 |
+
backendHealth.set(backend, {
|
99 |
+
isDown: true,
|
100 |
+
lastFailure: Date.now()
|
101 |
+
});
|
102 |
+
|
103 |
+
console.error(`Backend ${backend} marked as down at ${new Date().toISOString()}`);
|
104 |
+
}
|
105 |
+
|
106 |
+
// Clone request with new URL
|
107 |
+
function createBackendRequest(request: Request, backend: string): Request {
|
108 |
+
const url = new URL(request.url);
|
109 |
+
const backendUrl = new URL(`https://${backend}`);
|
110 |
+
|
111 |
+
// Preserve path and query parameters
|
112 |
+
backendUrl.pathname = url.pathname;
|
113 |
+
backendUrl.search = url.search;
|
114 |
+
|
115 |
+
// Get original headers and create a new headers object
|
116 |
+
const headers = new Headers(request.headers);
|
117 |
+
|
118 |
+
// Set the host header to the backend hostname
|
119 |
+
headers.set('Host', backend);
|
120 |
+
|
121 |
+
// Add proxy headers
|
122 |
+
headers.set('X-Forwarded-Host', url.hostname);
|
123 |
+
headers.set('X-Forwarded-Proto', url.protocol.replace(':', ''));
|
124 |
+
|
125 |
+
// Check if we need to handle WebSockets
|
126 |
+
const upgradeHeader = request.headers.get('Upgrade');
|
127 |
+
const isWebSocket = upgradeHeader !== null && upgradeHeader.toLowerCase() === 'websocket';
|
128 |
+
|
129 |
+
// Clone the request with the new URL
|
130 |
+
const newRequest = new Request(backendUrl.toString(), {
|
131 |
+
method: request.method,
|
132 |
+
headers: headers,
|
133 |
+
body: request.body,
|
134 |
+
redirect: 'manual', // Don't follow redirects automatically
|
135 |
+
// If this is a WebSocket request, we need to preserve the upgrade header
|
136 |
+
duplex: isWebSocket ? 'half' : undefined
|
137 |
+
});
|
138 |
+
|
139 |
+
return newRequest;
|
140 |
+
}
|
141 |
+
|
142 |
+
// Determine if we're in a development environment
|
143 |
+
function isDevelopment(): boolean {
|
144 |
+
try {
|
145 |
+
// Check if we're in a browser-like environment with location object
|
146 |
+
// @ts-ignore - Cloudflare Workers have location in dev/preview but not in TypeScript defs
|
147 |
+
return typeof globalThis.location === 'object' &&
|
148 |
+
// @ts-ignore
|
149 |
+
(globalThis.location.hostname === 'localhost' ||
|
150 |
+
// @ts-ignore
|
151 |
+
globalThis.location.hostname.includes('workers.dev') ||
|
152 |
+
// @ts-ignore
|
153 |
+
globalThis.location.hostname.includes('preview'));
|
154 |
+
} catch (e) {
|
155 |
+
return false;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
export default {
|
160 |
+
async fetch(request: Request, env: Env, ctx: any): Promise<Response> {
|
161 |
+
const url = new URL(request.url);
|
162 |
+
const isDevEnvironment = isDevelopment();
|
163 |
+
|
164 |
+
// In production, only handle requests for the PRIMARY_DOMAIN
|
165 |
+
// In development, handle all requests (to make testing easier)
|
166 |
+
if (!isDevEnvironment && url.hostname !== env.PRIMARY_DOMAIN) {
|
167 |
+
console.log(`Request for ${url.hostname} rejected (expected ${env.PRIMARY_DOMAIN})`);
|
168 |
+
return new Response(`This worker is configured to handle requests for ${env.PRIMARY_DOMAIN} only`, {
|
169 |
+
status: 404,
|
170 |
+
headers: { 'Content-Type': 'text/plain' }
|
171 |
+
});
|
172 |
+
}
|
173 |
+
|
174 |
+
// Redirect HTTP to HTTPS in production
|
175 |
+
if (!isDevEnvironment && url.protocol === 'http:') {
|
176 |
+
url.protocol = 'https:';
|
177 |
+
return Response.redirect(url.toString(), 301);
|
178 |
+
}
|
179 |
+
|
180 |
+
// Check for WebSocket upgrade
|
181 |
+
const upgradeHeader = request.headers.get('Upgrade');
|
182 |
+
const isWebSocket = upgradeHeader !== null && upgradeHeader.toLowerCase() === 'websocket';
|
183 |
+
|
184 |
+
// Try each backend until success or we run out of retries
|
185 |
+
let backend = chooseBackend(request, env);
|
186 |
+
let attempts = 0;
|
187 |
+
const maxRetries = parseInt(env.MAX_RETRIES) || 3;
|
188 |
+
|
189 |
+
// For WebSockets, we only try once per backend to avoid connection issues
|
190 |
+
const effectiveMaxRetries = isWebSocket ? Math.min(maxRetries, 1) : maxRetries;
|
191 |
+
|
192 |
+
console.log(`Routing request to ${backend} (attempt 1/${effectiveMaxRetries})`);
|
193 |
+
|
194 |
+
while (attempts < effectiveMaxRetries) {
|
195 |
+
attempts++;
|
196 |
+
|
197 |
+
try {
|
198 |
+
// Create a new request for the backend
|
199 |
+
const backendRequest = createBackendRequest(request, backend);
|
200 |
+
|
201 |
+
// Forward the request to the backend
|
202 |
+
const response = await fetch(backendRequest);
|
203 |
+
|
204 |
+
// If the response is a server error (5xx), mark the backend as down and try another
|
205 |
+
if (response.status >= 500 && response.status < 600) {
|
206 |
+
console.error(`Backend ${backend} returned ${response.status}`);
|
207 |
+
markBackendDown(backend, env);
|
208 |
+
|
209 |
+
// Choose a different backend for the next attempt
|
210 |
+
if (attempts < effectiveMaxRetries) {
|
211 |
+
backend = chooseBackend(request, env);
|
212 |
+
console.log(`Retrying with ${backend} (attempt ${attempts + 1}/${effectiveMaxRetries})`);
|
213 |
+
continue;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
// Clone the response so we can modify headers
|
218 |
+
const clonedResponse = new Response(response.body, response);
|
219 |
+
|
220 |
+
// If sticky sessions are enabled, set a cookie with the backend
|
221 |
+
if (env.STICKY_SESSIONS) {
|
222 |
+
// Calculate cookie expiration
|
223 |
+
const ttl = parseInt(env.SESSION_COOKIE_TTL || '86400'); // Default to 1 day
|
224 |
+
const expires = new Date();
|
225 |
+
expires.setSeconds(expires.getSeconds() + ttl);
|
226 |
+
|
227 |
+
clonedResponse.headers.append('Set-Cookie',
|
228 |
+
`${env.SESSION_COOKIE_NAME}=${backend}; Path=/; HttpOnly; SameSite=Lax; Expires=${expires.toUTCString()}`);
|
229 |
+
}
|
230 |
+
|
231 |
+
// For WebSocket upgrade responses, make sure we preserve the Connection and Upgrade headers
|
232 |
+
if (isWebSocket && response.status === 101) {
|
233 |
+
clonedResponse.headers.set('Connection', 'Upgrade');
|
234 |
+
clonedResponse.headers.set('Upgrade', 'websocket');
|
235 |
+
}
|
236 |
+
|
237 |
+
console.log(`Successfully routed to ${backend}, status: ${response.status}`);
|
238 |
+
return clonedResponse;
|
239 |
+
} catch (error) {
|
240 |
+
console.error(`Error forwarding to ${backend}:`, error);
|
241 |
+
markBackendDown(backend, env);
|
242 |
+
|
243 |
+
// Choose a different backend for the next attempt
|
244 |
+
if (attempts < effectiveMaxRetries) {
|
245 |
+
backend = chooseBackend(request, env);
|
246 |
+
console.log(`Retrying with ${backend} (attempt ${attempts + 1}/${effectiveMaxRetries})`);
|
247 |
+
}
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
// If we've exhausted all retries, return a 502 Bad Gateway
|
252 |
+
return new Response('All backends are currently unavailable', {
|
253 |
+
status: 502,
|
254 |
+
headers: {
|
255 |
+
'Content-Type': 'text/plain',
|
256 |
+
'Retry-After': '30'
|
257 |
+
}
|
258 |
+
});
|
259 |
+
}
|
260 |
+
};
|
packages/cloudflare-loadbalancer/src/test.ts
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* This is a simple test script that can be run locally using wrangler dev.
|
3 |
+
* It simulates the behavior of the load balancer by mocking backend responses.
|
4 |
+
*/
|
5 |
+
|
6 |
+
import { Env } from './index';
|
7 |
+
|
8 |
+
// Mock fetch responses for each backend
|
9 |
+
const mockResponses = new Map<string, Response>();
|
10 |
+
|
11 |
+
// Helper to register a mock response for a backend
|
12 |
+
function mockBackendResponse(backend: string, status: number, body: string): void {
|
13 |
+
mockResponses.set(backend, new Response(body, { status }));
|
14 |
+
}
|
15 |
+
|
16 |
+
// Overrides the global fetch for testing
|
17 |
+
// @ts-ignore
|
18 |
+
globalThis.fetch = async (request: Request): Promise<Response> => {
|
19 |
+
const url = new URL(request.url);
|
20 |
+
const hostname = url.hostname;
|
21 |
+
|
22 |
+
if (mockResponses.has(hostname)) {
|
23 |
+
return mockResponses.get(hostname)!;
|
24 |
+
}
|
25 |
+
|
26 |
+
return new Response(`Unmocked backend: ${hostname}`, { status: 404 });
|
27 |
+
};
|
28 |
+
|
29 |
+
// Mock the location object for development detection
|
30 |
+
// @ts-ignore
|
31 |
+
globalThis.location = {
|
32 |
+
hostname: 'localhost:8787',
|
33 |
+
protocol: 'http:'
|
34 |
+
};
|
35 |
+
|
36 |
+
// Test scenarios
|
37 |
+
async function runTests() {
|
38 |
+
// Set up mock environment
|
39 |
+
const env: Env = {
|
40 |
+
PRIMARY_DOMAIN: 'aiostreams.example.com',
|
41 |
+
BACKEND_CF: 'aiostreams-cf.example.com',
|
42 |
+
BACKEND_KOYEB: 'aiostreams-koyeb.example.com',
|
43 |
+
BACKEND_DUCK: 'aiostreams.example.duckdns.org',
|
44 |
+
STICKY_SESSIONS: true,
|
45 |
+
SESSION_COOKIE_NAME: 'aiostreams_backend',
|
46 |
+
SESSION_COOKIE_TTL: '86400',
|
47 |
+
BACKEND_DOWN_TIME: '30000',
|
48 |
+
MAX_RETRIES: '3'
|
49 |
+
};
|
50 |
+
|
51 |
+
console.log('=== AIOStreams Load Balancer Tests ===');
|
52 |
+
|
53 |
+
// Test 1: All backends healthy
|
54 |
+
console.log('\nTest 1: All backends healthy');
|
55 |
+
mockBackendResponse(env.BACKEND_CF, 200, 'Response from CF');
|
56 |
+
mockBackendResponse(env.BACKEND_KOYEB, 200, 'Response from Koyeb');
|
57 |
+
mockBackendResponse(env.BACKEND_DUCK, 200, 'Response from DuckDNS');
|
58 |
+
|
59 |
+
// Simulate a request
|
60 |
+
const request1 = new Request(`https://${env.PRIMARY_DOMAIN}/test`);
|
61 |
+
// @ts-ignore - Import the actual handler from index.ts
|
62 |
+
const response1 = await require('./index').default.fetch(request1, env, {});
|
63 |
+
|
64 |
+
console.log(`Status: ${response1.status}`);
|
65 |
+
console.log(`Body: ${await response1.text()}`);
|
66 |
+
console.log(`Cookie: ${response1.headers.get('Set-Cookie')}`);
|
67 |
+
|
68 |
+
// Test 2: One backend down
|
69 |
+
console.log('\nTest 2: One backend down (Cloudflare)');
|
70 |
+
mockBackendResponse(env.BACKEND_CF, 503, 'Service Unavailable');
|
71 |
+
|
72 |
+
const request2 = new Request(`https://${env.PRIMARY_DOMAIN}/test`);
|
73 |
+
// @ts-ignore - Import the actual handler from index.ts
|
74 |
+
const response2 = await require('./index').default.fetch(request2, env, {});
|
75 |
+
|
76 |
+
console.log(`Status: ${response2.status}`);
|
77 |
+
console.log(`Body: ${await response2.text()}`);
|
78 |
+
|
79 |
+
// Test 3: Sticky session
|
80 |
+
console.log('\nTest 3: Sticky session (should use Koyeb)');
|
81 |
+
const request3 = new Request(`https://${env.PRIMARY_DOMAIN}/test`, {
|
82 |
+
headers: {
|
83 |
+
'Cookie': `${env.SESSION_COOKIE_NAME}=${env.BACKEND_KOYEB}`
|
84 |
+
}
|
85 |
+
});
|
86 |
+
|
87 |
+
// @ts-ignore - Import the actual handler from index.ts
|
88 |
+
const response3 = await require('./index').default.fetch(request3, env, {});
|
89 |
+
|
90 |
+
console.log(`Status: ${response3.status}`);
|
91 |
+
console.log(`Body: ${await response3.text()}`);
|
92 |
+
|
93 |
+
// Test 4: All backends down
|
94 |
+
console.log('\nTest 4: All backends down');
|
95 |
+
mockBackendResponse(env.BACKEND_CF, 503, 'Service Unavailable');
|
96 |
+
mockBackendResponse(env.BACKEND_KOYEB, 502, 'Bad Gateway');
|
97 |
+
mockBackendResponse(env.BACKEND_DUCK, 500, 'Internal Server Error');
|
98 |
+
|
99 |
+
const request4 = new Request(`https://${env.PRIMARY_DOMAIN}/test`);
|
100 |
+
// @ts-ignore - Import the actual handler from index.ts
|
101 |
+
const response4 = await require('./index').default.fetch(request4, env, {});
|
102 |
+
|
103 |
+
console.log(`Status: ${response4.status}`);
|
104 |
+
console.log(`Body: ${await response4.text()}`);
|
105 |
+
|
106 |
+
// Test 5: HTTP to HTTPS redirect
|
107 |
+
console.log('\nTest 5: HTTP to HTTPS redirect');
|
108 |
+
const request5 = new Request(`http://${env.PRIMARY_DOMAIN}/test`);
|
109 |
+
// @ts-ignore - Import the actual handler from index.ts
|
110 |
+
const response5 = await require('./index').default.fetch(request5, env, {});
|
111 |
+
|
112 |
+
console.log(`Status: ${response5.status}`);
|
113 |
+
console.log(`Location: ${response5.headers.get('Location')}`);
|
114 |
+
|
115 |
+
// Test 6: WebSocket handling
|
116 |
+
console.log('\nTest 6: WebSocket handling');
|
117 |
+
mockBackendResponse(env.BACKEND_CF, 101, ''); // WebSocket upgrade response
|
118 |
+
|
119 |
+
const webSocketHeaders = new Headers();
|
120 |
+
webSocketHeaders.set('Upgrade', 'websocket');
|
121 |
+
webSocketHeaders.set('Connection', 'Upgrade');
|
122 |
+
|
123 |
+
const request6 = new Request(`https://${env.PRIMARY_DOMAIN}/ws`, {
|
124 |
+
headers: webSocketHeaders
|
125 |
+
});
|
126 |
+
|
127 |
+
// @ts-ignore - Import the actual handler from index.ts
|
128 |
+
const response6 = await require('./index').default.fetch(request6, env, {});
|
129 |
+
|
130 |
+
console.log(`Status: ${response6.status}`);
|
131 |
+
console.log(`Upgrade header: ${response6.headers.get('Upgrade')}`);
|
132 |
+
console.log(`Connection header: ${response6.headers.get('Connection')}`);
|
133 |
+
|
134 |
+
// Test 7: Wrong hostname (should be ignored in dev environment)
|
135 |
+
console.log('\nTest 7: Wrong hostname (should be handled in dev)');
|
136 |
+
const request7 = new Request('https://wrong-hostname.example.com/test');
|
137 |
+
// @ts-ignore - Import the actual handler from index.ts
|
138 |
+
const response7 = await require('./index').default.fetch(request7, env, {});
|
139 |
+
|
140 |
+
console.log(`Status: ${response7.status}`);
|
141 |
+
console.log(`Body: ${await response7.text().then((body: string) => body.substring(0, 50) + '...')}`);
|
142 |
+
|
143 |
+
console.log('\n=== Tests Complete ===');
|
144 |
+
}
|
145 |
+
|
146 |
+
// Run the tests
|
147 |
+
runTests().catch(error => {
|
148 |
+
console.error('Test error:', error);
|
149 |
+
});
|
packages/cloudflare-loadbalancer/tsconfig.json
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"compilerOptions": {
|
3 |
+
"target": "es2022",
|
4 |
+
"lib": [
|
5 |
+
"es2022"
|
6 |
+
],
|
7 |
+
"module": "es2022",
|
8 |
+
"moduleResolution": "node",
|
9 |
+
"esModuleInterop": true,
|
10 |
+
"strict": true,
|
11 |
+
"noImplicitAny": true,
|
12 |
+
"strictNullChecks": true,
|
13 |
+
"strictFunctionTypes": true,
|
14 |
+
"strictBindCallApply": true,
|
15 |
+
"strictPropertyInitialization": true,
|
16 |
+
"noImplicitThis": true,
|
17 |
+
"alwaysStrict": true,
|
18 |
+
"isolatedModules": true,
|
19 |
+
"resolveJsonModule": true,
|
20 |
+
"skipLibCheck": true,
|
21 |
+
"outDir": "dist"
|
22 |
+
},
|
23 |
+
"include": [
|
24 |
+
"src/**/*"
|
25 |
+
],
|
26 |
+
"exclude": [
|
27 |
+
"node_modules",
|
28 |
+
"dist"
|
29 |
+
]
|
30 |
+
}
|
packages/cloudflare-loadbalancer/wrangler.toml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#:schema node_modules/wrangler/config-schema.json
|
2 |
+
name = "aiostreams-loadbalancer"
|
3 |
+
main = "src/index.ts"
|
4 |
+
compatibility_date = "2024-12-24"
|
5 |
+
compatibility_flags = ["nodejs_compat"]
|
6 |
+
|
7 |
+
# Workers Logs
|
8 |
+
[observability]
|
9 |
+
enabled = true
|
10 |
+
|
11 |
+
# Variable bindings
|
12 |
+
[vars]
|
13 |
+
# Primary domain the worker is handling
|
14 |
+
PRIMARY_DOMAIN = "aiostreams.example.com"
|
15 |
+
# Upstream backends
|
16 |
+
BACKEND_CF = "aiostreams-cf.example.com"
|
17 |
+
BACKEND_KOYEB = "aiostreams-koyeb.example.com"
|
18 |
+
BACKEND_DUCK = "aiostreams.example.duckdns.org"
|
19 |
+
# Sticky session configuration
|
20 |
+
STICKY_SESSIONS = true
|
21 |
+
# Session cookie name (used if sticky sessions are enabled)
|
22 |
+
SESSION_COOKIE_NAME = "aiostreams_backend"
|
23 |
+
# Session cookie TTL in seconds (default: 86400 = 1 day)
|
24 |
+
SESSION_COOKIE_TTL = "86400"
|
25 |
+
# How long to mark a backend as down after a failure (in milliseconds)
|
26 |
+
BACKEND_DOWN_TIME = "30000"
|
27 |
+
# Maximum number of retries when a backend fails
|
28 |
+
MAX_RETRIES = "3"
|
packages/cloudflare-worker/package.json
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@aiostreams/cloudflare-worker",
|
3 |
+
"version": "1.21.1",
|
4 |
+
"scripts": {
|
5 |
+
"deploy": "wrangler deploy",
|
6 |
+
"dev": "wrangler dev",
|
7 |
+
"start": "wrangler dev",
|
8 |
+
"test": "vitest",
|
9 |
+
"cf-typegen": "wrangler types"
|
10 |
+
},
|
11 |
+
"dependencies": {
|
12 |
+
"@aiostreams/addon": "^1.0.0",
|
13 |
+
"@aiostreams/types": "^1.0.0"
|
14 |
+
},
|
15 |
+
"devDependencies": {
|
16 |
+
"@cloudflare/workers-types": "^4.20241224.0",
|
17 |
+
"esbuild": "^0.25.5",
|
18 |
+
"typescript": "^5.5.2",
|
19 |
+
"wrangler": "^4.18.0"
|
20 |
+
}
|
21 |
+
}
|
packages/cloudflare-worker/src/index.ts
ADDED
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { AIOStreams, errorResponse, validateConfig } from '@aiostreams/addon';
|
2 |
+
import manifest from '@aiostreams/addon/src/manifest';
|
3 |
+
import { Config, StreamRequest } from '@aiostreams/types';
|
4 |
+
import { unminifyConfig } from '@aiostreams/utils';
|
5 |
+
|
6 |
+
const HEADERS = {
|
7 |
+
'Access-Control-Allow-Origin': '*',
|
8 |
+
'Access-Control-Allow-Methods': 'GET,HEAD,POST,OPTIONS',
|
9 |
+
};
|
10 |
+
|
11 |
+
const PROXY_URL = 'https://warp-proxy.bolabaden.org';
|
12 |
+
|
13 |
+
// Proxy utility function
|
14 |
+
async function fetchWithProxy(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
|
15 |
+
try {
|
16 |
+
// Convert input to string URL
|
17 |
+
const targetUrl = typeof input === 'string' ? input : input instanceof URL ? input.toString() : input.url;
|
18 |
+
|
19 |
+
// First, try to use the proxy
|
20 |
+
const proxyUrl = `${PROXY_URL}/fetch?url=${encodeURIComponent(targetUrl)}`;
|
21 |
+
const proxyResponse = await fetch(proxyUrl, {
|
22 |
+
...init,
|
23 |
+
// Add API key and other headers
|
24 |
+
headers: {
|
25 |
+
...init?.headers,
|
26 |
+
'User-Agent': 'AIOStreams-CloudflareWorker/1.0',
|
27 |
+
'X-API-Key': 'sk_IQys9kpENSiYY8lFuCslok3PauKBRSzeGprmvPfiMWAM9neeXoSqCZW7pMlWKbqPrwtF33kh1F73vf7D4PBpVfZJ1reHEL8d6ny6J03Ho',
|
28 |
+
},
|
29 |
+
});
|
30 |
+
|
31 |
+
// If proxy responds successfully, return the response
|
32 |
+
if (proxyResponse.ok) {
|
33 |
+
return proxyResponse;
|
34 |
+
}
|
35 |
+
|
36 |
+
// If proxy fails, fall back to direct request
|
37 |
+
console.warn(`Proxy failed with status ${proxyResponse.status}, falling back to direct request`);
|
38 |
+
return await fetch(input, init);
|
39 |
+
} catch (error) {
|
40 |
+
// If proxy is completely unreachable, fall back to direct request
|
41 |
+
console.warn('Proxy unreachable, falling back to direct request:', error);
|
42 |
+
return await fetch(input, init);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
function createJsonResponse(data: any): Response {
|
47 |
+
return new Response(JSON.stringify(data, null, 4), {
|
48 |
+
headers: HEADERS,
|
49 |
+
});
|
50 |
+
}
|
51 |
+
|
52 |
+
function createResponse(message: string, status: number): Response {
|
53 |
+
return new Response(message, {
|
54 |
+
status,
|
55 |
+
headers: HEADERS,
|
56 |
+
});
|
57 |
+
}
|
58 |
+
|
59 |
+
export default {
|
60 |
+
async fetch(request, env, ctx): Promise<Response> {
|
61 |
+
try {
|
62 |
+
const url = new URL(decodeURIComponent(request.url));
|
63 |
+
const components = url.pathname.split('/').splice(1);
|
64 |
+
|
65 |
+
// handle static asset requests
|
66 |
+
if (components.includes('_next') || components.includes('assets')) {
|
67 |
+
return env.ASSETS.fetch(request);
|
68 |
+
}
|
69 |
+
|
70 |
+
if (url.pathname === '/icon.ico') {
|
71 |
+
return env.ASSETS.fetch(request);
|
72 |
+
}
|
73 |
+
|
74 |
+
// redirect to /configure if root path is requested
|
75 |
+
if (url.pathname === '/') {
|
76 |
+
return Response.redirect(url.origin + '/configure', 301);
|
77 |
+
}
|
78 |
+
|
79 |
+
// handle /encrypt-user-data POST requests
|
80 |
+
if (components.includes('encrypt-user-data')) {
|
81 |
+
const data = (await request.json()) as { data: string };
|
82 |
+
if (!data) {
|
83 |
+
return createResponse('Invalid Request', 400);
|
84 |
+
}
|
85 |
+
const dataToEncode = data.data;
|
86 |
+
try {
|
87 |
+
console.log(
|
88 |
+
`Received /encrypt-user-data request with Data: ${dataToEncode}`
|
89 |
+
);
|
90 |
+
const encodedData = Buffer.from(dataToEncode).toString('base64');
|
91 |
+
return createJsonResponse({ data: encodedData, success: true });
|
92 |
+
} catch (error: any) {
|
93 |
+
console.error(error);
|
94 |
+
return createJsonResponse({ error: error.message, success: false });
|
95 |
+
}
|
96 |
+
}
|
97 |
+
// handle /configure and /:config/configure requests
|
98 |
+
if (components.includes('configure')) {
|
99 |
+
if (components.length === 1) {
|
100 |
+
return env.ASSETS.fetch(request);
|
101 |
+
} else {
|
102 |
+
// display configure page with config still in url
|
103 |
+
return env.ASSETS.fetch(
|
104 |
+
new Request(url.origin + '/configure', request)
|
105 |
+
);
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
// handle /manifest.json and /:config/manifest.json requests
|
110 |
+
if (components.includes('manifest.json')) {
|
111 |
+
if (components.length === 1) {
|
112 |
+
return createJsonResponse(manifest());
|
113 |
+
} else {
|
114 |
+
return createJsonResponse(manifest(undefined, true));
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
if (components.includes('stream')) {
|
119 |
+
// when /stream is requested without config
|
120 |
+
let config = decodeURIComponent(components[0]);
|
121 |
+
console.log(`components: ${components}`);
|
122 |
+
if (components.length < 4) {
|
123 |
+
return createJsonResponse(
|
124 |
+
errorResponse(
|
125 |
+
'You must configure this addon first',
|
126 |
+
url.origin,
|
127 |
+
'/configure'
|
128 |
+
)
|
129 |
+
);
|
130 |
+
}
|
131 |
+
console.log(`Received /stream request with Config: ${config}`);
|
132 |
+
const decodedPath = decodeURIComponent(url.pathname);
|
133 |
+
|
134 |
+
const streamMatch = /stream\/(movie|series)\/([^/]+)\.json/.exec(
|
135 |
+
decodedPath
|
136 |
+
);
|
137 |
+
if (!streamMatch) {
|
138 |
+
let path = decodedPath.replace(`/${config}`, '');
|
139 |
+
console.error(`Invalid request: ${path}`);
|
140 |
+
return createResponse('Invalid request', 400);
|
141 |
+
}
|
142 |
+
|
143 |
+
const [type, id] = streamMatch.slice(1);
|
144 |
+
console.log(`Received /stream request with Type: ${type}, ID: ${id}`);
|
145 |
+
|
146 |
+
let decodedConfig: Config;
|
147 |
+
|
148 |
+
if (config.startsWith('E-') || config.startsWith('E2-')) {
|
149 |
+
return createResponse('Encrypted Config Not Supported', 400);
|
150 |
+
}
|
151 |
+
try {
|
152 |
+
decodedConfig = unminifyConfig(
|
153 |
+
JSON.parse(Buffer.from(config, 'base64').toString('utf-8'))
|
154 |
+
);
|
155 |
+
} catch (error: any) {
|
156 |
+
console.error(error);
|
157 |
+
return createJsonResponse(
|
158 |
+
errorResponse(
|
159 |
+
'Unable to parse config, please reconfigure or create an issue on GitHub',
|
160 |
+
url.origin,
|
161 |
+
'/configure'
|
162 |
+
)
|
163 |
+
);
|
164 |
+
}
|
165 |
+
const { valid, errorMessage, errorCode } =
|
166 |
+
validateConfig(decodedConfig);
|
167 |
+
if (!valid) {
|
168 |
+
console.error(`Invalid config: ${errorMessage}`);
|
169 |
+
return createJsonResponse(
|
170 |
+
errorResponse(errorMessage ?? 'Unknown', url.origin, '/configure')
|
171 |
+
);
|
172 |
+
}
|
173 |
+
|
174 |
+
if (type !== 'movie' && type !== 'series') {
|
175 |
+
return createResponse('Invalid Request', 400);
|
176 |
+
}
|
177 |
+
|
178 |
+
let streamRequest: StreamRequest = { id, type };
|
179 |
+
|
180 |
+
decodedConfig.requestingIp =
|
181 |
+
request.headers.get('X-Forwarded-For') ||
|
182 |
+
request.headers.get('X-Real-IP') ||
|
183 |
+
request.headers.get('CF-Connecting-IP') ||
|
184 |
+
request.headers.get('X-Client-IP') ||
|
185 |
+
undefined;
|
186 |
+
|
187 |
+
// Temporarily replace global fetch with proxy-enabled fetch for AIOStreams
|
188 |
+
const originalFetch = globalThis.fetch;
|
189 |
+
globalThis.fetch = fetchWithProxy;
|
190 |
+
|
191 |
+
try {
|
192 |
+
const aioStreams = new AIOStreams(decodedConfig);
|
193 |
+
const streams = await aioStreams.getStreams(streamRequest);
|
194 |
+
return createJsonResponse({ streams });
|
195 |
+
} finally {
|
196 |
+
// Restore original fetch
|
197 |
+
globalThis.fetch = originalFetch;
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
const notFound = await env.ASSETS.fetch(
|
202 |
+
new Request(url.origin + '/404', request)
|
203 |
+
);
|
204 |
+
return new Response(notFound.body, { ...notFound, status: 404 });
|
205 |
+
} catch (e) {
|
206 |
+
console.error(e);
|
207 |
+
return new Response('Internal Server Error', {
|
208 |
+
status: 500,
|
209 |
+
headers: {
|
210 |
+
'Content-Type': 'text/plain',
|
211 |
+
},
|
212 |
+
});
|
213 |
+
}
|
214 |
+
},
|
215 |
+
} satisfies ExportedHandler<Env>;
|
packages/cloudflare-worker/tsconfig.json
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"compilerOptions": {
|
3 |
+
"target": "es2021",
|
4 |
+
"lib": ["es2021"],
|
5 |
+
/* Specify what JSX code is generated. */
|
6 |
+
"jsx": "react-jsx",
|
7 |
+
|
8 |
+
/* Specify what module code is generated. */
|
9 |
+
"module": "es2022",
|
10 |
+
/* Specify how TypeScript looks up a file from a given module specifier. */
|
11 |
+
"moduleResolution": "Bundler",
|
12 |
+
/* Specify type package names to be included without being referenced in a source file. */
|
13 |
+
"types": ["@cloudflare/workers-types"],
|
14 |
+
/* Enable importing .json files */
|
15 |
+
"resolveJsonModule": true,
|
16 |
+
|
17 |
+
/* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
|
18 |
+
"allowJs": true,
|
19 |
+
/* Enable error reporting in type-checked JavaScript files. */
|
20 |
+
"checkJs": false,
|
21 |
+
|
22 |
+
/* Disable emitting files from a compilation. */
|
23 |
+
"noEmit": true,
|
24 |
+
|
25 |
+
/* Ensure that each file can be safely transpiled without relying on other imports. */
|
26 |
+
"isolatedModules": true,
|
27 |
+
/* Allow 'import x from y' when a module doesn't have a default export. */
|
28 |
+
"allowSyntheticDefaultImports": true,
|
29 |
+
/* Ensure that casing is correct in imports. */
|
30 |
+
"forceConsistentCasingInFileNames": true,
|
31 |
+
|
32 |
+
/* Enable all strict type-checking options. */
|
33 |
+
"strict": true,
|
34 |
+
|
35 |
+
/* Skip type checking all .d.ts files. */
|
36 |
+
"skipLibCheck": true
|
37 |
+
},
|
38 |
+
"references": [
|
39 |
+
{
|
40 |
+
"path": "../addon"
|
41 |
+
},
|
42 |
+
{
|
43 |
+
"path": "../types"
|
44 |
+
}
|
45 |
+
],
|
46 |
+
"exclude": ["test"],
|
47 |
+
"include": ["worker-configuration.d.ts", "src/**/*.ts"]
|
48 |
+
}
|
packages/cloudflare-worker/worker-configuration.d.ts
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Generated by Wrangler by running `wrangler types`
|
2 |
+
|
3 |
+
interface Env {
|
4 |
+
ASSETS: Fetcher;
|
5 |
+
}
|
packages/cloudflare-worker/wrangler.toml
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#:schema node_modules/wrangler/config-schema.json
|
2 |
+
name = "aiostreams"
|
3 |
+
main = "src/index.ts"
|
4 |
+
compatibility_date = "2024-12-24"
|
5 |
+
compatibility_flags = ["nodejs_compat"]
|
6 |
+
assets = { directory = "../frontend/out", binding = "ASSETS", experimental_serve_directly = false}
|
7 |
+
|
8 |
+
# Workers Logs
|
9 |
+
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
|
10 |
+
# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
|
11 |
+
[observability]
|
12 |
+
enabled = true
|
13 |
+
|
14 |
+
# Automatically place your workloads in an optimal location to minimize latency.
|
15 |
+
# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
|
16 |
+
# rather than the end user may result in better performance.
|
17 |
+
# Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
|
18 |
+
# [placement]
|
19 |
+
# mode = "smart"
|
20 |
+
|
21 |
+
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
22 |
+
# Docs:
|
23 |
+
# - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
24 |
+
# Note: Use secrets to store sensitive data.
|
25 |
+
# - https://developers.cloudflare.com/workers/configuration/secrets/
|
26 |
+
[vars]
|
27 |
+
ADDON_ID="aiostreams.cfworker.bolabaden"
|
28 |
+
ADDON_NAME="BadenAIO (CloudFlare)"
|
29 |
+
DETERMINISTIC_ADDON_ID=false
|
30 |
+
SECRET_KEY="1070c705d193441da9fce510d5977e824686d5d0a0ab44bc8d8cb006ff64ee82"
|
31 |
+
API_KEY="sk_4dc059c0399c43fd94c09baaf0b94da119fc526775914bf2b3a3fb6e073e26d9"
|
32 |
+
LOG_LEVEL="debug"
|
33 |
+
LOG_FORMAT="text"
|
34 |
+
LOG_SENSITIVE_INFO=true
|
35 |
+
MAX_ADDONS=50
|
36 |
+
MAX_KEYWORD_FILTERS=30
|
37 |
+
DEFAULT_STREMTHRU_URL="https://stremthru.bolabaden.org/"
|
38 |
+
DEFAULT_STREMTHRU_CREDENTIAL="[email protected]:Hilogirl80!"
|
39 |
+
ENCRYPT_STREMTHRU_URLS=true
|
40 |
+
COMET_URL="http://comet.elfhosted.com/"
|
41 |
+
MEDIAFUSION_URL="http://mediafusion.elfhosted.com/"
|
42 |
+
JACKETTIO_URL="https://jackettio.elfhosted.com/"
|
43 |
+
DEFAULT_JACKETTIO_INDEXERS='["1337x", "animetosho", "anirena", "limetorrents", "nyaasi", "solidtorrents", "thepiratebay", "torlock", "yts"]'
|
44 |
+
DEFAULT_JACKETTIO_STREMTHRU_URL="https://stremthru.bolabaden.org"
|
45 |
+
STREMIO_JACKETT_URL="https://stremio-jackett.elfhosted.com/"
|
46 |
+
DEFAULT_STREMIO_JACKETT_TMDB_API_KEY="cec876f852b9c15d2c1b436b1117dff7"
|
47 |
+
STREMIO_JACKETT_CACHE_ENABLED=true
|
48 |
+
STREMTHRU_STORE_URL="https://stremthru.bolabaden.org/stremio/store/"
|
49 |
+
|
50 |
+
# Add other non-sensitive environment variables here
|
51 |
+
|
52 |
+
# Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
|
53 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
|
54 |
+
# [ai]
|
55 |
+
# binding = "AI"
|
56 |
+
|
57 |
+
# Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
|
58 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
|
59 |
+
# [[analytics_engine_datasets]]
|
60 |
+
# binding = "MY_DATASET"
|
61 |
+
|
62 |
+
# Bind a headless browser instance running on Cloudflare's global network.
|
63 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
|
64 |
+
# [browser]
|
65 |
+
# binding = "MY_BROWSER"
|
66 |
+
|
67 |
+
# Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
|
68 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
|
69 |
+
# [[d1_databases]]
|
70 |
+
# binding = "MY_DB"
|
71 |
+
# database_name = "my-database"
|
72 |
+
# database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
73 |
+
|
74 |
+
# Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
|
75 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
|
76 |
+
# [[dispatch_namespaces]]
|
77 |
+
# binding = "MY_DISPATCHER"
|
78 |
+
# namespace = "my-namespace"
|
79 |
+
|
80 |
+
# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
|
81 |
+
# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
|
82 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
|
83 |
+
# [[durable_objects.bindings]]
|
84 |
+
# name = "MY_DURABLE_OBJECT"
|
85 |
+
# class_name = "MyDurableObject"
|
86 |
+
|
87 |
+
# Durable Object migrations.
|
88 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
|
89 |
+
# [[migrations]]
|
90 |
+
# tag = "v1"
|
91 |
+
# new_classes = ["MyDurableObject"]
|
92 |
+
|
93 |
+
# Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
|
94 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
|
95 |
+
# [[hyperdrive]]
|
96 |
+
# binding = "MY_HYPERDRIVE"
|
97 |
+
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
98 |
+
|
99 |
+
# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
|
100 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
101 |
+
# [[kv_namespaces]]
|
102 |
+
# binding = "MY_KV_NAMESPACE"
|
103 |
+
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
104 |
+
|
105 |
+
# Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
|
106 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
|
107 |
+
# [[mtls_certificates]]
|
108 |
+
# binding = "MY_CERTIFICATE"
|
109 |
+
# certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
110 |
+
|
111 |
+
# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
|
112 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
113 |
+
# [[queues.producers]]
|
114 |
+
# binding = "MY_QUEUE"
|
115 |
+
# queue = "my-queue"
|
116 |
+
|
117 |
+
# Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
|
118 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
|
119 |
+
# [[queues.consumers]]
|
120 |
+
# queue = "my-queue"
|
121 |
+
|
122 |
+
# Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
|
123 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
|
124 |
+
# [[r2_buckets]]
|
125 |
+
# binding = "MY_BUCKET"
|
126 |
+
# bucket_name = "my-bucket"
|
127 |
+
|
128 |
+
# Bind another Worker service. Use this binding to call another Worker without network overhead.
|
129 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
130 |
+
# [[services]]
|
131 |
+
# binding = "MY_SERVICE"
|
132 |
+
# service = "my-service"
|
133 |
+
|
134 |
+
# Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
|
135 |
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
|
136 |
+
# [[vectorize]]
|
137 |
+
# binding = "MY_INDEX"
|
138 |
+
# index_name = "my-index"
|
packages/core/package.json
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@aiostreams/core",
|
3 |
+
"version": "0.0.0",
|
4 |
+
"main": "dist/index.js",
|
5 |
+
"scripts": {
|
6 |
+
"test": "vitest run --passWithNoTests",
|
7 |
+
"test:watch": "vitest watch",
|
8 |
+
"build": "tsc"
|
9 |
+
},
|
10 |
+
"description": "Combine all your streams into one addon and display them with consistent formatting, sorting, and filtering.",
|
11 |
+
"dependencies": {
|
12 |
+
"bcrypt": "^6.0.0",
|
13 |
+
"bytes": "^3.1.2",
|
14 |
+
"dotenv": "^16.4.7",
|
15 |
+
"envalid": "^8.0.0",
|
16 |
+
"expr-eval": "^2.0.2",
|
17 |
+
"moment-timezone": "^0.5.48",
|
18 |
+
"parse-torrent-title": "github:TheBeastLT/parse-torrent-title",
|
19 |
+
"pg": "^8.16.0",
|
20 |
+
"sqlite": "^5.1.1",
|
21 |
+
"sqlite3": "^5.1.7",
|
22 |
+
"super-regex": "^1.0.0",
|
23 |
+
"undici": "^7.2.3",
|
24 |
+
"winston": "^3.17.0",
|
25 |
+
"zod": "^3.24.4"
|
26 |
+
},
|
27 |
+
"devDependencies": {
|
28 |
+
"@types/bcrypt": "^5.0.2",
|
29 |
+
"@types/bytes": "^3.1.5",
|
30 |
+
"@types/node": "^20.14.10",
|
31 |
+
"@types/pg": "^8.15.2"
|
32 |
+
}
|
33 |
+
}
|
packages/core/src/db/db.ts
ADDED
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { TABLES } from './schemas';
|
2 |
+
import { createLogger } from '../utils';
|
3 |
+
import { parseConnectionURI, adaptQuery, ConnectionURI } from './utils';
|
4 |
+
|
5 |
+
const logger = createLogger('database');
|
6 |
+
|
7 |
+
import { Pool, Client, QueryResult } from 'pg';
|
8 |
+
import sqlite3 from 'sqlite3';
|
9 |
+
import { open, Database } from 'sqlite';
|
10 |
+
import { URL } from 'url';
|
11 |
+
import path from 'path';
|
12 |
+
import fs from 'fs';
|
13 |
+
|
14 |
+
type QueryResultRow = Record<string, any>;
|
15 |
+
|
16 |
+
interface UnifiedQueryResult<T = QueryResultRow> {
|
17 |
+
rows: T[];
|
18 |
+
rowCount: number;
|
19 |
+
command?: string;
|
20 |
+
}
|
21 |
+
|
22 |
+
type DBDialect = 'postgres' | 'sqlite';
|
23 |
+
|
24 |
+
type DSNModifier = (url: URL, query: URLSearchParams) => void;
|
25 |
+
|
26 |
+
type Transaction = {
|
27 |
+
commit: () => Promise<void>;
|
28 |
+
rollback: () => Promise<void>;
|
29 |
+
execute: (query: string, params?: any[]) => Promise<UnifiedQueryResult<any>>;
|
30 |
+
};
|
31 |
+
|
32 |
+
export class DB {
|
33 |
+
private static instance: DB;
|
34 |
+
private db!: Pool | Database<any>;
|
35 |
+
private static initialised: boolean = false;
|
36 |
+
private static dialect: DBDialect;
|
37 |
+
private uri!: ConnectionURI;
|
38 |
+
private dsnModifiers: DSNModifier[] = [];
|
39 |
+
|
40 |
+
private constructor() {}
|
41 |
+
|
42 |
+
static getInstance(): DB {
|
43 |
+
if (!this.instance) {
|
44 |
+
this.instance = new DB();
|
45 |
+
}
|
46 |
+
return this.instance;
|
47 |
+
}
|
48 |
+
isInitialised(): boolean {
|
49 |
+
return DB.initialised;
|
50 |
+
}
|
51 |
+
|
52 |
+
getDialect(): DBDialect {
|
53 |
+
return DB.dialect;
|
54 |
+
}
|
55 |
+
|
56 |
+
async initialise(
|
57 |
+
uri: string,
|
58 |
+
dsnModifiers: DSNModifier[] = []
|
59 |
+
): Promise<void> {
|
60 |
+
if (DB.initialised) {
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
try {
|
64 |
+
this.uri = parseConnectionURI(uri);
|
65 |
+
this.dsnModifiers = dsnModifiers;
|
66 |
+
await this.open();
|
67 |
+
await this.ping();
|
68 |
+
|
69 |
+
// create tables
|
70 |
+
for (const [name, schema] of Object.entries(TABLES)) {
|
71 |
+
const createTableQuery = `CREATE TABLE IF NOT EXISTS ${name} (${schema})`;
|
72 |
+
await this.execute(createTableQuery);
|
73 |
+
}
|
74 |
+
|
75 |
+
if (this.uri.dialect === 'sqlite') {
|
76 |
+
await this.execute('PRAGMA busy_timeout = 5000');
|
77 |
+
await this.execute('PRAGMA foreign_keys = ON');
|
78 |
+
await this.execute('PRAGMA synchronous = OFF');
|
79 |
+
await this.execute('PRAGMA journal_mode = WAL');
|
80 |
+
await this.execute('PRAGMA locking_mode = IMMEDIATE');
|
81 |
+
}
|
82 |
+
|
83 |
+
DB.initialised = true;
|
84 |
+
DB.dialect = this.uri.dialect;
|
85 |
+
} catch (error) {
|
86 |
+
logger.error('Failed to initialize database:', error);
|
87 |
+
throw error;
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
async open(): Promise<void> {
|
92 |
+
if (this.uri.dialect === 'postgres') {
|
93 |
+
const pool = new Pool({
|
94 |
+
connectionString: this.uri.url.toString(),
|
95 |
+
idleTimeoutMillis: 30000,
|
96 |
+
connectionTimeoutMillis: 2000,
|
97 |
+
});
|
98 |
+
this.db = pool;
|
99 |
+
this.uri.dialect = 'postgres';
|
100 |
+
} else if (this.uri.dialect === 'sqlite') {
|
101 |
+
// make parent directory if it does not exist
|
102 |
+
const parentDir = path.dirname(this.uri.filename);
|
103 |
+
if (!parentDir) {
|
104 |
+
throw new Error('Invalid SQLite path');
|
105 |
+
}
|
106 |
+
if (!fs.existsSync(parentDir)) {
|
107 |
+
fs.mkdirSync(parentDir, { recursive: true });
|
108 |
+
}
|
109 |
+
logger.debug(`Opening SQLite database: ${this.uri.filename}`);
|
110 |
+
|
111 |
+
this.db = await open({
|
112 |
+
filename: this.uri.filename,
|
113 |
+
driver: sqlite3.Database,
|
114 |
+
});
|
115 |
+
this.uri.dialect = 'sqlite';
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
async close(): Promise<void> {
|
120 |
+
if (this.uri.dialect === 'postgres') {
|
121 |
+
await (this.db as Pool).end();
|
122 |
+
} else if (this.uri.dialect === 'sqlite') {
|
123 |
+
await (this.db as Database<any>).close();
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
async ping(): Promise<void> {
|
128 |
+
if (this.uri.dialect === 'postgres') {
|
129 |
+
await (this.db as Pool).query('SELECT 1');
|
130 |
+
} else if (this.uri.dialect === 'sqlite') {
|
131 |
+
await (this.db as Database<any>).get('SELECT 1');
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
async execute(query: string, params?: any[]): Promise<any> {
|
136 |
+
if (this.uri.dialect === 'postgres') {
|
137 |
+
return (this.db as Pool).query(
|
138 |
+
adaptQuery(query, this.uri.dialect),
|
139 |
+
params
|
140 |
+
);
|
141 |
+
} else if (this.uri.dialect === 'sqlite') {
|
142 |
+
return (this.db as Database<any>).run(
|
143 |
+
adaptQuery(query, this.uri.dialect),
|
144 |
+
params
|
145 |
+
);
|
146 |
+
}
|
147 |
+
throw new Error('Unsupported dialect');
|
148 |
+
}
|
149 |
+
|
150 |
+
async query(query: string, params?: any[]): Promise<any[]> {
|
151 |
+
const adaptedQuery = adaptQuery(query, this.uri.dialect);
|
152 |
+
if (this.uri.dialect === 'postgres') {
|
153 |
+
const result = await (this.db as Pool).query(adaptedQuery, params);
|
154 |
+
return result.rows;
|
155 |
+
} else if (this.uri.dialect === 'sqlite') {
|
156 |
+
return (this.db as Database<any>).all(adaptedQuery, params);
|
157 |
+
}
|
158 |
+
return [];
|
159 |
+
}
|
160 |
+
|
161 |
+
async begin(): Promise<Transaction> {
|
162 |
+
if (this.uri.dialect === 'postgres') {
|
163 |
+
const client = await (this.db as Pool).connect();
|
164 |
+
await client.query('BEGIN');
|
165 |
+
|
166 |
+
let finalised = false;
|
167 |
+
|
168 |
+
const finalise = () => {
|
169 |
+
if (!finalised) {
|
170 |
+
finalised = true;
|
171 |
+
client.release();
|
172 |
+
}
|
173 |
+
};
|
174 |
+
|
175 |
+
return {
|
176 |
+
commit: async () => {
|
177 |
+
try {
|
178 |
+
await client.query('COMMIT');
|
179 |
+
} finally {
|
180 |
+
finalise();
|
181 |
+
}
|
182 |
+
},
|
183 |
+
rollback: async () => {
|
184 |
+
try {
|
185 |
+
await client.query('ROLLBACK');
|
186 |
+
} finally {
|
187 |
+
finalise();
|
188 |
+
}
|
189 |
+
},
|
190 |
+
execute: async (
|
191 |
+
query: string,
|
192 |
+
params?: any[]
|
193 |
+
): Promise<UnifiedQueryResult> => {
|
194 |
+
const result = await client.query(
|
195 |
+
adaptQuery(query, 'postgres'),
|
196 |
+
params
|
197 |
+
);
|
198 |
+
return {
|
199 |
+
rows: result.rows,
|
200 |
+
rowCount: result.rowCount || 0,
|
201 |
+
command: result.command,
|
202 |
+
};
|
203 |
+
},
|
204 |
+
};
|
205 |
+
} else if (this.uri.dialect === 'sqlite') {
|
206 |
+
const db = this.db as Database<any>;
|
207 |
+
await db.run('BEGIN');
|
208 |
+
return {
|
209 |
+
commit: async () => {
|
210 |
+
await db.run('COMMIT');
|
211 |
+
},
|
212 |
+
rollback: async () => {
|
213 |
+
await db.run('ROLLBACK');
|
214 |
+
},
|
215 |
+
execute: async (
|
216 |
+
query: string,
|
217 |
+
params?: any[]
|
218 |
+
): Promise<UnifiedQueryResult> => {
|
219 |
+
const result = await db.all(adaptQuery(query, 'sqlite'), params);
|
220 |
+
return {
|
221 |
+
rows: result,
|
222 |
+
rowCount: result.length || 0,
|
223 |
+
command: 'SELECT',
|
224 |
+
};
|
225 |
+
},
|
226 |
+
};
|
227 |
+
}
|
228 |
+
throw new Error('Unsupported transaction dialect');
|
229 |
+
}
|
230 |
+
}
|
packages/core/src/db/index.ts
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export * from './db';
|
2 |
+
export * from './users';
|
3 |
+
export * from './schemas';
|
4 |
+
export * from './queue';
|
packages/core/src/db/queue.ts
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { createLogger } from '../utils';
|
2 |
+
import { DB } from './db';
|
3 |
+
const logger = createLogger('db');
|
4 |
+
const db = DB.getInstance();
|
5 |
+
|
6 |
+
// Queue for SQLite transactions
|
7 |
+
|
8 |
+
export class TransactionQueue {
|
9 |
+
private queue: Array<() => Promise<any>> = [];
|
10 |
+
private processing = false;
|
11 |
+
private static instance: TransactionQueue;
|
12 |
+
|
13 |
+
private constructor() {}
|
14 |
+
|
15 |
+
static getInstance(): TransactionQueue {
|
16 |
+
if (!this.instance) {
|
17 |
+
this.instance = new TransactionQueue();
|
18 |
+
}
|
19 |
+
return this.instance;
|
20 |
+
}
|
21 |
+
|
22 |
+
async enqueue<T>(operation: () => Promise<T>): Promise<T> {
|
23 |
+
// If using PostgreSQL, execute directly without queuing
|
24 |
+
if (db['uri']?.dialect === 'postgres') {
|
25 |
+
return operation();
|
26 |
+
}
|
27 |
+
|
28 |
+
return new Promise((resolve, reject) => {
|
29 |
+
this.queue.push(async () => {
|
30 |
+
try {
|
31 |
+
const result = await operation();
|
32 |
+
resolve(result);
|
33 |
+
} catch (error) {
|
34 |
+
reject(error);
|
35 |
+
}
|
36 |
+
});
|
37 |
+
this.processQueue();
|
38 |
+
});
|
39 |
+
}
|
40 |
+
|
41 |
+
private async processQueue() {
|
42 |
+
if (this.processing || this.queue.length === 0) return;
|
43 |
+
this.processing = true;
|
44 |
+
|
45 |
+
while (this.queue.length > 0) {
|
46 |
+
const operation = this.queue.shift();
|
47 |
+
if (operation) {
|
48 |
+
try {
|
49 |
+
await operation();
|
50 |
+
} catch (error) {
|
51 |
+
logger.error('Error processing queued operation:', error);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
this.processing = false;
|
57 |
+
}
|
58 |
+
}
|