Skip to content

fix: sync real browser UA headers and resolve video CDN via redirect#148

Open
iloverabbit wants to merge 4 commits into
TheSmallHanCat:mainfrom
iloverabbit:main
Open

fix: sync real browser UA headers and resolve video CDN via redirect#148
iloverabbit wants to merge 4 commits into
TheSmallHanCat:mainfrom
iloverabbit:main

Conversation

@iloverabbit
Copy link
Copy Markdown

@iloverabbit iloverabbit commented May 20, 2026

fix: 同步真实浏览器 UA 请求头并通过重定向解析视频 CDN

TL;DR make getting result of video generation fallback to new api route. And make the api request have consistency user agent if using captcha=personal

同步真实浏览器 UA 的平台请求头 (captcha_method=personal)

当使用个人验证码方法(personal captcha method)时,请求头(Request headers)现已改从实际运行的浏览器中获取,而不是使用硬编码的 macOS Chrome 配置档案(Profile)。这保证了客户端请求头与真实浏览器发送的内容一致,从而减少因请求头不匹配(Header mismatch)导致的上游 4xx/5xx 拒绝报错。

BrowserCaptchaService_PersonalBrowserPoolService 中新增了 get_current_user_agent() 方法。该方法会优先解析初始化时构建的运行时表面配置(Runtime surface profile)中的 UA,如果解析失败,则会降级使用实时的 CDP(Chrome DevTools Protocol)查询。

通过重定向接口获取真实的视频 CDN URL

新的 Flow schema 不再直接在视频状态响应中返回 fifeUrl。为此,我们在 FlowClient 中新增了 get_media_url_redirect() 方法,该方法会携带会话令牌(Session token)和媒体名称(Media name)请求 labs.google 上的 /trpc/media.getMediaUrlRedirect,接着读取 302 状态码中的 Location 请求头,并返回真实的 CDN URL。通过设置 allow_redirects=False,使其在触发重定向时即停止,而不是继续跟随重定向。此外,该功能也支持通过现有的代理管理器(Proxy manager)来使用代理。

当返回的 video_url 为空但存在 mediaName 时,处理器(Handler)现在会在判定失败前,先调用 get_media_url_redirect() 来解析出真实的 URL。

@iloverabbit
Copy link
Copy Markdown
Author

disclaimer: AI assisted both code and the pr content + pr translation

@iloverabbit iloverabbit changed the title feat: sync real browser UA headers and resolve video CDN via redirect fix: sync real browser UA headers and resolve video CDN via redirect May 21, 2026
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.

1 participant