Hongguo Short Drama & Douyin/TikTok Video API Tricks & Decryption Skill
1. Hongguo Short Drama (红果免费短剧 / Fanqie) Input Resolution
- Short Share Links (
novelquickapp.com/s/...,changdunovel.com) :- Send a
GETrequest withredirect: "manual"and mobile User-Agent. - Parse the
Locationheader query string forvideo_series_id,series_id,book_id,album_id,group_id,item_id, orvid(19-digit numeric IDs).
- Send a
- Official Web Links (
hongguoduanju.com) :- Series page:
https://hongguoduanju.com/detail?series_id={19_digit_id} - Episode player page:
https://hongguoduanju.com/player/{series_id}/{vid}
- Series page:
2. Trick #1: Bypassing X-Gorgon via Official Fqnovel App Preload Mirrors
Standard Fqnovel/Hongguo mobile endpoints enforce ByteDance X-Gorgon / X-Argus signatures. However, the Preload v1 endpoints across 6 official mirrors accept unauthenticated POST requests when passed the standard Android preload query parameters and "dr_scene": "preload":
- 6 Active Mirrors:
https://api5-normal-sinfonlineb.fqnovel.comhttps://api5-normal-sinfonlinea.fqnovel.comhttps://api5-normal-sinfonlinec.fqnovel.comhttps://api5-normal-lf.fqnovel.comhttps://api5-normal-lq.fqnovel.comhttps://api5-normal-hl.fqnovel.com
- Required Query String (
COMMON_APP_QUERY) :klink_egdi=AAI29o4dI-eMiO73_SRSbZ_0By1v3fUSriNeu8-L951MoXhWT88pzj5B&iid=3788260546453235&device_id=538083340353620&ac=wifi&channel=oppo_8662_64&aid=8662&app_name=novelread&version_code=71532&version_name=7.1.5.32&device_platform=android&os=android&ssmix=a&device_type=SM-N9860&device_brand=Samsung&language=zh&os_api=28&os_version=9&manifest_version_code=71532&resolution=900*1600&dpi=320&update_version_code=71532&host_abi=arm64-v8a&dragon_device_type=pad&pv_player=71532&compliance_status=0&need_personal_recommend=1&player_so_load=1&is_android_pad_screen=0 - Required Headers:
User-Agent:com.phoenix.read/71532 (Linux; U; Android 9; SM-N9860; Build/PQ3A.190705.10241111;tt-ok/3.12.13.20)Referer:https://novelquickapp.com/
- Endpoint A — Full Series Metadata & Episode List:
- Path:
POST /novel/player/multi_video_detail/preload/v1?{COMMON_APP_QUERY} - JSON Body:
{ "biz_param": { "detail_page_version": 0, "disable_digg_stat": false, "need_all_video_definition": false, "need_mp4_align": false, "screen_width_px": "900", "source": 7, "use_os_player": false, "use_server_dns": false }, "dr_scene": "preload", "series_id": "7588802892412406808" } - Returns:
data[series_id].video_data(series_title,series_cover,series_intro,episode_cnt,celebrities, andvideo_listcontaining all episodevid,vid_index,duration).
- Path:
- Endpoint B — Multi-Resolution Video Streams &
spade_aKeys:- Path:
POST /novel/player/multi_video_model/preload/v1?{COMMON_APP_QUERY} - JSON Body:
{ "biz_param": { "detail_page_version": 0, "device_level": 3, "disable_digg_stat": false, "need_all_video_definition": true, "need_mp4_align": false, "use_os_player": false, "use_server_dns": false, "video_platform": 1024 }, "dr_scene": "preload", "mixed_video_id_map": { "1004": ["7588804476701690904"] } } - Returns:
data[vid].video_model(JSON string). Insidevideo_list(video_1tovideo_5), each item containsdefinition(360p..1080p),main_url,backup_url,encrypt_info.spade_a, plusfallback_api(https://vas-lf-x.snssdk.com/video/fplay/1/...).
- Path:
3. Trick #2: Hongguo Official Web SSR (window._ROUTER_DATA) & Direct H.264 Stream
- Extracting
window._ROUTER_DATA:- Fetch
https://hongguoduanju.com/pages with standard Desktop Browser UA:- Trending/Home:
https://hongguoduanju.com/(loaderData.page.homeSections) - Category pages:
https://hongguoduanju.com/category/{real-drama|comic-drama|ai-drama}(loaderData.category_page.recommendList) - Keyword Search:
https://hongguoduanju.com/search/{encodeURIComponent(keyword)}(loaderData["search_(keyword)/page"].searchList) - Series Detail:
https://hongguoduanju.com/detail?series_id={seriesId}(seriesDetail.vid_list)
- Trending/Home:
- Extract the JSON assigned to
_ROUTER_DATAvia brace-balanced parsing starting at the first{after_ROUTER_DATA.
- Fetch
- Unencrypted H.264 Stream (
360p-h264) :- Every episode
vidhas a direct unencrypted H.264/AAC MP4 endpoint:https://hongguoduanju.com/video/public/{vid}/360p.mp4 - Must be fetched with header
Referer: https://hongguoduanju.com/. - Use this stream for instant
<video>preview in browsers (since browsers cannot natively play CENC-encryptedencvstreams without EME/MSE).
- Every episode
4. Trick #3: spade_a Key Derivation & Fast WebCrypto CENC-AES-128-CTR Decryption
spade_ato 16-Byte AES Key (key_hex—libttmplayer.soalgorithm) :- Base64-decode
spade_aintobuf(L = buf.length). - Compute
key0 = buf[0] ^ buf[1] ^ buf[2],x27 = key0 - 0x30,w22 = L - key0 + 0x2f. - Slice
x21 = buf.slice(1, 1 + w22). Initializew11 = 0x55,w12 = 0xfa,w10 = 0xeb. - For each index
i, compute popcountpc = popcount(i),w14 = (i & 1) === 0 ? w12 : w11, updatew11/w12withx21[i], and setx21[i] = ((w10 - pc) + (w14 ^ x21[i])) & 0xff. - Decode base36 digit
hvalfromx21[0], computew9 = w22 - hval, and extract ASCII hex stringx21.slice(1, w9)(32 hex chars = 16-byte AES key).
- Base64-decode
- Decrypting ISO-BMFF
cencMP4 (encv->hvc1,enca->mp4a) :- Locate
moovbox and iterate over eachtrak -> mdia -> minf -> stbl:- Parse
stsz(sample sizes),stsc(sample-to-chunk),stco(chunk offsets), andsenc(8-byte IV per sample atsenc.off + 16 + i * 8). - Zero-pad each 8-byte IV into a 16-byte AES-CTR counter block (
counter[0..7] = iv8,counter[8..15] = 0) and decrypt each sample withcrypto.subtle.decrypt({ name: "AES-CTR", counter, length: 64 }, cryptoKey, sampleSlice).
- Parse
- Rebuild
moov:- Rename
encv->hvc1,enca->mp4a, removesinf,senc,saio,saizboxes, and subtractdelta = oldMoovSize - newMoovSizefrom every offset instcothat followsmoov(or overwritesinf/senc/saio/saizin-place withfreeboxes to keepmoovsize constant).
- Rename
- Locate
5. Trick #4: Cloudflare Free Tier 10ms CPU Bypass & Multi-Provider Douyin Rotation
- Hybrid Client + Server Decryption:
- On Cloudflare Free Tier (10ms CPU limit), expose
/api/download?url=...&raw=1(streaming passthrough withReferer: https://novelquickapp.com/). - Perform
CENC-AES-128-CTRdecryption in the browser viawindow.HongguoClientDecryptorusing hardware-accelerated WebCrypto (0ms Worker CPU cost), while keeping server-side decryption in/api/downloadand Pythonapp.py(Render.com withpycryptodome) as fallback.
- On Cloudflare Free Tier (10ms CPU limit), expose
- Douyin / TikTok Multi-Provider Failover:
- Primary:
TikWM(https://www.tikwm.com/api/,POST url=...&hd=1) — no cooldown. - Fallback:
Apihz4 routes (https://cn.apihz.cn/api/fun/douyin.php+ 3 HTTP IP mirrors proxied server-side via Cloudflare Worker to avoid browser HTTPS Mixed-Content blocking). - Note:
api.cenguigui.cn/api/duanju.htmlis deprecated (HTTP 404); keep only as last-resort fallback.
- Primary:
6. Trick #5: Cloudflare Free "Max Ping" & Quota Optimization Runbook
To achieve <2ms Edge delivery, zero CPU overruns, and prevent burning the 100,000/day Cloudflare Free Worker invocation quota:
- Static Asset Quota Bypass (
public/_routes.json) :- Use
"include": ["/api/*"]and"exclude": ["/", "/index.html", "/articles.js", "/ads.txt", "/robots.txt", "/sitemap.xml", "/favicon.svg"]. - Result: Static files are served directly by Cloudflare CDN at Edge PoPs (~5ms ping) and consume zero Worker invocations.
- Use
- Singleflight Request Coalescing (
INFLIGHT_MAP) :- Coalesce concurrent incoming requests for the same series, episode, or category into a single Promise. Downstream requests await the existing inflight fetch, preventing duplicate upstream calls.
- Stale-While-Revalidate (SWR) in V8 Isolate RAM:
- Cache parsed JSON in module-level
MEM_CACHE. If a request arrives after soft TTL expires but within hard TTL (3x), return cached data instantly (0.0ms) and trigger an asynchronous background refresh viactx.waitUntil.
- Cache parsed JSON in module-level
- Adaptive Mirror Latency Scoreboard (EMA Tracker + Hedging) :
- Continually measure RTT across all 6 Fqnovel preload mirrors (
sinfonlineb,sinfonlinea,sinfonlinec,lf,lq,hl). - Dynamically sort mirrors by lowest EMA latency and hedge upstream requests with a
650msparallel timeout.
- Continually measure RTT across all 6 Fqnovel preload mirrors (
- 15-Episode Single-Request Batching:
- Fqnovel's
/novel/player/multi_video_model/preload/v1accepts up to 15 VIDs inmixed_video_id_map: { "1004": [vid1, vid2, ... vid15] }. - Prefetch 15 episodes on the initial
/api/parsecall and during batch downloads via/api/episode?vids=...&indices=..., cutting 93% of API roundtrips.
- Fqnovel's
- Smart Placement (
wrangler.toml) :- Specify
[placement] mode = "smart"so Cloudflare executes Workers at Edge datacenters near ByteDance/Hongguo Asian upstreams, reducing multi-hop network latency by 40-70%.
- Specify
- Edge Cache API (
caches.default) :- Cache cover images (
/api/proxy) for 30 days (immutable) and small decrypted MP4s (<= 20MB) for 1-2 hours so repeated requests and range requests serve directly from Edge RAM.
- Cache cover images (
7. Trick #6: Direct ByteDance CDN Offloading (Zero Bandwidth & 0ms CPU Cost)
- Upstream CORS Header Discovery:
- Both
*.qznovelvod.com(ByteDance VOD CDN for 1080p CENC MP4) and*.byteimg.com(cover image CDN) returnHTTP 200with header:Access-Control-Allow-Origin: *when requested without aRefererheader (referrerPolicy: "no-referrer").
- Both
- Client-Side Direct Fetching:
- In browser frontend, fetch raw MP4 bytes directly via:
fetch(rawVideoUrl, { referrerPolicy: "no-referrer" })and only fall back to/api/download?url=...&raw=1if CORS fails. - For images, use
<img src="direct_byteimg_url" referrerpolicy="no-referrer" onerror="this.src='/api/proxy?url=...'"/>. - Benefit: 100% of video bandwidth and 99% of image requests bypass Cloudflare Workers entirely, saving thousands of worker invocations and bandwidth limits on Cloudflare Free.
- In browser frontend, fetch raw MP4 bytes directly via:
8. Trick #7: Hybrid 4.1x T-Table + WebCrypto AES-128-CTR Decryption Engine
- Sample Distribution in 1080p CENC MP4:
- In ISO-BMFF CENC MP4 streams, 94.2% of samples are $\le 2048$ bytes (audio frames and P/B video slices). Only ~5.8% (large I-frames) exceed 2048 bytes.
- Calling
crypto.subtle.decryptfor 12,000+ tiny samples creates 12,000+ Promise allocations, causing severe event-loop overhead and hitting Cloudflare Worker 10ms CPU limits (Error 1102).
- Hybrid Solution:
- Precompute 32-bit AES T-tables (
AES_TE0..TE3,AES_SBOX). - Decrypt all samples $\le 2048$ bytes synchronously in-place (0 Promise allocation, 0 GC).
- Dispatch only large I-frames ($> 2048$ bytes) to hardware-accelerated
crypto.subtle.decrypt. - Result: Decryption time drops from 395.6ms to 95.7ms (4.1x faster), Promise allocations drop by 94.2%.
- Precompute 32-bit AES T-tables (
- Browser Inline Web Worker:
- Run the decryptor inside an inline
BlobWeb Worker with zero-copyTransferableArrayBuffer(postMessage(..., [u8.buffer])). - Ensures 0ms UI freeze on the browser main thread during multi-episode batch downloading.
- Run the decryptor inside an inline
9. Trick #8: Douyin / TikTok Multi-Provider Rotation & Cooldown Bypass
- Apihz 30s Cooldown:
- Free Apihz accounts enforce a strict 30s rate-limit (
该接口免费用户限制30秒解析1次). - Primary Route: Must use HTTPS
https://cn.apihz.cn/api/fun/douyin.php(raw IPs like101.35.2.25fail across firewalls). - Two-Tier Cache: Cache parsed Douyin responses for 30 minutes (
getOrSetCache(cacheKey, 1800, ...)) using canonicalaweme_idor resolved URL. Subsequent hits return in $<1\text{ms}$ and bypass the 30s rate limit completely.
- Free Apihz accounts enforce a strict 30s rate-limit (
- TikWM & Native SSR Hedged Fallback:
- Resolve
v.douyin.comwithredirect: "manual"in ~200ms to get canonicalaweme_id. - Race Apihz (primary) with TikWM and Native SSR backups using
raceWithHedge(primary, backups, 1200).
- Resolve