From f7ca7e77be69b7028d68b92332d6de499d528601 Mon Sep 17 00:00:00 2001 From: Epsilon Spider <105926847+epsilonSpider@users.noreply.github.com> Date: Tue, 4 Apr 2023 16:29:00 -0400 Subject: [PATCH] [safari] Refactor login check --- youtube_dl/extractor/safari.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/safari.py b/youtube_dl/extractor/safari.py index 2d41482e5..e923d7641 100644 --- a/youtube_dl/extractor/safari.py +++ b/youtube_dl/extractor/safari.py @@ -38,8 +38,11 @@ class SafariBaseIE(InfoExtractor): 'Downloading login page') def is_logged(urlh): - return ('https://learning.oreilly.com/member/login/' == urlh.geturl() - or 'learning.oreilly.com/home/' in urlh.geturl()) + url = urlh.geturl() + parsed_url = compat_urlparse.urlparse(url) + return parsed_url.hostname.endswith('learning.oreilly.com') and ( + parsed_url.path.startswith('/home/') + or (parsed_url.path == '/member/login/' and not parsed_url.query)) if is_logged(urlh): self.LOGGED_IN = True