fix(autopilot): send the YouTube consent cookie when checking for Shorts
From the EU prod servers every /shorts/<id> HEAD is first a 302 to consent.youtube.com, which read as 'not a Short' and let a 53 s Short through to the pipeline. With SOCS/CONSENT set, a Short answers 200 and a regular video 303 to /watch (checked from the prod container). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8f57560fa5
commit
b7b5e95e7c
2 changed files with 8 additions and 4 deletions
|
|
@ -379,7 +379,7 @@ on their socials, one a day. Paid plans only (it spends minutes unattended).
|
||||||
clips the back catalogue) and at most 3 days old; 1 automatic job per user
|
clips the back catalogue) and at most 3 days old; 1 automatic job per user
|
||||||
per 24 h; `max_minutes` per video (default 30, sent as the partial-clip
|
per 24 h; `max_minutes` per video (default 30, sent as the partial-clip
|
||||||
`max_minutes`); YouTube Shorts are skipped (`HEAD /shorts/<id>` answers 200
|
`max_minutes`); YouTube Shorts are skipped (`HEAD /shorts/<id>` answers 200
|
||||||
for a Short and 303 to `/watch` for a regular video, checked on prod IPs).
|
for a Short and 303 to `/watch` for a regular video; the SOCS consent cookie is required, from the EU servers every request is otherwise a 302 to consent.youtube.com).
|
||||||
- **Dedupe across the deploy handover**: two containers poll at once during a
|
- **Dedupe across the deploy handover**: two containers poll at once during a
|
||||||
rolling deploy, so a video is claimed by INSERTing its `autopilot_runs` row
|
rolling deploy, so a video is claimed by INSERTing its `autopilot_runs` row
|
||||||
(unique `user_id, video_id`) before anything is submitted. A draining
|
(unique `user_id, video_id`) before anything is submitted. A draining
|
||||||
|
|
|
||||||
|
|
@ -265,11 +265,15 @@ async def is_youtube_short(video_id: str) -> bool:
|
||||||
"""True when YouTube serves this id as a Short.
|
"""True when YouTube serves this id as a Short.
|
||||||
|
|
||||||
``/shorts/<id>`` answers 200 for a Short and redirects to ``/watch`` for a
|
``/shorts/<id>`` answers 200 for a Short and redirects to ``/watch`` for a
|
||||||
regular video. Any other answer (a consent page, a bot check) reads as
|
regular video. From the prod servers (EU) YouTube first redirects every
|
||||||
"not a Short" and the normal pipeline's own too-short gate still applies.
|
request to consent.youtube.com, which read as "not a Short" and let a Short
|
||||||
|
through (22-sep-2026); the SOCS/CONSENT cookies skip that page. Any other
|
||||||
|
answer (a bot check) still reads as "not a Short" and the normal
|
||||||
|
pipeline's own too-short gate applies.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
async with httpx.AsyncClient(timeout=10, follow_redirects=False) as client:
|
async with httpx.AsyncClient(timeout=10, follow_redirects=False,
|
||||||
|
cookies={"SOCS": "CAI", "CONSENT": "YES+"}) as client:
|
||||||
resp = await client.head(f"https://www.youtube.com/shorts/{video_id}")
|
resp = await client.head(f"https://www.youtube.com/shorts/{video_id}")
|
||||||
return resp.status_code == 200
|
return resp.status_code == 200
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue