Repository navigation
Add AIOStreams, TorBox and dual-debrid stream diversity - #43
Conversation
Stream selection now resolves through AIOStreams or the direct providers, and users can keep RealDebrid and TorBox keys at once so both resolvers feed the same list: providers are merged, deduplicated by info hash and file index, and the preferred service's streams are ordered first. Playback also gains selectable quality rungs with HDR tone mapping and hardware encoder auto-detection, so slow links and HDR sources transcode predictably. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Make saved keys removable, verify administrator key replacements before they replace a working key, constrain app_settings to a single row, and fix two transcode filter defects: HDR detection now keys off the transfer function only, and bitmap subtitles are scaled to the base before the overlay. The resolver also probes with a Range request and routes provider proxy links by origin, and stalls rejected during recovery no longer count toward a quality downgrade. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
An automatic quality downgrade now leaves direct/remux playback so the next reconnect actually carries the rung, and resolver connections are chosen by the candidate's provider before URL origin so a shared Comet/AIOStreams origin keeps the AIOStreams proxy in use. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Keeps upstream's redesigned views and README, with the debrid section rebuilt as a dual-service panel and TorBox/AIOStreams documented in the new docs/CONFIGURATION.md. The home notice now covers TorBox and team keys. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
The settings controller only ran key verification on the update path without a password, so a mistyped TorBox or RealDebrid key saved in the same form as a password change replaced a working key while the flash message reported only the password update. Run the same verification on the password path and report a failure as an alert that still confirms the password change. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Upstream added a picture-in-picture button and notice to the player, which collides with this branch's quality selector in the target list and the control bar. Both features are additive, so the resolution keeps the quality select and the PiP button side by side and registers both sets of targets. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@vitobotta ready for a first review and mergeable against current |
vitobotta
left a comment
There was a problem hiding this comment.
Not ready to merge. Two blocking items, one security fix and two behavior gaps; the rest is minor.
Blocking
-
The committed suite is red.
bundle exec rspecis 559 examples with 1 failure:spec/services/tor_box_service_spec.rb:31.to_timeoutraisesFaraday::ConnectionFailedon the locked Faraday 2.15.1, so the service returns "Could not connect to TorBox" and theinclude("timed out")expectation fails. The timeout branch is never exercised. Fix the stub or the rescue, and get the suite green. -
Nobody can become an admin.
admindefaults to false and no seed, rake task, env var, UI or doc ever sets it to true. A fresh install therefore hides the Team link and/admin/settingsonly redirects, so the team-key feature this PR adds cannot be reached without a console update. Add a documented bootstrap (first-user promotion,FIRST_ADMIN_EMAIL, or a rake task) and a README step.
Security
- Comet writes the debrid key to the log.
build_configbase64-encodes the key into the request path, and the HTTP failure and timeout rescues log that path. Base64 is reversible, and the path now carries TorBox keys as well as RealDebrid ones. Redact the config segment before logging.
Behavior
-
Auto-downgrade never runs on HLS. The new call sits in
handleStreamStall. Safari and iOS stalls go throughhandleHlsStall, which restarts the session at the current quality, so auto mode never steps down on the platform where HLS is the default. Call the same check from the HLS path. -
Hardware encoders are now auto-selected on Linux.
transcode_argstries nvenc, qsv and amf ifFFMPEG_ENCODERis unset. Those arg lists set no bitrate, and auto quality adds no-maxrate, so a GPU host can encode 1080p at the encoder default instead of libx264 CRF 23. Make it opt-in or add rate control, and document it.
Minor
- The Team entry uses
sidebar-link, which is not defined anywhere. The other sidebar links usenav-link, so the new entry loses padding, hover and active styles. content/show.html.erb:208still tells a TorBox-only user to add a RealDebrid key. Use the debrid-configured helper there as the home page now does.- The README env table and
docs/CONFIGURATION.mdomitREALDEBRID_API_KEY,TORBOX_API_KEY,AIOSTREAMS_URL,AIOSTREAMS_PROXY,TORBOX_API_BASE_URLandSTREAM_SOURCE_HOSTS. db/schema.rbreorders the columns of every table. That is dump noise and will conflict with the other open PRs; regenerate on the project DB version or revert the reorder.
Verified
- Focused specs (user, resolved source, stream provider, resolver, TorBox, AIOStreams, available streams, Comet, transcoder, settings, admin settings): 227 examples, 1 failure (the TorBox timeout).
- Full RSpec: 559 examples, 1 failure.
- JS: 530 pass, 0 fail.
- RuboCop on 22 touched Ruby files: no offenses.
db:prepare, migrations andtailwindcss:buildrun.- Admin settings specs cover member rejection, masked keys, verify-before-save, clear and blank-keeps.
- Scale filter with a real ffmpeg run: 1920x1080 becomes 1280x720, 1440x1080 becomes 960x720, 1080x1920 becomes 406x720.
- Key scoping: the RealDebrid bearer is only added for RealDebrid hosts, TorBox and AIOStreams URLs get no debrid header, and an unlisted host is rejected.
Not verified
- Live AIOStreams or TorBox playback; the PR says the same, and it needs a password-protected install link and an active TorBox account.
- The quality menu in a real browser; the PR says it has not been driven.
- The container ffmpeg build for
zscale,tonemapand hardware encoders; I could not build the image here. There are also no CI checks attached to the head, so the gates above are local runs.
WebMock's to_timeout surfaces as a connection failure on Faraday 2.15, so the timeout branch was never exercised; hardware encoders become opt-in because they carry no rate control; the Comet config segment is base64 of the debrid key and must not be logged. Also merges upstream/main, keeping the quality param inside its new buildMseStreamUrl and restoring the schema column order.
|
All items are addressed at Blocking
Security
Behaviour
Minor
One merge note: main moved the MSE URL construction into Gates on this head (Windows machine, so results differ from your Linux run): targeted services and request specs 115/0; JS 580/580; RuboCop clean on every touched Ruby file. Full suite is 596 examples with 12 failures, and all 12 are platform-only: ten |
|
Drove the player in a real browser on a deployed build of this branch to close the "quality menu not driven" gap. Environment: the branch built with its own Dockerfile, the app on a LAN address, Chromium, a real playback descriptor issued by the app for a public MP4 ( Quality menu
HLS downgrade Chromium cannot start the HLS path on its own (it needs
So the HLS stall path does step down and the restarted session carries the new rung. What I did not observe is HLS playback itself: the sessions and playlists were created and served, but Chromium has no native HLS, so I cannot claim the restarted stream played in Safari. The AIOStreams provider and TorBox resolver also remain unexercised for lack of credentials. |
|
@vitobotta the verification section of this PR description has been rewritten to match what was actually measured, and it no longer claims the quality menu is untested. Since the last review:
Could you take another look when you have a moment? |
vitobotta
left a comment
There was a problem hiding this comment.
All six findings from the previous review are addressed at 156e6cc:
- The TorBox timeout example now raises
Faraday::TimeoutError, so the actual timeout rescue runs. - The
admin:promotetask and the README bootstrap step make the Team page reachable on a fresh install. - Comet logs
/[config]/stream/instead of the base64 config segment. - Hardware encoders are opt-in through
FFMPEG_ENCODER, with libx264 as the default. - HLS stalls now call
maybeDowngradeAutoQualitybefore restarting the session. - The Team entry uses the existing
nav-linkclass.
The branch still conflicts with current main in db/schema.rb. Main's schema version is 2026_10_30_130000 from the playlists migration, while this branch carries 2026_11_05_090000. Rebase onto main and keep 2026_11_05_090000, retaining the playlists tables that main adds.
Gates after a test merge with that resolution: 623 RSpec examples, 0 failures; 580 JavaScript tests, 0 failures; RuboCop inspected 165 files with no offenses; Brakeman clean. The focused changed-area specs are 231 examples, 0 failures.
No other findings.
Resolve the schema dump against main's playlists migration: keep this branch's 2026_11_05_090000 version with app_settings, and retain the playlists tables main adds. The merged schema was verified by migrating a throwaway database from scratch and comparing the dump, which matches byte for byte. The README env table keeps both sides' rows.
|
Merged today's main ( I merged rather than replaying the branch: it carries seven commits, two of which are earlier merges of main, so a rebase re-conflicts each one. The merged tree is the one your test merge describes — 623 RSpec examples, matching your count exactly. Schema resolution — README — the env table keeps both sides' rows, so the RealDebrid/TorBox/AIOStreams/ Gates at |
vitobotta
left a comment
There was a problem hiding this comment.
The merge onto d0f8cb9 resolves the schema conflict. db/schema.rb uses version 2026_11_05_090000, keeps the app_settings table from this branch, and retains the playlists and playlist_items tables from main.
The six earlier findings remain fixed. CI now passes lint, scan_js and scan_ruby, and the PR is MERGEABLE and CLEAN.
Gates at 7a3584a: 623 RSpec examples, 0 failures; 580 JavaScript tests, 0 failures; RuboCop inspected 198 files with no offenses; Brakeman reports no warnings.
No other findings.
|
Merged. Thanks @phantomic12 for the AIOStreams, TorBox, dual-debrid and team-key work. A new release will be made soon. |
Summary
Adds AIOStreams and TorBox as first-class stream sources alongside Real-Debrid/Comet, and lets both debrid accounts be active at once so the resolver ranks every candidate in a single list instead of picking one provider up front.
Streams::AioStreamsProvider,AIOSTREAMS_URL): reads a Stremio install link, normalisesbehaviorHints, resolution and size, and probes a proxied resolve URL withRange: bytes=0-1before treating it as playable.TorBoxService,TORBOX_API_KEY): account info, torrent search, and per-user keys kept in encrypted credentials, with separate admin team key and user key handling.StreamProvidermerges candidates from all configured providers, the resolver scores them together, and cached playback generations stay keyed per provider.scale2reffor bitmap subtitles when the deployed ffmpeg supports it.Routing also had to become provider-aware: when
COMET_URLandAIOSTREAMS_URLshare an origin, the candidate's provider now decides which connection (and therefore which proxy) is used, rather than comparing origins alone.Automated checks (at
156e6cc, Windows dev box)streams_resolver_spec,tor_box_service_spec,admin_settings_spec,settings_spec,media_transcoder_spec,hls_session_manager_spec,hls_spec): 156 examples, 11 failures, and none of the failures is an assertion. Nine come fromProcess.spawn(..., pgroup: true)raisingwrong exec option symbol: pgroupand two fromProcess.kill('SIGCONT', -pid)raisingunsupported signal 'SIGCONT'; both are Windows gaps in the process-manager specs. Everything else passes, including provider routing, shared-origin routing, resolve-URL probing, TorBox account/search/error paths, key save/verify/clear leaving a working key intact when verification fails,scale2refburn-in, HDR transfer-function detection, and the stall-driven HLS quality argument.node --test spec/javascript/*_test.mjs: 580 tests, 580 pass, 0 fail. Includes the auto-downgrade ladder stepping direct playback onto the transcode path and the HLS stall hook.bin/rubocop: 188 files inspected, no offenses.pgroup, 1SIGCONT) plusspec/config/production_process_spec.rb:15, which spawnsbin/docker-entrypointand cannot execute on Windows./up200,scale2refpresent on the bundled ffmpeg 7.1.5, single-rowapp_settingsafter migration.Browser verification (head
156e6cc)Deployed the branch with its own Dockerfile on a LAN host and drove it in Chromium, signed in as a real user. No AIOStreams install link or TorBox subscription was available, so playback was reached through a real playback descriptor issued by the app for a public MP4 (
media.w3.org, allowlisted throughSTREAM_SOURCE_HOSTS). That exercises the genuine direct-play, transcode and HLS endpoints; only the provider/resolver layer is bypassed.Quality menu
/direct_stream, playing at 19.8s,readyState4), menu atAuto.720p: controller moved toquality=720p/autoQuality=false, the select synced, the choice persisted tolocalStorage, and playback restarted throughGET /transcode?...&start_seconds=30&quality=720p(200), continuing on the MSEblob:source with the resume position kept.HLS downgrade
Chromium cannot enter the HLS path on its own (it requires
isSafari()), so the watchdog entry point was driven on the live controller with the restart requests captured:POST /hls/startbody tailautoauto...&start_seconds=5&audio_stream=1(noquality)720p, select synced...&start_seconds=5&quality=720p&audio_stream=1So the stall path does step down, and the restarted session carries the new rung.
Not covered