YouTube/IMDb/Lyrics: verify URL domain

This commit is contained in:
oddluck 2020-02-27 00:14:06 +00:00
parent 7d62a21a75
commit d992a7dd2c
3 changed files with 9 additions and 9 deletions

View File

@ -74,7 +74,7 @@ class IMDb(callbacks.Plugin):
""" """
apikey = self.registryValue('omdbAPI') apikey = self.registryValue('omdbAPI')
url = self.dosearch(query) url = self.dosearch(query)
if url: if url and 'imdb.com' in utils.web.getDomain(url):
imdb_id = url.split("/title/")[1].rstrip("/") imdb_id = url.split("/title/")[1].rstrip("/")
omdb_url = "http://www.omdbapi.com/?i=%s&plot=short&r=json&tomatoes=true&apikey=%s" % (imdb_id, apikey) omdb_url = "http://www.omdbapi.com/?i=%s&plot=short&r=json&tomatoes=true&apikey=%s" % (imdb_id, apikey)
log.debug("IMDb: requesting %s" % omdb_url) log.debug("IMDb: requesting %s" % omdb_url)
@ -146,7 +146,7 @@ class IMDb(callbacks.Plugin):
log.error("IMDb HTTPError: %s" % (str(e))) log.error("IMDb HTTPError: %s" % (str(e)))
finally: finally:
if result is not None: if result is not None:
irc.reply(result) irc.reply(result, prefixNick=False)
else: else:
irc.error(self.registryValue("noResultsMessage")) irc.error(self.registryValue("noResultsMessage"))

View File

@ -86,16 +86,16 @@ class Lyrics(callbacks.Plugin):
Get song lyrics from Lyrics Wiki. Search powered by Google. Get song lyrics from Lyrics Wiki. Search powered by Google.
""" """
title, url = self.dosearch(lyric) title, url = self.dosearch(lyric)
if not title or not url: if url and title and 'lyrics.fandom.com' in utils.web.getDomain(url):
irc.reply("No results found for {0}".format(lyric))
return
else:
try: try:
lyrics = self.getlyrics(url) lyrics = self.getlyrics(url)
irc.reply(title) irc.reply(title, prefixNick=False)
irc.reply(lyrics) irc.reply(lyrics, prefixNick=False)
except Exception: except Exception:
irc.reply("Unable to retrieve lyrics from {0}".format(url)) irc.reply("Unable to retrieve lyrics from {0}".format(url))
else:
irc.reply("No results found for {0}".format(lyric))
return
lyric = wrap(lyric, ['text']) lyric = wrap(lyric, ['text'])
Class = Lyrics Class = Lyrics

View File

@ -143,7 +143,7 @@ class YouTube(callbacks.Plugin):
""" """
apikey = self.registryValue('developerKey') apikey = self.registryValue('developerKey')
url = self.dosearch(query) url = self.dosearch(query)
if url: if url and 'youtube.com' in utils.web.getDomain(url):
video_id = self.get_video_id_from_url(url) video_id = self.get_video_id_from_url(url)
else: else:
video_id = None video_id = None