diff --git a/app/utils/results.py b/app/utils/results.py index 3cfcbc1..60a4f6b 100644 --- a/app/utils/results.py +++ b/app/utils/results.py @@ -27,7 +27,7 @@ SITE_ALTS = { 'youtube.com': os.getenv('WHOOGLE_ALT_YT', 'invidious.snopyta.org'), 'instagram.com': os.getenv('WHOOGLE_ALT_IG', 'bibliogram.art/u'), 'reddit.com': os.getenv('WHOOGLE_ALT_RD', 'libredd.it'), - 'medium.com': os.getenv('WHOOGLE_ALT_MD','scribe.rip'), + 'medium.com': os.getenv('WHOOGLE_ALT_MD', 'scribe.rip'), } @@ -73,16 +73,14 @@ def get_site_alt(link: str) -> str: str: An updated (or ignored) result link """ + # Need to replace full hostname with alternative to encapsulate + # subdomains as well + hostname = urlparse.urlparse(link).hostname for site_key in SITE_ALTS.keys(): - if site_key not in link: + if not hostname or site_key not in hostname: continue - # Need to replace full hostname with alternative to encapsulate - # subdomains as well - - hostname = urlparse.urlparse(link).hostname - link = link.replace(hostname, SITE_ALTS[site_key]) for prefix in SKIP_PREFIX: link = link.replace(prefix, '//')