Ecco alcuni risultati aggiuntivi. Nota che ci sono molte ipotesi nel post qui sotto, basate su una mancanza di conoscenze reali.
Farò seguito a questo post con la mia opinione su ciò che sta succedendo e su cosa dovrebbe accadere.
Grazie per la risposta, Robert.
Nota che l’Oneboxing dei video tramite la rotta /watch falliva (e fallisce ancora!) quando ho provato, quindi non ho avuto bisogno di un ciclo per forzare il fallimento.
Quindi un’ipotesi che ho fatto è che lo user-agent utilizzato da Onebox sia Discourse Forum Onebox v2.6.0.beta1, basandomi su questo codice…
Ho scelto un video a caso e ho provato a usare curl per leggere le intestazioni.
L’ho fatto all’interno del contenitore Docker del mio sito in produzione, ottenendo la seguente risposta.
Risultato del primo curl con la rotta /watch?
comando
curl --user-agent "Discourse Forum Onebox v2.6.0.beta1" -sD - -o /dev/null "https://m.youtube.com/watch?v=s0ONj4TG0UA"
risposta:
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"
Quindi sono stato reindirizzato con una risposta 303 all’URL presente nell’intestazione location, ovvero https://www.youtube.com/watch?v=s0ONj4TG0UA&app=desktop.
Questo ha semplicemente avuto l’effetto di aggiungere &app=desktop all’URL.
Risultato del secondo curl all’URL reindirizzato - ancora sulla rotta /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"
risposta
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"
Quindi ricevo un codice di risposta 429 “troppe richieste”, ma senza ricevere un’intestazione retry-after: cessate e desistete senza negoziare.
In ogni caso, se è questo che Onebox sta vedendo, sta ignorando la risposta o almeno non so dove cercare se viene registrata.
Anche se questo potrebbe essere un comportamento legittimo per un singolo 429, vedere molte risposte 429 in un periodo di tempo molto breve non può essere ignorato.
Risultato del terzo curl - questa volta usando la rotta /embed/
Per completezza, ho immediatamente provato a ottenere lo stesso video, ma questa volta usando la rotta /embed/.
comando
curl --user-agent "Discourse Forum Onebox v2.6.0.beta1" -sD - -o /dev/null "https://www.youtube.com/embed/s0ONj4TG0UA"
risposta
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 - Successo.
Il plugin lazy-yt sembra riscrivere gli URL nel formato /watch
Non sono sicuro che abbia alcuna rilevanza, ma… il plugin embedded lazy-yt è abilitato per impostazione predefinita? L’ho notato nella mia installazione di sviluppo.
Sembra fare monkey patching del metodo to_html dell’Oneboxer di YouTube.
Non so se sia significativo, ma il metodo to_html dell’Onebox originale restituisce il formato URL /embed/…
Mentre il plugin lazy-yt utilizza il formato URL /watch?v=.
C’è qualcos’altro che posso fare per dimostrare che c’è un problema che richiede qualche forma di intervento? Nel prossimo post spiegherò quale ritengo sia la causa principale.