Aquí hay más resultados. Tenga en cuenta que hay muchas suposiciones en el siguiente post, basadas en la falta de conocimiento real.
Seguiré este post con mi opinión sobre lo que está sucediendo y lo que debería ocurrir.
Gracias por la respuesta, Robert.
Tenga en cuenta que la Oneboxing de videos usando la ruta /watch fallaba (¡y sigue fallando!) cuando lo intenté, por lo que no necesité un bucle para forzar el fallo.
Así que una suposición que he hecho es que el user-agent que usa Onebox es Discourse Forum Onebox v2.6.0.beta1, basado en este código…
Elegí un video al azar e intenté usar curl para leer las cabeceras.
Lo hice desde dentro del contenedor Docker en mi sitio en vivo, lo que produjo la siguiente respuesta.
Resultado del primer curl usando la ruta /watch?
comando
curl --user-agent "Discourse Forum Onebox v2.6.0.beta1" -sD - -o /dev/null "https://m.youtube.com/watch?v=s0ONj4TG0UA"
respuesta:
curl --user-agent "Discourse Forum Onebox v2.6.0.beta1" -sD - -o /dev/null "https://m.youtube.com/watch?v=s0ONj4TG0UA"
HTTP/2 303
content-length: 0
p3p: CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en-GB for more info."
cache-control: no-cache
x-frame-options: SAMEORIGIN
content-type: text/html; charset=utf-8
location: https://www.youtube.com/watch?v=s0ONj4TG0UA&app=desktop
accept-ch-lifetime: 2592000
x-content-type-options: nosniff
accept-ch: DPR
expires: Tue, 27 Apr 1971 19:44:06 GMT
strict-transport-security: max-age=31536000
date: Fri, 07 Aug 2020 11:35:21 GMT
server: YouTube Frontend Proxy
x-xss-protection: 0
set-cookie: VISITOR_INFO1_LIVE=rcVTSJn81Ck; path=/; domain=.youtube.com; secure; expires=Wed, 03-Feb-2021 11:35:20 GMT; httponly; samesite=None
set-cookie: YSC=cFXIPerzT3Y; path=/; domain=.youtube.com; secure; httponly; samesite=None
set-cookie: GPS=1; path=/; domain=.youtube.com; expires=Fri, 07-Aug-2020 12:05:20 GMT
alt-svc: h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Así que fui redirigido con una respuesta 303 a la URL en la cabecera location, que era https://www.youtube.com/watch?v=s0ONj4TG0UA&app=desktop.
Esto simplemente tuvo el efecto de añadir &app=desktop a la URL.
Resultado del segundo curl a la URL redirigida - aún en la ruta /watch?
comando
curl --user-agent "Discourse Forum Onebox v2.6.0.beta1" -sD - -o /dev/null "https://www.youtube.com/watch?v=s0ONj4TG0UA&app=desktop"
respuesta
HTTP/2 429
x-content-type-options: nosniff
expires: Tue, 27 Apr 1971 19:44:06 GMT
x-frame-options: SAMEORIGIN
cache-control: no-cache
p3p: CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en-GB for more info."
accept-ch-lifetime: 2592000
content-type: text/html; charset=utf-8
accept-ch: DPR
strict-transport-security: max-age=31536000
content-length: 48982
date: Fri, 07 Aug 2020 11:46:00 GMT
server: YouTube Frontend Proxy
x-xss-protection: 0
set-cookie: VISITOR_INFO1_LIVE=VQwNuouhq-s; path=/; domain=.youtube.com; secure; expires=Wed, 03-Feb-2021 11:46:00 GMT; httponly; samesite=None
set-cookie: YSC=8IRfPRFRY6c; path=/; domain=.youtube.com; secure; httponly; samesite=None
set-cookie: GPS=1; path=/; domain=.youtube.com; expires=Fri, 07-Aug-2020 12:16:00 GMT
set-cookie: VISITOR_INFO1_LIVE=VQwNuouhq-s; path=/; domain=.youtube.com; secure; expires=Wed, 03-Feb-2021 11:46:00 GMT; httponly; samesite=None
set-cookie: YSC=8IRfPRFRY6c; path=/; domain=.youtube.com; secure; httponly; samesite=None
set-cookie: GPS=1; path=/; domain=.youtube.com; expires=Fri, 07-Aug-2020 12:16:00 GMT
alt-svc: h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Así que me están enviando un código de respuesta 429 “demasiadas solicitudes”, pero sin enviar una cabecera retry-after — cesar y desistir sin negociación.
De cualquier manera, si esto es lo que está viendo Onebox, está ignorando la respuesta o, al menos, no sé dónde buscar si se está registrando.
Aunque esto podría ser algo legítimo de hacer para un único 429, ver muchas respuestas 429 en un período de tiempo muy corto no puede ser ignorado.
Resultado del tercer curl - esta vez usando la ruta /embed/
Para completar, intenté inmediatamente obtener el mismo video, pero esta vez usando la ruta /embed/.
comando
curl --user-agent "Discourse Forum Onebox v2.6.0.beta1" -sD - -o /dev/null "https://www.youtube.com/embed/s0ONj4TG0UA"
respuesta
HTTP/2 200
accept-ch-lifetime: 2592000
content-type: text/html; charset=utf-8
expires: Tue, 27 Apr 1971 19:44:06 GMT
x-content-type-options: nosniff
cache-control: no-cache
p3p: CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en-GB for more info."
strict-transport-security: max-age=31536000
accept-ch: DPR
date: Fri, 07 Aug 2020 11:55:29 GMT
server: YouTube Frontend Proxy
x-xss-protection: 0
set-cookie: VISITOR_INFO1_LIVE=PNE6x6djF00; path=/; domain=.youtube.com; secure; expires=Wed, 03-Feb-2021 11:55:29 GMT; httponly; samesite=None
set-cookie: VISITOR_INFO1_LIVE=PNE6x6djF00; path=/; domain=.youtube.com; secure; expires=Wed, 03-Feb-2021 11:55:29 GMT; httponly; samesite=None
set-cookie: GPS=1; path=/; domain=.youtube.com; expires=Fri, 07-Aug-2020 12:25:29 GMT
set-cookie: YSC=pDW-hdbauK8; path=/; domain=.youtube.com; secure; httponly; samesite=None
alt-svc: h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
accept-ranges: none
vary: Accept-Encoding
200 - Éxito.
El plugin lazy-yt parece reescribir las URLs en formato /watch
No estoy seguro de si esto es de alguna significancia, pero… ¿el plugin incrustado lazy-yt está habilitado por defecto? Lo noté en mi instalación de desarrollo.
Parece que hace un monkey patch al método to_html del Oneboxer de YouTube.
No sé si es significativo, pero el método to_html del Onebox original devuelve el formato de URL /embed/…
Mientras que el plugin lazy-yt usa el formato de URL /watch?v=.
¿Hay algo más que pueda hacer para mostrar que hay un problema que necesita alguna forma de atención? El siguiente post explicará lo que creo que es la causa raíz.