From aa961bbe651d2f78c2c8a2964b627b8f28bf5b4f Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Wed, 3 Feb 2016 10:55:14 +0100 Subject: [PATCH] ~h for help too, more work on yotube playlist queue, music debugging --- .gitignore | 3 +++ NadekoBot/Classes/Music/MusicControls.cs | 6 +++++- NadekoBot/Classes/Music/StreamRequest.cs | 7 ++++--- NadekoBot/Commands/HelpCommand.cs | 2 +- NadekoBot/Modules/Searches.cs | 5 ++++- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 673df0c5..3df07766 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,9 @@ obj/ !**/Bin/Debug/opus.dll !**/Bin/Debug/libsodium.dll !**/Bin/Debug/Discord.Net.Commands.dll +!**/Bin/Debug/Nito.AsyncEx.Enlightenment.dll +!**/Bin/Debug/Nito.AsyncEx.dll +!**/Bin/Debug/WebSocket4Net.dll !**/Bin/Debug/data/* !**/Bin/Debug/data/ diff --git a/NadekoBot/Classes/Music/MusicControls.cs b/NadekoBot/Classes/Music/MusicControls.cs index c3e6da3d..cc70a683 100644 --- a/NadekoBot/Classes/Music/MusicControls.cs +++ b/NadekoBot/Classes/Music/MusicControls.cs @@ -61,8 +61,12 @@ namespace NadekoBot.Classes.Music { } try { - if (VoiceClient == null) + if (VoiceClient == null) { + Console.WriteLine($"Joining voice channel [{DateTime.Now.Second}]"); + //todo add a new event, to tell people nadeko is trying to join VoiceClient = await NadekoBot.client.Audio().Join(VoiceChannel); + Console.WriteLine($"Joined voicechannel [{DateTime.Now.Second}]"); + } await CurrentSong.Start(); } catch (Exception ex) { Console.WriteLine($"Starting failed: {ex}"); diff --git a/NadekoBot/Classes/Music/StreamRequest.cs b/NadekoBot/Classes/Music/StreamRequest.cs index f3de304f..5158e3ee 100644 --- a/NadekoBot/Classes/Music/StreamRequest.cs +++ b/NadekoBot/Classes/Music/StreamRequest.cs @@ -156,6 +156,7 @@ namespace NadekoBot.Classes.Music { Arguments = $"-i {Url} -f s16le -ar 48000 -ac 2 pipe:1", UseShellExecute = false, RedirectStandardOutput = true, + RedirectStandardError = false, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, }); @@ -165,7 +166,7 @@ namespace NadekoBot.Classes.Music { //wait for the read pos to catch up with write pos while (buffer.writePos - buffer.readPos > 5.MB() && State != StreamState.Completed) { prebufferingComplete = true; - await Task.Delay(500); + await Task.Delay(200); } if (State == StreamState.Completed) { @@ -258,7 +259,7 @@ namespace NadekoBot.Classes.Music { if (readCount == 0) { if (attempt == 2) { - Console.WriteLine($"Failed to read {attempt} times. Stopping playback."); + Console.WriteLine($"Failed to read {attempt} times. Breaking out. [{DateTime.Now.Second}]"); break; } else { ++attempt; @@ -287,7 +288,7 @@ namespace NadekoBot.Classes.Music { } internal void Stop() { - Console.WriteLine("Stopping playback"); + Console.WriteLine($"Stopping playback [{DateTime.Now.Second}]"); if (State != StreamState.Completed) { State = StreamState.Completed; parent.OnCompleted(); diff --git a/NadekoBot/Commands/HelpCommand.cs b/NadekoBot/Commands/HelpCommand.cs index f21a736c..d1319e67 100644 --- a/NadekoBot/Commands/HelpCommand.cs +++ b/NadekoBot/Commands/HelpCommand.cs @@ -55,7 +55,7 @@ namespace NadekoBot public override void Init(CommandGroupBuilder cgb) { cgb.CreateCommand("-h") - .Alias(new string[] { "-help", NadekoBot.botMention + " help", NadekoBot.botMention + " h" }) + .Alias(new string[] { "-help", NadekoBot.botMention + " help", NadekoBot.botMention + " h", "~h" }) .Description("Help command") .Do(DoFunc()); cgb.CreateCommand("-hgit") diff --git a/NadekoBot/Modules/Searches.cs b/NadekoBot/Modules/Searches.cs index bbb2f979..8c9cac5c 100644 --- a/NadekoBot/Modules/Searches.cs +++ b/NadekoBot/Modules/Searches.cs @@ -269,7 +269,10 @@ namespace NadekoBot.Modules { var sr = new StreamReader(wr.GetResponse().GetResponseStream()); dynamic obj = JObject.Parse(sr.ReadToEnd()); - toReturn = "http://www.youtube.com/watch?v=" + obj.items[0].id.playlistId.ToString(); + + foreach (var item in obj.items) { + toReturn.Add("http://www.youtube.com/watch?v=" + item.id.contentDetails.videoId); + } return toReturn; } catch (Exception ex) { Console.WriteLine($"Error in GetPlaylistId: {ex.Message}");