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

Catch when videos fail to download

This commit is contained in:
Phxntxm 2017-05-07 21:05:37 -05:00
parent 064e182dde
commit 4ebfcf6613
3 changed files with 19 additions and 6 deletions

View file

@ -56,12 +56,22 @@ class VoiceState:
self.current = None
async def audio_player_task(self):
fmt = ""
while True:
if self.playing or self.songs.peek() is None:
if self.playing:
await asyncio.sleep(1)
continue
song = self.songs.peek()
if song is None:
await asyncio.sleep(1)
continue
self.current = await self.songs.get_next_entry()
try:
self.current = await self.songs.get_next_entry()
await self.current.channel.send("Now playing {}".format())
except ExtractionError as e:
await song.channel.send("Failed to download {}!\nError: {}".format(self.current.title, e))
continue
source = FFmpegPCMAudio(
self.current.filename,

View file

@ -92,16 +92,18 @@ class BasePlaylistEntry:
class URLPlaylistEntry(BasePlaylistEntry):
def __init__(self, playlist, url, title, requester, duration=0, expected_filename=None, **meta):
def __init__(self, playlist, url, title, ctx, thumbnail, duration=0, expected_filename=None, **meta):
super().__init__()
self.playlist = playlist
self.url = url
self.title = title
self.duration = duration
self.thumbnail = thumbnail
self.expected_filename = expected_filename
self.meta = meta
self.requester = requester
self.requester = ctx.message.author
self.channel = ctx.message.channel
self.download_folder = self.playlist.downloader.download_folder
def __str__(self):

View file

@ -37,7 +37,7 @@ class Playlist(EventEmitter):
else:
return 0
async def add_entry(self, song_url, requester, **meta):
async def add_entry(self, song_url, ctx, **meta):
"""
Validates and adds a song_url to be played. This does not start the download of the song.
@ -97,7 +97,8 @@ class Playlist(EventEmitter):
self,
song_url,
info.get('title', 'Untitled'),
requester,
ctx,
info.get('thumbnail', None),
info.get('duration', 0) or 0,
self.downloader.ytdl.prepare_filename(info),
**meta