Handle errors
This commit is contained in:
parent
2f27c94be6
commit
11a639be5d
18
main.py
18
main.py
@ -50,14 +50,16 @@ async def youtube(room, message):
|
||||
match = botlib.MessageMatch(room, message, bot)
|
||||
pieces = str(message).split()
|
||||
links = filter(filterfunc, pieces)
|
||||
for i in links:
|
||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||
info_dict = ydl.extract_info(i, download=False)
|
||||
fname = urllib.parse.quote(info_dict.get('title', None).replace('|', '_'))
|
||||
#fname = fname.translate({ord(c): None for c in ',&!|'})
|
||||
url = 'https://trygve.me/video_bot/' + fname + '.webm'
|
||||
ydl.download([i])
|
||||
await bot.api.send_text_message(room.room_id, url)
|
||||
try:
|
||||
for i in links:
|
||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||
info_dict = ydl.extract_info(i, download=False)
|
||||
fname = urllib.parse.quote(info_dict.get('title', None).replace('|', '_'))
|
||||
url = 'https://trygve.me/video_bot/' + fname + '.webm'
|
||||
ydl.download([i])
|
||||
await bot.api.send_text_message(room.room_id, url)
|
||||
except Exception as e:
|
||||
await bot.api.send_text_message(room.room_id, str(e))
|
||||
|
||||
bot.add_message_listener(youtube)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user