diff --git a/src/NadekoBot/Modules/Music/Classes/MusicControls.cs b/src/NadekoBot/Modules/Music/Classes/MusicControls.cs index 257b319f..be726c84 100644 --- a/src/NadekoBot/Modules/Music/Classes/MusicControls.cs +++ b/src/NadekoBot/Modules/Music/Classes/MusicControls.cs @@ -152,10 +152,6 @@ 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 496de92c..7892e278 100644 --- a/src/NadekoBot/Modules/Music/Classes/SongHandler.cs +++ b/src/NadekoBot/Modules/Music/Classes/SongHandler.cs @@ -76,21 +76,16 @@ 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.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"); + 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(); 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 a3b15204..9751c938 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(3).Select(async id => + var tasks = Task.WhenAll(ids.Take(5).Select(async id => { if (cancelSource.Token.IsCancellationRequested) return; @@ -874,9 +874,8 @@ $"{("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 c2300bd0..259fe88f 100644 --- a/src/NadekoBot/ShardedDiscordClient.cs +++ b/src/NadekoBot/ShardedDiscordClient.cs @@ -80,8 +80,7 @@ namespace NadekoBot private Task Client_Log(LogMessage arg) { - _log.Warn(arg.Message); - _log.Error(arg.Exception); + _log.Warn(arg.Exception, arg.Message); return Task.CompletedTask; }