Skip to content

Retry on 429 never rotates IP for InnerTube POST (urllib3 Retry excludes POST by default) #612

Description

@chirag127

Problem

retries_when_blocked never triggers IP rotation on the InnerTube POST endpoint because urllib3's Retry default allowed_methods excludes POST.

Read cite

youtube_transcript_api/_api.py:43-48:

retry_config = Retry(
    total=proxy_config.retries_when_blocked,
    status_forcelist=[429],
)

No allowed_methods set. urllib3 Retry.DEFAULT_ALLOWED_METHODS = {HEAD, GET, PUT, DELETE, OPTIONS, TRACE} — POST omitted.

youtube_transcript_api/_transcripts.py:446 issues self._http_client.post(INNERTUBE_API_URL...). When YouTube returns 429 on this POST, Retry skips it; connection is not closed, IP not rotated, IpBlocked raised on first hit.

Expected

With WebshareProxyConfig (default retries_when_blocked=10), a 429 on the InnerTube POST triggers up to 10 retries with fresh TCP connections (rotating IPs).

Actual

Single attempt, then IpBlocked. Only the GET /watch and GET /api/timedtext paths benefit from retries.

Fix sketch

retry_config = Retry(
    total=proxy_config.retries_when_blocked,
    status_forcelist=[429],
    allowed_methods=frozenset({"HEAD", "GET", "PUT", "DELETE", "OPTIONS", "TRACE", "POST"}),
)

Environment

youtube-transcript-api 1.2.4 (pyproject.toml), requests *, Python 3.8-3.14.

Thanks for maintaining jdepoix/youtube-transcript-api!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions