diff options
| author | Alexey Glushko <[email protected]> | 2016-01-25 20:39:37 +0000 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2016-01-26 22:27:00 -0500 |
| commit | f075548d78020b00337d372131c87ad99f6757c4 (patch) | |
| tree | 025914da0fb33b86eb260d554f0980bb2d927245 | |
| parent | Add and remove some of the on_socket_* events. (diff) | |
| download | discord.py-f075548d78020b00337d372131c87ad99f6757c4.tar.xz discord.py-f075548d78020b00337d372131c87ad99f6757c4.zip | |
add ``headers`` option to create_ffmpeg_player()
headers can't be passed through 'options' because in '-headers' flag shoul be placed before '-i'
At least for ffmpeg 2.8.4
| -rw-r--r-- | discord/voice_client.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/discord/voice_client.py b/discord/voice_client.py index 74713e0b..70b6574f 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -334,7 +334,7 @@ class VoiceClient: struct.pack_into('>I', buff, 8, self.ssrc) return buff - def create_ffmpeg_player(self, filename, *, use_avconv=False, pipe=False, options=None, after=None): + def create_ffmpeg_player(self, filename, *, use_avconv=False, pipe=False, options=None, headers=None, after=None): """Creates a stream player for ffmpeg that launches in a separate thread to play audio. @@ -369,6 +369,8 @@ class VoiceClient: to the stdin of ffmpeg. options: str Extra command line flags to pass to ``ffmpeg``. + headers: dict + HTTP headers dictionary to pass to ``-headers`` command line option after : callable The finalizer that is called after the stream is done being played. All exceptions the finalizer throws are silently discarded. @@ -386,8 +388,13 @@ class VoiceClient: """ command = 'ffmpeg' if not use_avconv else 'avconv' input_name = '-' if pipe else shlex.quote(filename) - cmd = command + ' -i {} -f s16le -ar {} -ac {} -loglevel warning' - cmd = cmd.format(input_name, self.encoder.sampling_rate, self.encoder.channels) + headers_arg = "" + if isinstance(headers, dict): + for key, value in headers.items(): + headers_arg += "{}: {}\r\n".format(key, value) + headers_arg = ' -headers ' + shlex.quote(headers_arg) + cmd = command + '{} -i {} -f s16le -ar {} -ac {} -loglevel warning' + cmd = cmd.format(headers_arg, input_name, self.encoder.sampling_rate, self.encoder.channels) if isinstance(options, str): cmd = cmd + ' ' + options |