1
0
Fork 0
mirror of synced 2024-05-20 20:42:27 +12:00

Handle when live streams are attempted to be downloaded

This commit is contained in:
Phxntxm 2017-04-22 17:54:23 -05:00
parent 6be0c4c93d
commit ccee1dc046
2 changed files with 12 additions and 0 deletions

View file

@ -355,6 +355,8 @@ class Music:
entry = await self.add_entry(song, ctx)
except asyncio.TimeoutError:
await ctx.send("You took too long!")
except ExtractionError as e:
await ctx.send(str(e))
else:
if entry is None:
await ctx.send("Sorry but I couldn't download/find {}".format(song))

View file

@ -5,6 +5,15 @@ import youtube_dl
from concurrent.futures import ThreadPoolExecutor
class LiveStreamError(Exception):
pass
def match_filter(info_dict):
if 'is_live' in info_dict and info_dict['is_live'] == True:
raise LiveStreamError("Cannot download livestreams!")
return None
ytdl_format_options = {
'format': 'bestaudio/best',
'extractaudio': True,
@ -16,6 +25,7 @@ ytdl_format_options = {
'ignoreerrors': False,
'logtostderr': False,
'quiet': True,
'match_filter': match_filter,
'no_warnings': True,
'default_search': 'auto',
'source_address': '0.0.0.0'