Add proper error handling on get_title
This commit is contained in:
parent
34557b7888
commit
1a64668191
12
bot.py
12
bot.py
|
@ -7,10 +7,14 @@ PUBLIC_COMMANDS = ["sotd","listsotd"]
|
|||
SOTDS = datastore.DataStore("sotd.json")
|
||||
|
||||
def get_title(link):
|
||||
title = str(urlopen(link).read()).split("<title>", 1)[1].split("</title>", 1)[0]
|
||||
if "YouTube" in title:
|
||||
return title.split(" - YouTube", 1)[0]
|
||||
return title
|
||||
try:
|
||||
title = str(urlopen(link).read()).split("<title>", 1)[1].split("</title>", 1)[0]
|
||||
if "YouTube" in title:
|
||||
return title.split(" - YouTube", 1)[0]
|
||||
return title
|
||||
except:
|
||||
print(e)
|
||||
return link
|
||||
|
||||
class SOTDBot(teambot.Handler,teambot.CommandHandlerMixin):
|
||||
def __init__(self,*args):
|
||||
|
|
Reference in New Issue