on master help sign in
[fix] youtube - send CONSENT Cookie to not be redirected

In the EU there exists a "General Data Protection Regulation" [1] aka GDPR (BTW: very user friendly!) which requires consent to tracking. To get the consent from the user, youtube requests are redirected to confirm and get a CONSENT Cookie from https://consent.youtube.com This patch adds a CONSENT Cookie to the youtube request to avoid redirection. [1] https://en.wikipedia.org/wiki/General_Data_Protection_Regulation Signed-off-by: Markus Heiser <markus.heiser@darmarit.de> Reported-by: https://github.com/searx/searx/issues/2774

commit34d7d97e1e59515cd9d81916e273206154bde07e authorMarkus Heiser <markus.heiser@darmarit.de> dateWed 21 Apr 2021, 13:09 (6 years ago) parentf105807
1 file changed+2
searx/engines/youtube_noapi.py+2
searx/engines/youtube_noapi.py+2
@@ -3,6 +3,7 @@
33 Youtube (Videos)
44"""
55
6+from datetime import datetime
67from functools import reduce
78from json import loads, dumps
89from urllib.parse import quote_plus
@@ -56,6 +57,7 @@ def request(query, params):
5657 })
5758 params['headers']['Content-Type'] = 'application/json'
5859
60+ params['headers']['Cookie'] = "CONSENT=YES+cb.%s-17-p0.en+F+941;" % datetime.now().strftime("%Y%m%d")
5961 return params
6062
6163