From ed3d9a7d7c42b019137dada1ccdb544597ebd01a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20F=C3=B6rster?= Date: Wed, 28 Aug 2024 15:42:35 +0200 Subject: [PATCH] invidious support for basic auth urls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds user, password and port to the proxy and thumbnail url, if they exist. fixes #614 & #731 Signed-off-by: Toni Förster --- Model/Applications/InvidiousAPI.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Model/Applications/InvidiousAPI.swift b/Model/Applications/InvidiousAPI.swift index c3c1084e..7f685d15 100644 --- a/Model/Applications/InvidiousAPI.swift +++ b/Model/Applications/InvidiousAPI.swift @@ -445,6 +445,9 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI { urlComponents.scheme = instanceURLComponents.scheme urlComponents.host = instanceURLComponents.host + urlComponents.user = instanceURLComponents.user + urlComponents.password = instanceURLComponents.password + urlComponents.port = instanceURLComponents.port guard let url = urlComponents.url else { return nil @@ -563,13 +566,20 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI { return nil } - // some of instances are not configured properly and return thumbnails links - // with incorrect scheme + // Some instances are not configured properly and return thumbnail links + // with an incorrect scheme or a missing port. components.scheme = accountUrlComponents.scheme + components.port = accountUrlComponents.port + + // If basic HTTP authentication is used, + // the username and password need to be prepended to the URL. + components.user = accountUrlComponents.user + components.password = accountUrlComponents.password guard let thumbnailUrl = components.url else { return nil } + print("Final thumbnail URL: \(thumbnailUrl)") return Thumbnail(url: thumbnailUrl, quality: .init(rawValue: quality)!) }