mirror of
https://github.com/benbusby/whoogle-search
synced 2024-11-10 13:10:30 +00:00
Ignore blank alts if site alt config is enabled
If the alt for a particular service is blank, the original source is used instead. Example: 1. Site alts enabled in config 2. User wants wikipedia links, not wikiless 3. WHOOGLE_ALT_WIKI set to "" 4. All available alt links redirected to farside, except wikipedia Fixes #704
This commit is contained in:
parent
788730cdc2
commit
797372ecaa
@ -410,7 +410,7 @@ class Filter:
|
|||||||
# Replace link description
|
# Replace link description
|
||||||
link_desc = link_desc[0]
|
link_desc = link_desc[0]
|
||||||
for site, alt in SITE_ALTS.items():
|
for site, alt in SITE_ALTS.items():
|
||||||
if site not in link_desc:
|
if site not in link_desc or not alt:
|
||||||
continue
|
continue
|
||||||
new_desc = BeautifulSoup(features='html.parser').new_tag('div')
|
new_desc = BeautifulSoup(features='html.parser').new_tag('div')
|
||||||
new_desc.string = str(link_desc).replace(site, alt)
|
new_desc.string = str(link_desc).replace(site, alt)
|
||||||
|
@ -128,7 +128,7 @@ def get_site_alt(link: str) -> str:
|
|||||||
hostname = urlparse.urlparse(link).hostname
|
hostname = urlparse.urlparse(link).hostname
|
||||||
|
|
||||||
for site_key in SITE_ALTS.keys():
|
for site_key in SITE_ALTS.keys():
|
||||||
if not hostname or site_key not in hostname:
|
if not hostname or site_key not in hostname or not SITE_ALTS[site_key]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
link = link.replace(hostname, SITE_ALTS[site_key])
|
link = link.replace(hostname, SITE_ALTS[site_key])
|
||||||
|
Loading…
Reference in New Issue
Block a user