Repository navigation
feat(transcribe): opt-in HuntAPI backend for URL audio downloads - #5801
Open
josselinlbe wants to merge 2 commits into
Open
josselinlbe wants to merge 2 commits into
josselinlbe wants to merge 2 commits into
Conversation
On datacenter and VPS IPs YouTube answers every yt-dlp request with "Sign in to confirm you're not a bot", so download_audio() cannot fetch audio for `graphify add <youtube-url>` there (Graphify-Labs#3049). When HUNTAPI_API_KEY is set, download_audio() submits the URL to HuntAPI, polls the job (GRAPHIFY_HUNTAPI_TIMEOUT, default 900s) and streams the finished file into the same yt_<hash>.<ext> path, size-capped and through the SSRF-guarded opener. Without the variable the yt-dlp path is unchanged. The cache check now runs before the yt-dlp import. Refs Graphify-Labs#3049 Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Graphify review 
No issues reported · High impact
When HUNTAPI_API_KEY is set, URL audio downloads use HuntAPI jobs and save the returned audio locally.
What this review covered
- We didn't review 1 file that isn't source code, such as docs, config, images, or generated or third-party code.
- 2 of 2 changed files inspected. This is scope, not a correctness guarantee.
Code graph · 428 functions depend on this change
- 2 functions became more coupled.
download_audio()(11 callers),_huntapi_save()(3 callers). - 693 of 693 test files are affected by this change.
- Gate, test list and every flagged function: in the Graphify check.
Reviewed 6d5e7b3 · 1 of 1 earlier findings resolved
nan or inf made the job-polling deadline never expire. Co-Authored-By: Claude <noreply@anthropic.com>
This branch has not been deployed
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.
What does this PR do?
Adds an opt-in download backend for
graphify add <youtube-url>and video URL transcription, for the case described in #3049: on datacenter and VPS IPs, YouTube answers every yt-dlp request with "Sign in to confirm you're not a bot", sodownload_audio()cannot get the audio at all.When
HUNTAPI_API_KEYis set,download_audio()sends the URL to HuntAPI, a hosted media download API that handles that wall. It waits for the job, then streams the finished audio file into the sameyt_<hash>.<ext>path yt-dlp would have used. Without the variable, nothing changes.urllibthroughgraphify.security._build_opener()(SSRF guard, redirect re-validation), plusvalidate_url()on the returned file URL.x-api-keyheader toapi.huntapi.com. It is never sent to the file host and never appears in errors..partfile with a 500 MB cap, then an atomic rename. Nothing is left behind on failure.videoextra to download (Whisper still does).GRAPHIFY_HUNTAPI_TIMEOUT(seconds, default 900) bounds the wait, following the module'sGRAPHIFY_WHISPER_*env convention.RuntimeErrorwith the API's message.ingest()andtranscribe_all()already report those.This complements #3050 (cookie pass-through for yt-dlp) and does not conflict with it. Cookies help when you have a logged-in browser export; this helps on servers where you don't.
Type of change
Verification & Invariants
Without
HUNTAPI_API_KEY, the yt-dlp path is byte-for-byte the same call as before (test_without_key_yt_dlp_is_used).URL validation still runs first. The file URL returned by the API goes through
validate_url(), so a private or metadata address is refused (test_file_url_on_private_host_is_blocked).The cache path and file naming are unchanged, so previously downloaded audio is still found.
No extraction output changes, so no cache schema bump.
Read the CONTRIBUTING.md guide.
Reproduced the issue and identified the invariant.
Made the smallest fix necessary.
Added a regression test (if bug fix) or isolated boundary test.
Kept the PR description synchronized with the final implementation.
Documented any limitations / unsupported cases explicitly.
Limitations: HuntAPI is a paid service; the backend is only used when the user sets the key. The generated skill references are not touched; the README's
videoextra row mentions the variable.How was this tested?
Full suite: 12525 passed. The 20 failures (
test_export.py,test_export_svg_malformed.py,test_ext_tagged_id_clash.py,test_multilang.py,test_pascal_singleton_resolution.py) and thetest_serve_reload_off_loop.pycollection error (noanyiowithout themcpextra) are identical on a cleanv8checkout in the same environment.tests/test_transcribe_huntapi.py(16 tests) fakes the opener, so no network is used andHUNTAPI_API_KEY/GRAPHIFY_HUNTAPI_TIMEOUTare cleared for every test. The new tests fail onv8without the change.Live check with a real key:
graphify.ingest.ingest("https://www.youtube.com/watch?v=Z5YP8kznWZs", ...)went through one HuntAPI job (Running, then completed) and savedyt_a2690cf3f7c0.mp3(20 MB, MP3 header checked). A second call returned the cached file without a new job.Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments.Refs #3049.