Skip to content
Snippets Groups Projects
Commit 32f68f75 authored by Pavel Dmitriev's avatar Pavel Dmitriev
Browse files

[PATCH] youtube.lua: disable cookies if redirected to consent page

parent c8c52d52
No related branches found
No related tags found
No related merge requests found
Pipeline #103238 passed with stage
in 15 minutes and 32 seconds
From f26577f12c20f63bb698255ac03ffd3eaa4700cc Mon Sep 17 00:00:00 2001
Message-Id: <f26577f12c20f63bb698255ac03ffd3eaa4700cc.1622540062.git.dantalian.pv@gmail.com>
From: Pierre Ynard <linkfanel@yahoo.fr>
Date: Sat, 3 Apr 2021 12:02:34 +0200
Subject: [PATCH] youtube.lua: disable cookies if redirected to consent page
In the past few days, YouTube has started redirecting requests for video
pages to a cookie consent and preference prompt, on a whole separate
page and domain; which prevents playback. We are not interested in
YouTube cookies, nor in consenting to them on behalf of our users, so
this just retries with cookies disabled. YouTube gets the hint and
simply redirects back to the original video page.
Fixes #25616
(cherry picked from commit f21c063ea3b8050541e5c8f4430378dfec85f4a5)
Signed-off-by: Pierre Ynard <linkfanel@yahoo.fr>
---
share/lua/playlist/youtube.lua | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/share/lua/playlist/youtube.lua b/share/lua/playlist/youtube.lua
index f8a8937387..65c81514d1 100644
--- a/share/lua/playlist/youtube.lua
+++ b/share/lua/playlist/youtube.lua
@@ -303,8 +303,8 @@ end
-- Probe function.
function probe()
- return ( ( vlc.access == "http" or vlc.access == "https" )
- and (
+ return ( ( vlc.access == "http" or vlc.access == "https" ) and (
+ ((
string.match( vlc.path, "^www%.youtube%.com/" )
or string.match( vlc.path, "^music%.youtube%.com/" )
or string.match( vlc.path, "^gaming%.youtube%.com/" ) -- out of use
@@ -315,14 +315,27 @@ function probe()
or string.match( vlc.path, "/get_video_info%?" ) -- info API
or string.match( vlc.path, "/v/" ) -- video in swf player
or string.match( vlc.path, "/embed/" ) -- embedded player iframe
- ) )
+ )) or
+ string.match( vlc.path, "^consent%.youtube%.com/" )
+ ) )
end
-- Parse function.
function parse()
- if not string.match( vlc.path, "^www%.youtube%.com/" ) then
+ if string.match( vlc.path, "^consent%.youtube%.com/" ) then
+ -- Cookie consent redirection
+ -- Location: https://consent.youtube.com/m?continue=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DXXXXXXXXXXX&gl=FR&m=0&pc=yt&uxe=23983172&hl=fr&src=1
+ -- Set-Cookie: CONSENT=PENDING+355; expires=Fri, 01-Jan-2038 00:00:00 GMT; path=/; domain=.youtube.com
+ local url = get_url_param( vlc.path, "continue" )
+ if not url then
+ vlc.msg.err( "Couldn't handle YouTube cookie consent redirection, please check for updates to this script or try disabling HTTP cookie forwarding" )
+ return { }
+ end
+ return { { path = vlc.strings.decode_uri( url ), options = { ":no-http-forward-cookies" } } }
+ elseif not string.match( vlc.path, "^www%.youtube%.com/" ) then
-- Skin subdomain
return { { path = vlc.access.."://"..string.gsub( vlc.path, "^([^/]*)/", "www.youtube.com/" ) } }
+
elseif string.match( vlc.path, "/watch%?" )
or string.match( vlc.path, "/live$" )
or string.match( vlc.path, "/live%?" )
--
2.26.2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment