aboutsummaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
authorRapptz <[email protected]>2016-01-31 17:49:40 -0500
committerRapptz <[email protected]>2016-01-31 17:49:40 -0500
commitb4604fa3f676f18b64fa0bb34874b144e1912b3c (patch)
tree30005854518fcb92d4ac19e80e77fb313aa4cc98 /discord
parent[commands] Fix crash when a group has no commands and help is requested (diff)
downloaddiscord.py-b4604fa3f676f18b64fa0bb34874b144e1912b3c.tar.xz
discord.py-b4604fa3f676f18b64fa0bb34874b144e1912b3c.zip
Change options in VoiceClient.create_ytdl_player to ytdl_options.
This is a breaking change. This allows you to set both ffmpeg options and regular ytdl options in the same function since we now just forward the keyword arguments to the ffmpeg player.
Diffstat (limited to 'discord')
-rw-r--r--discord/voice_client.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/discord/voice_client.py b/discord/voice_client.py
index 3324587f..c7d108e1 100644
--- a/discord/voice_client.py
+++ b/discord/voice_client.py
@@ -124,6 +124,7 @@ class ProcessPlayer(StreamPlayer):
self.process.kill()
super().stop()
+
class VoiceClient:
"""Represents a Discord voice connection.
@@ -415,7 +416,7 @@ class VoiceClient:
raise ClientException('Popen failed: {0.__name__} {1}'.format(type(e), str(e))) from e
- def create_ytdl_player(self, url, *, options=None, use_avconv=False, after=None):
+ def create_ytdl_player(self, url, *, ytdl_options=None, **kwargs):
"""Creates a stream player for youtube or other services that launches
in a separate thread to play the audio.
@@ -446,15 +447,12 @@ class VoiceClient:
url : str
The URL that ``youtube_dl`` will take and download audio to pass
to ``ffmpeg`` or ``avconv`` to convert to PCM bytes.
- options : dict
+ ytdl_options : dict
A dictionary of options to pass into the ``YoutubeDL`` instance.
See `the documentation <ydl>`_ for more details.
- use_avconv: bool
- Use ``avconv`` instead of ``ffmpeg``. Passes the appropriate
- flags to ``youtube-dl`` as well.
- after : callable
- The finalizer that is called after the stream is done being
- played. All exceptions the finalizer throws are silently discarded.
+ \*\*kwargs
+ The rest of the keyword arguments are forwarded to
+ :func:`create_ffmpeg_player`.
Raises
-------
@@ -469,18 +467,19 @@ class VoiceClient:
"""
import youtube_dl
+ use_avconv = kwargs.get('use_avconv', False)
opts = {
'format': 'webm[abr>0]' if 'youtube' in url else 'best',
'prefer_ffmpeg': not use_avconv
}
- if options is not None and isinstance(options, dict):
- opts.update(options)
+ if ytdl_options is not None and isinstance(ytdl_options, dict):
+ opts.update(ytdl_options)
ydl = youtube_dl.YoutubeDL(opts)
info = ydl.extract_info(url, download=False)
log.info('playing URL {}'.format(url))
- return self.create_ffmpeg_player(info['url'], use_avconv=use_avconv, after=after)
+ return self.create_ffmpeg_player(info['url'], **kwargs)
def encoder_options(self, *, sample_rate, channels=2):
"""Sets the encoder options for the OpusEncoder.