Skip to content

Commit

Permalink
[fix] youtube - send CONSENT Cookie to not be redirected
Browse files Browse the repository at this point in the history
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: searx/searx#2774
  • Loading branch information
return42 committed Apr 22, 2021
1 parent f251a97 commit e9a6ab4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions searx/engines/youtube_noapi.py
Expand Up @@ -3,6 +3,7 @@
Youtube (Videos)
"""

from datetime import datetime
from functools import reduce
from json import loads, dumps
from urllib.parse import quote_plus
Expand Down Expand Up @@ -56,6 +57,7 @@ def request(query, params):
})
params['headers']['Content-Type'] = 'application/json'

params['headers']['Cookie'] = "CONSENT=YES+cb.%s-17-p0.en+F+941;" % datetime.now().strftime("%Y%m%d")
return params


Expand Down

0 comments on commit e9a6ab4

Please sign in to comment.