Lyrics/IMDB: except search plugin errors

This commit is contained in:
oddluck 2020-07-02 00:54:55 +00:00
parent 5e315f86c9
commit 1ba1b29e9a
2 changed files with 28 additions and 19 deletions

View File

@ -87,24 +87,33 @@ class IMDb(callbacks.Plugin):
pattern = re.compile(r"https?://www.imdb.com/title/tt\d+/$") pattern = re.compile(r"https?://www.imdb.com/title/tt\d+/$")
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"]) try:
except TypeError: match = re.search(pattern, r["url"])
match = re.search(pattern, r.link) except TypeError:
if match: match = re.search(pattern, r.link)
log.debug("IMDb: found link using Google search") if match:
break log.debug("IMDb: found link using Google search")
break
except:
pass
elif ddg and self.registryValue("ddg", channel) == i: elif ddg and 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,
log.debug("IMDb: found link using DDG search") )
break for r in results:
match = re.search(pattern, r[2])
if match:
log.debug("IMDb: found link using DDG search")
break
except:
pass
if match: if match:
return match.group(0) return match.group(0)
else: else:

View File

@ -85,7 +85,7 @@ class Lyrics(callbacks.Plugin):
log.debug("Lyrics: found link using Google search") log.debug("Lyrics: found link using Google search")
break break
except: except:
continue pass
elif self.registryValue("ddg", channel) == i: elif self.registryValue("ddg", channel) == i:
try: try:
results = ddg.search_core( results = ddg.search_core(
@ -101,7 +101,7 @@ class Lyrics(callbacks.Plugin):
log.debug("Lyrics: found link using DDG") log.debug("Lyrics: found link using DDG")
break break
except: except:
continue pass
if match and title: if match and title:
return title, match.group(0) return title, match.group(0)
else: else: