~h for help too, more work on yotube playlist queue, music debugging

This commit is contained in:
Master Kwoth 2016-02-03 10:55:14 +01:00
parent 6f53bfcf16
commit aa961bbe65
5 changed files with 17 additions and 6 deletions

3
.gitignore vendored
View File

@ -20,6 +20,9 @@ obj/
!**/Bin/Debug/opus.dll !**/Bin/Debug/opus.dll
!**/Bin/Debug/libsodium.dll !**/Bin/Debug/libsodium.dll
!**/Bin/Debug/Discord.Net.Commands.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/*
!**/Bin/Debug/data/ !**/Bin/Debug/data/

View File

@ -61,8 +61,12 @@ namespace NadekoBot.Classes.Music {
} }
try { 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); VoiceClient = await NadekoBot.client.Audio().Join(VoiceChannel);
Console.WriteLine($"Joined voicechannel [{DateTime.Now.Second}]");
}
await CurrentSong.Start(); await CurrentSong.Start();
} catch (Exception ex) { } catch (Exception ex) {
Console.WriteLine($"Starting failed: {ex}"); Console.WriteLine($"Starting failed: {ex}");

View File

@ -156,6 +156,7 @@ namespace NadekoBot.Classes.Music {
Arguments = $"-i {Url} -f s16le -ar 48000 -ac 2 pipe:1", Arguments = $"-i {Url} -f s16le -ar 48000 -ac 2 pipe:1",
UseShellExecute = false, UseShellExecute = false,
RedirectStandardOutput = true, RedirectStandardOutput = true,
RedirectStandardError = false,
CreateNoWindow = true, CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden, WindowStyle = ProcessWindowStyle.Hidden,
}); });
@ -165,7 +166,7 @@ namespace NadekoBot.Classes.Music {
//wait for the read pos to catch up with write pos //wait for the read pos to catch up with write pos
while (buffer.writePos - buffer.readPos > 5.MB() && State != StreamState.Completed) { while (buffer.writePos - buffer.readPos > 5.MB() && State != StreamState.Completed) {
prebufferingComplete = true; prebufferingComplete = true;
await Task.Delay(500); await Task.Delay(200);
} }
if (State == StreamState.Completed) { if (State == StreamState.Completed) {
@ -258,7 +259,7 @@ namespace NadekoBot.Classes.Music {
if (readCount == 0) { if (readCount == 0) {
if (attempt == 2) { 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; break;
} else { } else {
++attempt; ++attempt;
@ -287,7 +288,7 @@ namespace NadekoBot.Classes.Music {
} }
internal void Stop() { internal void Stop() {
Console.WriteLine("Stopping playback"); Console.WriteLine($"Stopping playback [{DateTime.Now.Second}]");
if (State != StreamState.Completed) { if (State != StreamState.Completed) {
State = StreamState.Completed; State = StreamState.Completed;
parent.OnCompleted(); parent.OnCompleted();

View File

@ -55,7 +55,7 @@ namespace NadekoBot
public override void Init(CommandGroupBuilder cgb) public override void Init(CommandGroupBuilder cgb)
{ {
cgb.CreateCommand("-h") 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") .Description("Help command")
.Do(DoFunc()); .Do(DoFunc());
cgb.CreateCommand("-hgit") cgb.CreateCommand("-hgit")

View File

@ -269,7 +269,10 @@ namespace NadekoBot.Modules {
var sr = new StreamReader(wr.GetResponse().GetResponseStream()); var sr = new StreamReader(wr.GetResponse().GetResponseStream());
dynamic obj = JObject.Parse(sr.ReadToEnd()); 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; return toReturn;
} catch (Exception ex) { } catch (Exception ex) {
Console.WriteLine($"Error in GetPlaylistId: {ex.Message}"); Console.WriteLine($"Error in GetPlaylistId: {ex.Message}");