Skip to content

feat: Add regex URI Rules engine, cloud share link rewrites, Video Players toggle & UI enhancements - #1

Closed
Bluscream wants to merge 138 commits into
codeyumx:mainfrom
Bluscream:main
Closed

Bluscream wants to merge 138 commits into
codeyumx:mainfrom
Bluscream:main

Conversation

@Bluscream

@Bluscream Bluscream commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary of Enhancements

This Pull Request brings several major feature enhancements ported and expanded from the VRCVideoCacher ecosystem:

📷 Screenshots & Release Artifacts: https://github.com/Bluscream/VRCVideoCacherPlusPlus/releases/tag/2026.8.20

⚡ Regex URI Rules Engine & Live Matcher UI

  • Added a flexible UriRule engine supporting Cache, Redirect, Rewrite, Block, and Direct actions.
  • Features regex pattern matching with capture group substitutions ($1, $2) and token expansions.
  • Rules Tab: Live DataGrid interface displaying all configured rules with live Test URL matcher preview.
  • Priority Reordering: Support for moving rules up/down.
  • Unsaved Changes Protection: Modal dialog preventing accidental data loss when switching tabs or closing with unsaved rules.

🔀 Rewrite Action & Cloud Share Direct Link Rewrites

  • Introduced the Rewrite rule action type which transforms URLs (such as cloud share links) while allowing lower rules down the chain to evaluate the rewritten URL.
  • Added default rules for:
    • Dropbox Direct Share Rewrite: dl=0 -> dl=1
    • Google Drive File Rewrite: /file/d/<id>/view -> uc?export=download&id=<id>
    • MightyGym CDN Direct, Illumination Media Direct, Virtual Film Institute Direct bypasses.

🎬 In-Game Video Player Toggle

  • Added a Video Players control card on the Dashboard with a single Enable / Disable toggle button.
  • When disabled, all in-game video playback requests are immediately blocked.

🛠️ Dashboard & UI Improvements

  • Tools Status Card: Consolidated status card tracking yt-dlp, Deno, and FFmpeg runtimes (Up-To-Date, Shim, Outdated, Missing).
  • Cache Browser Action Buttons: Reordered action shortcuts (Watch Video, Copy File Path, Open on YouTube, Open Source URL, Delete).
  • Firefox Extension Validation: Fixed missing data_collection_permissions in manifest.json for AMO compatibility.

…h is not found to prevent error popup dialog
…ew UI keys strictly into dedicated bottom section
…cked URLs to rules, and remove legacy BlockedUrls section from SettingsView
…set confirmation and remove redundant ConfirmUnsavedWindow
Bluscream and others added 18 commits August 22, 2026 05:52
…ened

The Linux path could not work and said it did. `ss -t -K` needs CAP_NET_ADMIN;
without it the kernel refuses, ss writes "SOCK_DESTROY answers: Operation not
permitted" to stderr, prints its column header to stdout, and still exits 0.
TryKillSocketsForIp treated exit-code-0-plus-non-empty-stdout as success, so on
every machine without root it logged "Successfully severed N active video
connection targets" while changing nothing. Verified against a live socket: the
connection survives untouched.

Windows has the same shape — SetTcpEntry returns ERROR_ACCESS_DENIED without
elevation, and that was logged at Debug, so it also failed silently.

Reworked around the distinction that actually matters:

  Local  — a cached video streaming from our own web server. We own that
           socket, so closing it always works, everywhere, unprivileged.
  Remote — VRChat talking to a CDN directly. Privileged, and therefore usually
           impossible.

Severing now returns a SeverResult carrying both counts and a SeverOutcome
(Severed / NotPermitted / Unsupported / NothingToDo / Failed), classified from
what actually happened: stderr for the permission refusal, and socket rows
printed beneath ss's header for real closures. The UI and the log say
"this needs administrator/root, a video already streaming will keep playing"
instead of claiming victory.

SocketKill is split into NetworkConnections (read-only listing, safe) and
ConnectionSevering (privileged, destructive) — keeping them together made it
easy to assume that seeing a connection meant being able to close it.

Also in this pass:

- Dropped the silent `sudo -n ss -K` escalation. Attempting to run as root
  without ever telling the user is not something to do behind their back; the
  message now explains the requirement so they can choose to elevate.
- Subprocesses go through ProcessRunner instead of ReadToEnd-then-WaitForExit,
  the deadlock shape that runner exists to prevent, and severing is async so it
  no longer blocks the UI thread on two process launches per address.
- Severing one CDN address no longer calls CloseAllLocalStreams and take every
  other playing video down with it.
- procfs parsing returns failure instead of "127.0.0.1" for anything it cannot
  parse — a real address that would then be matched and severed — and now reads
  /proc/net/tcp6, so IPv6 streams are at least visible.
- Process matching is exact ("VRChat") rather than a substring, and the result
  is cached briefly instead of enumerating every process on the machine per
  refresh.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ated

The first-run notice said "Your previous settings have been kept as a backup in
PlusConfig.json.bak". Migrations were deliberately removed, so nothing writes a
.bak anywhere — users following that advice would go looking for a file that
does not exist. What actually happens is simpler: the old PlusConfig.json is
left exactly where it is, unread. The notice now says that, and also names the
Plus version alongside the original as something that will rewrite the file.

A test asserted the ".bak" string, so it was enforcing the incorrect text
rather than catching it; it now asserts the real filename and that no backup is
mentioned.

Adds a locale key-parity test, which immediately found ko.loc.json missing
CookiesRefreshHeader. English is the fallback so it degraded quietly, which is
exactly why it went unnoticed — the key is now present and drift fails the build.

Also corrects two comments left describing the removed migration, in
ConfigManager and DefaultRules.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A failing YouTube video could launch yt-dlp four times: the AVPro attempt, the
non-AVPro retry, the android-client fallback, and ApiController's own retry
after the prefetch fails. Each launch is a ~15 MB Python bundle with a second or
two of startup, and VRChat is blocked on the resolve throughout. For a deleted,
private or members-only video, not one of them could ever have succeeded.

The retries themselves are worth keeping — the android fallback genuinely
rescues restricted DASH formats, and a cookie-less retry rescues expired
cookies — so rather than removing them, they are now gated on
IsTerminalFailure. Format errors and bot checks stay retryable (a different
player client can beat both); "Video unavailable", "Private video",
"members-only", "has been terminated" and friends return immediately.

Also moves the oEmbed lookup below the cache check in
FetchAndCacheYouTubeMetadataAsync. It ran first, so every call made an HTTP
round trip to YouTube even when the duration was already cached and the method
was about to return without doing anything. Its bare `catch {}` is gone too —
GetVideoTitleAsync already logs its own failures, which that swallowed.

Sixteen tests cover the classifier in both directions.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…-aware log monitor

Three fixes to connection severing and one to the log monitor.

IPv6 on Linux: `ss` parses its own address filter, and a bare IPv6 literal loses —
the colons read as a host:port separator, so `dst 2001:db8::1` is rejected with
"an inet prefix is expected rather than 2001:db8:" and nothing is closed. Verified
against a live `ss` that `dst [2001:db8::1]` parses and a bare literal does not.
Brackets are all that was missing; SOCK_DESTROY itself is address-family agnostic.

IPv6 on Windows: there is no fix. Windows exposes MIB_TCP6ROW for listing IPv6
connections but has never shipped a SetTcp6Entry to close one, at any privilege
level. Previously those targets were silently skipped and folded into the same
"not permitted" bucket as an unelevated IPv4 attempt, which would now offer an
elevation prompt that cannot possibly help. They are split out and reported as
Unsupported instead — while an IPv4 sever that did work still reports Severed.

Elevation: ElevatorManager already knew how to re-run us as root through pkexec
(falling back to sudo with a graphical askpass, then a terminal), which is how the
hosts entry is edited. That is generalised into RunElevatedSelfAsync and reused
here via a new --sever-connections=<ip>,<ip> one-shot command, so on KDE the
password prompt is polkit's own agent and the password never enters this process.
The helper re-parses every address as an IPAddress and drops anything else before
it reaches `ss`, since that code path runs as root.

Elevation is opt-in per call site: the explicit "sever this connection" buttons
pass allowElevation, the automatic block-all-videos toggle does not — a polkit or
UAC dialog nobody asked for, mid-session, is worse than a video that finishes.
Users who would rather never be prompted can grant the capability once instead;
CapabilityHint spells out the setcap cap_net_admin+ep line and is surfaced in the
log whenever the kernel refuses.

VrcLogMonitor now links its token to Program.ShutdownToken like the other
background loops, so it unwinds on shutdown rather than being killed mid-read by
the Environment.Exit at the end of Main.

Adds 6 tests (208 total).
English is the localization fallback, which is precisely why translation problems
never surface: a missing key silently renders English, an empty one silently
renders nothing, and a key nobody references any more just sits there being
translated into eight languages forever. scripts/lint-locales.py makes all of it
fatal — missing, unexpected, empty, untranslated and unused keys — and is wired
into both build.sh --lint and CI. Each of the five checks was verified to fail the
build by breaking a locale file on purpose and confirming the exit code.

It is Python rather than shell because every check needs real JSON parsing and the
build cannot assume `jq` is installed.

Two escape hatches, kept apart on purpose. locale-allow-identical.txt is for values
that are legitimately the same everywhere (Chrome, Firefox, the product name).
locale-untranslated.txt is debt, listed as lang:Key, so new untranslated strings
fail while existing ones do not block; the linter also fails on a *stale* entry, so
finishing a translation forces its line to be deleted and the file can only shrink.
The current debt is 55 strings, all Italian.

Unused-key detection deliberately matches whole words over the whole source rather
than Localizer.Get("Key") alone: keys are produced in one place and resolved in
another — VideoDownloader returns a bare "SkipReasonBotCheck" and VideoId builds
"SkipReasonTooLong|{0:F0}|{1}" — and a precise pattern called all of those dead.
Erring towards "used" is the right direction; a dead-key report you cannot trust is
worse than one that occasionally misses something. That found 10 genuinely dead
keys (MessageOfTheDay, JoinOurDiscord, the per-platform cache toggles superseded by
rules, and others), now removed from all eight files.

build.sh gains --bump --lint --build --deploy --commit --push --release, plus --all
and --dry-run. They run in dependency order no matter what order they are passed,
any failure aborts the rest, and every dotnet invocation now carries -warnaserror.

--restart no longer implies a deploy. Under the obvious rule — "no action flags
selected, so fall back to the legacy build+deploy" — `./build.sh --restart` selected
nothing, fell through, and silently built, deployed and restarted the running app.
The legacy default is now keyed on there being no arguments at all, and --restart
without --deploy is refused outright: a modifier must not be able to become a deploy
on its own.
AGENTS.md collects the things that have gone wrong here more than once: the shared
config that upstream VRCVideoCacher strips keys out of, localization that fails
silently because English is the fallback, source-generated JSON that fails at
runtime rather than compile time, `ss -K` exiting 0 when it did nothing, .NET
refusing an HTTPS→HTTP redirect, loops that never linked Program.ShutdownToken,
ArgumentList vs Arguments for paths with spaces, TimeSpan normalizing instead of
throwing, and the yt-dlp-stub.exe that rebuilds non-deterministically and shows up
dirty every time. Plus the build/lint/release commands, and the style and UX rules
this fork shares with upstream so the two stay readable as one project.

--restart is gone. It killed whatever was running, relaunched through Steam and
inferred success from a five-second sleep — too blunt for something you generally
want to watch, and the flag was a hazard in its own right: it selected no action, so
it fell through to the legacy "no actions means build and deploy" default and
silently deployed. That fallback is now keyed on the argument count instead, and the
help points at `steam steam://rungameid/4296960` for starting the app by hand.

The now-unused ANY_ACTION tracking goes with it.
…-restart

GitHub Actions does not run on this account, so every push produced a failed run and
a notification. .github/workflows/ci.yml now triggers on workflow_dispatch only. It
is kept rather than deleted because it still documents what a full check is and is
one edit away from working for anyone who forks; the re-enabling snippet is in a
comment at the top.

Its work moves into build.sh. --lint already covered the build-and-test and
browser-extension jobs. The publish job becomes --artifacts, which publishes win-x64
and linux-x64 with -warnaserror and zips them into dist/. That matters beyond
packaging: Release is the only configuration that is trimmed and single-file, so it
is the only one that exercises the trimmer, and a Debug build cannot reproduce the
trimmer dropping something that only reflection reaches. Both RIDs publish clean.

--release now attaches those zips and refuses to publish without them, rather than
creating a release with no downloads in it — which is what it would have done now
that no CI job uploads anything.

Running the workflow locally under `act` was the alternative and is not worth it: it
wants a container runtime and a runner image to do what is, in the end, two dotnet
publish calls. Neither act nor docker is installed here anyway.

--stop and --start are new, with --restart as the pair, replacing the --restart that
was removed last commit. They sit either side of --deploy in the action order, since
you want the app stopped before its files are overwritten and started after. Both are
better behaved than the old flag: --stop sends SIGTERM first so the shutdown token
fires and the loops unwind, escalating to SIGKILL only after 10s, and --start polls
for up to 30s instead of sleeping 5s and declaring a crash — that fixed-sleep guess
reported a crash on every slow Steam launch. --stop is explicitly dry-run guarded, or
the wait-and-verify would fail on a process it never signalled.
…ment privileges

A release is now always the same four downloads: the win-x64 and linux-x64 zips, the
Chrome .crx and the Firefox .xpi. --release implies --artifacts so it builds them
itself rather than attaching whatever an older run happened to leave in dist/, and
--artifacts now packages the browser extensions too instead of only the application.

Both check the set is complete rather than trusting it. BrowserExtension/build.sh
skips the .crx with a warning when npx is unavailable, which would otherwise produce
a release quietly missing the Chrome download; that now aborts.

Fixed a collision this exposed: BrowserExtension/build.sh did `rm -rf` on dist/,
which is shared with the application artifacts, so whichever of the two ran second
deleted the other's output. It now clears only its own files.

Exactly the four named assets are attached, not a glob over dist/ — the extension
.zip byproducts live there too (the .xpi is a copy of the Firefox zip, the .crx is
built from chrome/), and a release listing six downloads where two duplicate two
others is just confusing.

README gains a section on why an already-playing video sometimes cannot be stopped:
closing another process's socket is privileged, `sudo setcap cap_net_admin+ep` grants
it once on Linux and must be redone after every update, polkit prompts otherwise, and
Windows cannot close IPv6 connections at any privilege level. The setcap line existed
only in a log message and in AGENTS.md until now.

Also corrects the settings section, which still described a `Plus` key and a
PlusConfig.json.bak migration — both removed when the config became a single shared
file. The translated READMEs never covered this and needed no change.
The README was three forks of accumulation read as one document: download links to
bare VRCVideoCacher.exe/VRCVideoCacher that releases no longer produce, instructions
to side-load the extension from a cloned repo folder when every release now ships a
.crx and .xpi, a "Steam app integration isn't supported yet" build-status section
with a stray unmatched </details>, and the entire FAQ folded away inside a collapsed
block labelled as belonging to somebody else's README.

Rewritten around what this fork actually is and does. Kept and corrected: how the
yt-dlp stub works, the risk answer, config location, the outbound-connection table
including the two rewrites that quietly involve a third party, the bot-detection and
clock-skew answers, and uninstall steps. Dropped everything describing software this
is no longer.

Download links now name the assets that exist. The extension section leads with the
signed store version and is honest that the PlusPlus one is unsigned and must be
side-loaded — release Firefox will not install an unsigned .xpi at all, which the old
instructions never said. Platform support says what is actually tested rather than
claiming Linux is untested when it is the development platform.

Screenshots move to the existing orphan `assets` branch and are referenced by raw
URL, so the code history carries no binaries. docs/screenshots is deleted; its three
images were the pre-fork UI and are kept on `assets` only because the four translated
READMEs still link them — those now point at the branch too. Added a note that the
translations are inherited and describe the original VRCVideoCacher, which is true
and was not stated anywhere.
…se commits

Tags here are bare versions (2026.8.21) while release titles carry the v
(v2026.8.21). build.sh tagged v${VERSION}, which would have created v2026.8.22
alongside 2026.8.21 and split the tag history in two. Both conventions are now
followed: TAG is bare, RELEASE_TITLE has the v, and the default commit message uses
the title.

--commit also does `git add -A`, so the yt-dlp-stub.exe that rebuilds
non-deterministically — identical content, different bytes — would land in every
release commit. It is now restored before committing, but only when it was already
clean at the start of the run, so a genuine change to the stub is never discarded.
`gh release create` creates a draft, uploads the assets, then publishes. A 100MB
upload is not quick, and interrupting it leaves a published-looking draft behind with
no assets — which is exactly what happened releasing 2026.8.22, and had to be
finished by hand.

The old "release already exists" guard made that unrecoverable: every retry saw the
draft, refused, and offered nothing to do about it. It now distinguishes the two
cases, resuming a draft with `gh release upload --clobber` followed by
`gh release edit --draft=false`, and only refusing when the release is genuinely
published.

It also verifies afterwards that every asset reached the "uploaded" state. gh exits
before GitHub finishes processing large files, and an asset stuck in "starting" is a
broken download link on a release that otherwise looks fine.
@codeyumx
codeyumx self-requested a review August 26, 2026 10:07
@codeyumx codeyumx self-assigned this Aug 26, 2026
@codeyumx

Copy link
Copy Markdown
Owner

I'll review this pr soon, comment if you need something!

@codeyumx
codeyumx removed their request for review August 26, 2026 11:47
@codeyumx

codeyumx commented Aug 26, 2026 •

Copy link
Copy Markdown
Owner

re: Extension key

AI response

BrowserExtension/chrome.pem is a real RSA private key, committed in plaintext, so it has to be treated as burned — anyone who's cloned this branch already has it and could sign a .crx claiming the same extension ID. We can't just keep using this key going forward.

We've already generated a replacement and stored it as a GitHub Actions secret on this repo, CHROME_EXTENSION_PEM, so it's available for the packaging step without needing to sit in the repo at all.

To pick it up:

  1. Drop chrome.pem from this PR and add BrowserExtension/chrome.pem to .gitignore.
  2. Before build.sh runs the crx3 packaging step, write the secret to that path:
    - name: Write Chrome signing key
      run: printf '%s' "${{ secrets.CHROME_EXTENSION_PEM }}" > BrowserExtension/chrome.pem
  3. build.sh itself needs no change — crx3 chrome -p chrome.pem still reads the same filename, just no longer one that's committed.

Tested this locally: crx3 signs fine with a key that's never touched git, and two builds from the same key produce a byte-identical .crx, so the ID-stability goal you were going for still holds.

@codeyumx

codeyumx commented Aug 26, 2026 •

Copy link
Copy Markdown
Owner
Inital review from AI

Reviewed this in depth — the direction is right. Replacing the per-site booleans with one regex rule engine (Cache/Block/Redirect/Rewrite/Direct) is a real architectural improvement, and the Rewrite-then-rechain design for cloud share links (Dropbox, Google Drive) is a clean way to fold link normalization into the same mechanism instead of bolting it on separately.

It's not there yet, though. The main gap: the engine is only enforced in APIController.GetVideo. VideoId.GetVideoId() evaluates the rules but only forwards MatchedRule along for integration resolution — it never checks the action. So History → Save to cache, manual Download Queue add, and startup pre-caching all reach QueueDownload without Block/Redirect ever being consulted. EvaluateUrl has four call sites right now and three of them read at most MaxResolution/MaxDurationMinutes off the result. For a feature whose headline promise is "block this video," that's the part that has to work everywhere a URL enters the pipeline, not just one of them.

Things that need fixing before this is mergeable:

  • Config migration: the old fields (BlockedUrls, BlockRedirect, CacheYouTube*, CachePyPyDance, CacheVrDancing, RedirectVRDancing) are gone from ConfigModel, unknown JSON keys are dropped silently, and PlusConfigManager.Initialize only seeds/repairs default rules. Two consequences: users' blocked URLs vanish without warning, and — worse — anyone who had set CacheVrDancing = false or CachePyPyDance = false gets caching silently turned back on by the seeded rules. An opt-out gets inverted into an opt-in.
  • Google Drive rewrite regex: ([^\/]+) in the default rule consumes query strings, so .../file/d/ABC123?usp=sharing rewrites to uc?export=download&id=ABC123?usp=sharing. Your Dropbox patterns already guard against this with [^?#]+; the Drive pattern needs the same treatment.
  • ConnectionSevering.SeverAllAsync: snapshots the tracked IP set, awaits the sever (which can sit on a polkit/UAC prompt for a while), then clears the entire set — anything tracked mid-operation is dropped without ever being severed. Only the snapshot should be cleared.
  • Shutdown logging order: the new ProcessExit handler in SetupGlobalExceptionHandlers calls Log.CloseAndFlush(), and it registers before OnAppQuit does (handlers run in registration order), so the log pipeline is closed by the time OnAppQuit runs — any failure during shutdown, e.g. the yt-dlp restore, never reaches the log. This regresses main, where OnAppQuit owns the flush.
  • ActiveStreamTracker.TryGetUrlInfo: when there's no exact key match it falls back to bidirectional Contains between URLs, first hit wins — two videos sharing a CDN path prefix can attach each other's titles/durations in Now Playing and Active Connections.
  • Housekeeping: a stray t.db SQLite binary is committed at the repo root.

Non-blocking: SchemaReconciler only backfills columns on tables that already exist and skips missing ones entirely. Nothing in this PR trips that (it adds no new tables), but it's a quiet trap for whoever adds one next — worth at least a comment or an assert in Run.

None of these are architecture-level objections — they're gaps in wiring the new engine through consistently and migrating existing configs onto it.

Given the scope (147 files, 100 commits), do you want to keep working on this over the next month?
I also see https://github.com/Bluscream/VRCVideoCacherPlusPlus/tree/main your release here - you can send PRs of improvements you add too!

I might tuck the regex Rules checklist inside or below the settings tab too.

codeyumx added a commit that referenced this pull request Sep 11, 2026
Packages chrome/ and firefox/ into dist/, and guards against the two failure modes the
separate load-unpacked targets invite: the shared files drifting apart, and the two
manifests disagreeing about the version.

Ported by file rather than by commit: on the PR it arrived split across fda80c7, 30c5ae8,
b0741ba and 05c0b59, and the other three also rewrite the fork's README, AGENTS.md and
build.sh, none of which are wanted here.

Co-authored-by: Bluscream <bluscream@users.noreply.github.com>
codeyumx added a commit that referenced this pull request Sep 11, 2026
PR #1 by Bluscream, curated from 138 commits to 111: the regex URI rules engine and its
Rules tab, rule enforcement at every point a URL enters, the site-integration refactor,
the Video Players toggle with connection severing, the VRChat log monitor with the Now
Playing card and Active Connections grid, the smaller UI work, and the upstream-quality
fixes and hardening.

Dropped: the fork's build/release plumbing and binaries, and the message-of-the-day
banner, which this fork does not ship.
codeyumx added a commit that referenced this pull request Sep 11, 2026
PR #1 by Bluscream, curated from 138 commits to 111: the regex URI rules engine and its
Rules tab, rule enforcement at every point a URL enters, the site-integration refactor,
the Video Players toggle with connection severing, the VRChat log monitor with the Now
Playing card and Active Connections grid, the smaller UI work, and the upstream-quality
fixes and hardening.

Dropped: the fork's build/release plumbing and binaries, and the message-of-the-day
banner, which this fork does not ship.
@codeyumx

codeyumx commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Thanks!
Closed, included in pre-release.

@codeyumx codeyumx closed this Sep 30, 2026
@Bluscream

Copy link
Copy Markdown
Contributor Author

i have added a notice box to my fork that its features are almost all upstream now, so theres not much need for it anymore, and i archived it, if theres anything that needs my input, just ping me !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants