@@ -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.");
 | 
			
		||||
 
 | 
			
		||||
@@ -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<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");
 | 
			
		||||
                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();
 | 
			
		||||
 | 
			
		||||
                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(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();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user