fix: sync real browser UA headers and resolve video CDN via redirect#148
Open
iloverabbit wants to merge 4 commits into
Open
fix: sync real browser UA headers and resolve video CDN via redirect#148iloverabbit wants to merge 4 commits into
iloverabbit wants to merge 4 commits into
Conversation
… using captcha_method personal
…al User-Agent from browser instances
Author
|
disclaimer: AI assisted both code and the pr content + pr translation |
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.
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。