Lyrics/IMDb: fix for google plugin in testing

This commit is contained in:
oddluck 2020-06-01 13:27:52 +00:00
parent f351af5a47
commit 42fb7e1039
4 changed files with 15 additions and 8 deletions

View File

@ -37,7 +37,7 @@ import supybot.world as world
# Use this for the version of this plugin. You may wish to put a CVS keyword
# in here if you're keeping the plugin in CVS or some similar system.
__version__ = "2020.05.19+git"
__version__ = "2020.06.01+git"
# XXX Replace this with an appropriate author or supybot.Author instance.
__author__ = supybot.Author("butterscotchstallion", "butterscotchstallion", "")

View File

@ -89,7 +89,10 @@ class IMDb(callbacks.Plugin):
if google and self.registryValue("google", channel) == i:
results = google.decode(google.search(query, irc.network, channel))
for r in results:
match = re.search(pattern, r["url"])
try:
match = re.search(pattern, r["url"])
except TypeError:
match = re.search(pattern, r.link)
if match:
log.debug("IMDb: found link using Google search")
break
@ -156,9 +159,7 @@ class IMDb(callbacks.Plugin):
if rating["Source"] == "Rotten Tomatoes":
response["tomatometer"] = rating["Value"]
if rating["Source"] == "Metacritic":
response["metascore"] = "{0}%".format(
rating["Value"].split("/")[0]
)
response["metascore"] = "{0}%".format(rating["Value"].split("/")[0])
result = imdb_template.safe_substitute(response)
elif response.get("Error"):
log.debug("IMDb: OMDB API: %s" % response["Error"])

View File

@ -36,7 +36,7 @@ import supybot.world as world
# Use this for the version of this plugin. You may wish to put a CVS keyword
# in here if you're keeping the plugin in CVS or some similar system.
__version__ = "2020.05.19+git"
__version__ = "2020.06.01+git"
# XXX Replace this with an appropriate author or supybot.Author instance.
__author__ = supybot.Author("oddluck", "oddluck", "oddluck@riseup.net")

View File

@ -72,9 +72,15 @@ class Lyrics(callbacks.Plugin):
if google and self.registryValue("google", channel) == i:
results = google.decode(google.search(query, irc.network, channel))
for r in results:
match = re.search(pattern, r["url"])
try:
match = re.search(pattern, r["url"])
except TypeError:
match = re.search(pattern, r.link)
if match:
title = r["title"].replace(":", " - ").split("|")[0]
try:
title = r["title"].replace(":", " - ").split("|")[0]
except TypeError:
title = r.title.replace(":", " - ").split("|")[0]
log.debug("Lyrics: found link using Google search")
break
elif self.registryValue("ddg", channel) == i: