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,6 +87,7 @@ 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:
try:
results = google.decode(google.search(query, irc.network, channel)) results = google.decode(google.search(query, irc.network, channel))
for r in results: for r in results:
try: try:
@ -96,15 +97,23 @@ class IMDb(callbacks.Plugin):
if match: if match:
log.debug("IMDb: found link using Google search") log.debug("IMDb: found link using Google search")
break break
except:
pass
elif ddg and self.registryValue("ddg", channel) == i: elif ddg and self.registryValue("ddg", channel) == i:
try:
results = ddg.search_core( results = ddg.search_core(
query, channel_context=channel, max_results=10, show_snippet=False query,
channel_context=channel,
max_results=10,
show_snippet=False,
) )
for r in results: for r in results:
match = re.search(pattern, r[2]) match = re.search(pattern, r[2])
if match: if match:
log.debug("IMDb: found link using DDG search") log.debug("IMDb: found link using DDG search")
break 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: