[FIX] website_slides: embed YouTube videos without cookies
Due to recent legal changes in EU, you cannot install tracking cookies in a user's browser without explicit consent. Before this patch, Odoo embedded youtube videos were violating that law (AFAIK & IANAL). With this simple patch, you benefit from YouTube's offering to embed videos without cookies. The UI remains the same, but no tracking is done. @Tecnativa TT26153 closes odoo/odoo#61828 X-original-commit: a1a1169f28233b69cd70d01621d605b36517ac73 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
committed by
Thibault Delavallée
parent
f0232808c2
commit
012eec250a
@@ -345,7 +345,7 @@ class Slide(models.Model):
|
||||
# embed youtube video
|
||||
query = urls.url_parse(record.url).query
|
||||
query = query + '&theme=light' if query else 'theme=light'
|
||||
record.embed_code = '<iframe src="//www.youtube.com/embed/%s?%s" allowFullScreen="true" frameborder="0"></iframe>' % (record.document_id, query)
|
||||
record.embed_code = '<iframe src="//www.youtube-nocookie.com/embed/%s?%s" allowFullScreen="true" frameborder="0"></iframe>' % (record.document_id, query)
|
||||
else:
|
||||
# embed google doc video
|
||||
record.embed_code = '<iframe src="//drive.google.com/file/d/%s/preview" allowFullScreen="true" frameborder="0"></iframe>' % (record.document_id)
|
||||
@@ -740,7 +740,7 @@ class Slide(models.Model):
|
||||
url_obj = urls.url_parse(url)
|
||||
if url_obj.ascii_host == 'youtu.be':
|
||||
return ('youtube', url_obj.path[1:] if url_obj.path else False)
|
||||
elif url_obj.ascii_host in ('youtube.com', 'www.youtube.com', 'm.youtube.com'):
|
||||
elif url_obj.ascii_host in ('youtube.com', 'www.youtube.com', 'm.youtube.com', 'www.youtube-nocookie.com'):
|
||||
v_query_value = url_obj.decode_query().get('v')
|
||||
if v_query_value:
|
||||
return ('youtube', v_query_value)
|
||||
|
||||
@@ -183,7 +183,8 @@ class TestFromURL(slides_common.SlidesCase):
|
||||
'hlhLv0GN1hA': [
|
||||
'https://www.youtube.com/v/hlhLv0GN1hA',
|
||||
'https://www.youtube.com/embed/hlhLv0GN1hA',
|
||||
'https://m.youtube.com/watch?v=hlhLv0GN1hA'
|
||||
'https://www.youtube-nocookie.com/embed/hlhLv0GN1hA',
|
||||
'https://m.youtube.com/watch?v=hlhLv0GN1hA',
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user