Error logging
This commit is contained in:
parent
725d844131
commit
2d1cfad07f
@ -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.");
|
||||
|
@ -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<YouTubeVideo>(); } }).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<YouTubeVideo>(); } }).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.");
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user