From ee735ad2995ca09149678cfd6eb1136f778af605 Mon Sep 17 00:00:00 2001 From: Phantop Date: Sat, 12 Oct 2024 16:34:55 -0400 Subject: [PATCH] qute: update redirect for invidious not working anymore --- fish/functions/ytflux.fish | 2 +- qutebrowser/redirects.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/fish/functions/ytflux.fish b/fish/functions/ytflux.fish index c418696..b0abc55 100644 --- a/fish/functions/ytflux.fish +++ b/fish/functions/ytflux.fish @@ -2,5 +2,5 @@ function ytflux set cat (cat ~/.config/miniflux)/categories/3 set entries (eval curl $cat/entries?status=unread | jq -r .entries[].url) eval curl -X PUT $cat/mark-all-as-read - parallel -u "yt-dlp $argv (trurl -s host=youtube.com {})" ::: $entries + parallel -u "yt-dlp $argv {}" ::: $entries end diff --git a/qutebrowser/redirects.py b/qutebrowser/redirects.py index 7cbf989..e31caa7 100644 --- a/qutebrowser/redirects.py +++ b/qutebrowser/redirects.py @@ -18,11 +18,6 @@ basic = { 'www.twitch.tv' : 'twineo.exozy.me', } farside = { - 'music.youtube.com': 'invidious', - 'www.youtube.com': 'invidious', - 'youtu.be': 'invidious', - 'youtube.com': 'invidious', - 'old.reddit.com': 'redlib', 'reddit.com': 'redlib', 'www.reddit.com': 'redlib', @@ -58,6 +53,17 @@ subs = { 'tumblr.com' : tumblr, } +def youtube(info: interceptor.Request, url: QUrl): + url = url.toString() + nurl = url.replace("watch?v=", "embed/") + + if nurl != url: + info.redirect(QUrl(nurl)) + +custom = { + 'www.youtube.com' : youtube, +} + def rewrite(info: interceptor.Request): url = info.request_url host = url.host() @@ -66,6 +72,7 @@ def rewrite(info: interceptor.Request): bredir = basic.get(host) fredir = farside.get(host) sredir = subs.get(base) + credir = custom.get(host) if bredir is not None: url.setHost(bredir) @@ -78,5 +85,7 @@ def rewrite(info: interceptor.Request): sub = host.split('.')[0] sredir(url, sub) info.redirect(url) + elif credir is not None: + credir(info, url) interceptor.register(rewrite)