1
0
Fork 0
mirror of synced 2024-06-03 11:14:33 +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) entry = await self.add_entry(song, ctx)
except asyncio.TimeoutError: except asyncio.TimeoutError:
await ctx.send("You took too long!") await ctx.send("You took too long!")
except ExtractionError as e:
await ctx.send(str(e))
else: else:
if entry is None: if entry is None:
await ctx.send("Sorry but I couldn't download/find {}".format(song)) 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 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 = { ytdl_format_options = {
'format': 'bestaudio/best', 'format': 'bestaudio/best',
'extractaudio': True, 'extractaudio': True,
@ -16,6 +25,7 @@ ytdl_format_options = {
'ignoreerrors': False, 'ignoreerrors': False,
'logtostderr': False, 'logtostderr': False,
'quiet': True, 'quiet': True,
'match_filter': match_filter,
'no_warnings': True, 'no_warnings': True,
'default_search': 'auto', 'default_search': 'auto',
'source_address': '0.0.0.0' 'source_address': '0.0.0.0'