diff --git a/src/NadekoBot/Modules/Music/Music.cs b/src/NadekoBot/Modules/Music/Music.cs index d9057723..0b97c451 100644 --- a/src/NadekoBot/Modules/Music/Music.cs +++ b/src/NadekoBot/Modules/Music/Music.cs @@ -108,6 +108,7 @@ namespace NadekoBot.Modules.Music int index; try { + _log.Info("Added"); index = mp.Enqueue(songInfo); } catch (QueueFullException) @@ -169,11 +170,13 @@ namespace NadekoBot.Modules.Music [RequireContext(ContextType.Guild)] public async Task Queue([Remainder] string query) { + _log.Info("Getting player"); var mp = await _music.GetOrCreatePlayer(Context); + _log.Info("Resolving song"); var songInfo = await _music.ResolveSong(query, Context.User.ToString()); - + _log.Info("Queueing song"); try { await InternalQueue(mp, songInfo, false); } catch (QueueFullException) { return; } - + _log.Info("--------------"); if ((await Context.Guild.GetCurrentUserAsync()).GetPermissions((IGuildChannel)Context.Channel).ManageMessages) { Context.Message.DeleteAfter(10); diff --git a/src/NadekoBot/Services/Music/MusicPlayer.cs b/src/NadekoBot/Services/Music/MusicPlayer.cs index 15888dec..cf04f8e9 100644 --- a/src/NadekoBot/Services/Music/MusicPlayer.cs +++ b/src/NadekoBot/Services/Music/MusicPlayer.cs @@ -156,6 +156,7 @@ namespace NadekoBot.Services.Music _log.Info("Starting"); using (var b = new SongBuffer(await data.Song.Uri(), "")) { + _log.Info("Created buffer, buffering..."); AudioOutStream pcm = null; try { @@ -171,16 +172,19 @@ namespace NadekoBot.Services.Music _log.Info("Buffering failed due to a cancel or error."); continue; } - + _log.Info("Buffered. Getting audio client..."); var ac = await GetAudioClient(); + _log.Info("Got Audio client"); if (ac == null) { + _log.Info("Can't join"); await Task.Delay(900, cancelToken); // just wait some time, maybe bot doesn't even have perms to join that voice channel, // i don't want to spam connection attempts continue; } pcm = ac.CreatePCMStream(AudioApplication.Music, bufferMillis: 500); + _log.Info("Created pcm stream"); OnStarted?.Invoke(this, data); byte[] buffer = new byte[3840]; @@ -189,6 +193,7 @@ namespace NadekoBot.Services.Music while ((bytesRead = b.Read(buffer, 0, buffer.Length)) > 0 && (MaxPlaytimeSeconds <= 0 || MaxPlaytimeSeconds >= CurrentTime.TotalSeconds)) { + _log.Info("Sending stuff"); AdjustVolume(buffer, Volume); await pcm.WriteAsync(buffer, 0, bytesRead, cancelToken).ConfigureAwait(false); unchecked { _bytesSent += bytesRead; } @@ -309,6 +314,7 @@ namespace NadekoBot.Services.Music do { await Task.Delay(500); + _log.Info("Waiting for something to happen"); } while ((Queue.Count == 0 || Stopped) && !Exited); } diff --git a/src/NadekoBot/Services/Music/MusicService.cs b/src/NadekoBot/Services/Music/MusicService.cs index 2291b59a..aa5b35f0 100644 --- a/src/NadekoBot/Services/Music/MusicService.cs +++ b/src/NadekoBot/Services/Music/MusicService.cs @@ -282,6 +282,7 @@ namespace NadekoBot.Services.Music public async Task ResolveYoutubeSong(string query, string queuerName) { + _log.Info("Getting video"); var (link, video) = await GetYoutubeVideo(query); if (video == null) // do something with this error @@ -293,7 +294,8 @@ namespace NadekoBot.Services.Music //int gotoTime = 0; //if (m.Captures.Count > 0) // int.TryParse(m.Groups["t"].ToString(), out gotoTime); - + + _log.Info("Creating song info"); var song = new SongInfo { Title = video.Title.Substring(0, video.Title.Length - 10), // removing trailing "- You Tube" @@ -314,12 +316,14 @@ namespace NadekoBot.Services.Music private async Task<(string, YouTubeVideo)> GetYoutubeVideo(string query) { + _log.Info("Getting link"); var link = (await _google.GetVideoLinksByKeywordAsync(query).ConfigureAwait(false)).FirstOrDefault(); if (string.IsNullOrWhiteSpace(link)) { _log.Info("No song found."); return (null, null); } + _log.Info("Getting all videos"); var allVideos = await Task.Run(async () => { try { return await YouTube.Default.GetAllVideosAsync(link).ConfigureAwait(false); } catch { return Enumerable.Empty(); } }).ConfigureAwait(false); var videos = allVideos.Where(v => v.AdaptiveKind == AdaptiveKind.Audio); var video = videos