mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-30 07:21:16 -05:00
Lyrics: ignore search plugin errors
This commit is contained in:
parent
28fcc1f59c
commit
5e315f86c9
@ -70,29 +70,38 @@ class Lyrics(callbacks.Plugin):
|
|||||||
pattern = re.compile(r"https?://lyrics.fandom.com/wiki/.*")
|
pattern = re.compile(r"https?://lyrics.fandom.com/wiki/.*")
|
||||||
for i in range(1, 3):
|
for i in range(1, 3):
|
||||||
if google and self.registryValue("google", channel) == i:
|
if google and self.registryValue("google", channel) == i:
|
||||||
results = google.decode(google.search(query, irc.network, channel))
|
try:
|
||||||
for r in results:
|
results = google.decode(google.search(query, irc.network, channel))
|
||||||
try:
|
for r in results:
|
||||||
match = re.search(pattern, r["url"])
|
|
||||||
except TypeError:
|
|
||||||
match = re.search(pattern, r.link)
|
|
||||||
if match:
|
|
||||||
try:
|
try:
|
||||||
title = r["title"].replace(":", " - ").split("|")[0]
|
match = re.search(pattern, r["url"])
|
||||||
except TypeError:
|
except TypeError:
|
||||||
title = r.title.replace(":", " - ").split("|")[0]
|
match = re.search(pattern, r.link)
|
||||||
log.debug("Lyrics: found link using Google search")
|
if match:
|
||||||
break
|
try:
|
||||||
|
title = r["title"].replace(":", " - ").split("|")[0]
|
||||||
|
except TypeError:
|
||||||
|
title = r.title.replace(":", " - ").split("|")[0]
|
||||||
|
log.debug("Lyrics: found link using Google search")
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
continue
|
||||||
elif self.registryValue("ddg", channel) == i:
|
elif self.registryValue("ddg", channel) == i:
|
||||||
results = ddg.search_core(
|
try:
|
||||||
query, channel_context=channel, max_results=10, show_snippet=False
|
results = ddg.search_core(
|
||||||
)
|
query,
|
||||||
for r in results:
|
channel_context=channel,
|
||||||
match = re.search(pattern, r[2])
|
max_results=10,
|
||||||
if match:
|
show_snippet=False,
|
||||||
title = r[0].replace(":", " - ").split("|")[0]
|
)
|
||||||
log.debug("Lyrics: found link using DDG")
|
for r in results:
|
||||||
break
|
match = re.search(pattern, r[2])
|
||||||
|
if match:
|
||||||
|
title = r[0].replace(":", " - ").split("|")[0]
|
||||||
|
log.debug("Lyrics: found link using DDG")
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
continue
|
||||||
if match and title:
|
if match and title:
|
||||||
return title, match.group(0)
|
return title, match.group(0)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user