Optimize stripchat.py performance with caching & improved request handling#2
Open
medi0x1 wants to merge 44 commits into
Open
Optimize stripchat.py performance with caching & improved request handling#2medi0x1 wants to merge 44 commits into
medi0x1 wants to merge 44 commits into
Conversation
Clean up code added during merge
Corrects the SC player script URL by removing a duplicated version prefix. mmpVersion already contains v, resulting in vv2.x.x/main.js → 404. Updated to v2.x.x/main.js so main.js loads properly.
Updates Stripchat JS chunk detection to match the new hashed chunk naming. Replaces the hard-coded Doppio lookup with a hash-based pattern so getInitialData() can locate the correct chunk and initialize properly again.
Fixes a regression in SC HLS playlist handling. Ensures playlist parameters are correctly applied to variant URLs, restoring proper segment resolution and ffmpeg startup behavior.
Adds support for Mouflon v2 (psch=v2) HLS playlists on SC. Implements URI-based segment decoding, including reversed encrypted segments and EXT-X-MAP init handling, while preserving existing Mouflon v1 FILE-based logic.
Added updated decryption keys to fix promotional video download issue. Changes: - Added two new decryption keys - Kept existing key for backward compatibility
SC decided to rename their api fields nd broke everything lol changed `features` → `featureSettings` so it actually works now tested: doesn't crash anymore
img.doppiocdn.com is dead for the player assets, they quietly moved everything to mmp.doppiocdn.com. Same version, different subdomain. - hardcoded origin was pointing to the old img. subdomain → 404 on main.js - updated MMPExternalSourceOrigin to mmp.doppiocdn.com one line fix, took longer to debug than to patch lol
…MMP player version from homepage
## Problem
Stripchat removed both `featuresV2` and `mmpVersion` from their static
config API (`/api/front/v3/config/static`). This caused a hard crash on
startup with:
Exception: 'featuresV2' not found. Available keys: [...]
## Root Cause
`getInitialData()` relied on `static_data["featuresV2"]["playerModuleExternalLoading"]["mmpVersion"]`
to build the MMP player base URL. That entire key hierarchy no longer
exists in the API response.
## Solution
- Read `mmp_origin` from `featureSettings.MMPExternalUnitedSourceOrigin`
(still present in the API), with a known-good CDN URL as default.
- Auto-detect `mmp_version` by scraping the stripchat.com homepage for
the MMP script src URL pattern. Falls back to a hardcoded constant
`_MMP_FALLBACK_VERSION = "v2.6.0"` if scraping fails (e.g. rate limit,
geo-block).
- Added `_MMP_FALLBACK_VERSION` class constant for easy manual updates
when the player version changes in future.
## Files Changed
- `streamonitor/sites/stripchat.py`
## Testing
Verified the static config API response no longer contains `featuresV2`
or `mmpVersion`. Confirmed `v2.6.0` is the current MMP version via
DevTools network inspection on stripchat.com.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR optimizes stripchat.py implementation to improve performance & reduce resource usage. The changes focus on reducing redundant computations, improving network efficiency, nd adding better fallback mechanisms.
Changes
Performance Improvements
Added LRU caching for frequently computed operations:
Pre-compiled regex patterns at class level instead of compiling on every use
Optimized string operations:
Improved network handling:
Better memory usage:
Robustness Improvements
Multiple fallback patterns for finding doppio.js file:
require()pattern and new chunk-based patternAutomatic proxy support from environment variables (HTTP_PROXY, HTTPS_PROXY)
Improved error handling with proper exception catching
Code Quality
Performance Impact
Testing shows significant improvements:
Compatibility
Testing
Related
This builds on the improvements from PR lossless1024#263 and PR lossless1024#264 by combining their approaches with additional optimizations.