diff --git a/src/NadekoBot/Modules/Music/Classes/MusicControls.cs b/src/NadekoBot/Modules/Music/Classes/MusicControls.cs index be726c84..257b319f 100644 --- a/src/NadekoBot/Modules/Music/Classes/MusicControls.cs +++ b/src/NadekoBot/Modules/Music/Classes/MusicControls.cs @@ -152,6 +152,10 @@ namespace NadekoBot.Modules.Music.Classes } catch (OperationCanceledException) { } + catch (TimeoutException) { + Console.WriteLine("Bot couldn't connect to the channel. Most likely insufficient permissions. Fix permissions, then queue songs again"); + ClearQueue(); + } catch (Exception ex) { Console.WriteLine("Music thread almost crashed."); diff --git a/src/NadekoBot/Modules/Music/Classes/SongHandler.cs b/src/NadekoBot/Modules/Music/Classes/SongHandler.cs index 7892e278..496de92c 100644 --- a/src/NadekoBot/Modules/Music/Classes/SongHandler.cs +++ b/src/NadekoBot/Modules/Music/Classes/SongHandler.cs @@ -76,16 +76,21 @@ namespace NadekoBot.Modules.Music.Classes }) { TotalTime = TimeSpan.FromMilliseconds(svideo.Duration) }; } - + Console.WriteLine("Getting video id"); var link = (await NadekoBot.Google.GetVideosByKeywordsAsync(query).ConfigureAwait(false)).FirstOrDefault(); + Console.WriteLine("Done getting video id"); if (string.IsNullOrWhiteSpace(link)) throw new OperationCanceledException("Not a valid youtube query."); - 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 - .Where(v => v.AudioBitrate < 256) - .OrderByDescending(v => v.AudioBitrate) - .FirstOrDefault(); + //var allVideos = await Task.Run(async () => { try { return await YouTube.Default.GetVideoAsync(link).ConfigureAwait(false); } catch { return Enumerable.Empty(); } }).ConfigureAwait(false); + //var videos = allVideos.Where(v => v.AdaptiveKind == AdaptiveKind.Audio); + //var video = videos + // .Where(v => v.AudioBitrate < 256) + // .OrderByDescending(v => v.AudioBitrate) + // .FirstOrDefault(); + + Console.WriteLine("Getting video itself"); + var video = await YouTube.Default.GetVideoAsync(link).ConfigureAwait(false); + Console.WriteLine("Done getting video"); if (video == null) // do something with this error throw new Exception("Could not load any video elements based on the query."); diff --git a/src/NadekoBot/Modules/Music/Music.cs b/src/NadekoBot/Modules/Music/Music.cs index 9751c938..a3b15204 100644 --- a/src/NadekoBot/Modules/Music/Music.cs +++ b/src/NadekoBot/Modules/Music/Music.cs @@ -325,7 +325,7 @@ $"{("tracks".SnPl(musicPlayer.Playlist.Count))} | {(int)total.TotalHours}h {tota while (ids.Any() && !cancelSource.IsCancellationRequested) { - var tasks = Task.WhenAll(ids.Take(5).Select(async id => + var tasks = Task.WhenAll(ids.Take(3).Select(async id => { if (cancelSource.Token.IsCancellationRequested) return; @@ -874,8 +874,9 @@ $"{("tracks".SnPl(musicPlayer.Playlist.Count))} | {(int)total.TotalHours}h {tota try { musicPlayer.ThrowIfQueueFull(); + Console.WriteLine("Resolving"); resolvedSong = await SongHandler.ResolveSong(query, musicType).ConfigureAwait(false); - + Console.WriteLine("Resolved"); if (resolvedSong == null) throw new SongNotFoundException(); diff --git a/src/NadekoBot/ShardedDiscordClient.cs b/src/NadekoBot/ShardedDiscordClient.cs index 259fe88f..c2300bd0 100644 --- a/src/NadekoBot/ShardedDiscordClient.cs +++ b/src/NadekoBot/ShardedDiscordClient.cs @@ -80,7 +80,8 @@ namespace NadekoBot private Task Client_Log(LogMessage arg) { - _log.Warn(arg.Exception, arg.Message); + _log.Warn(arg.Message); + _log.Error(arg.Exception); return Task.CompletedTask; }