From 30fde5fa83e6109d2c03686c55c107faf41719f7 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 21 Aug 2016 00:41:15 +0200 Subject: [PATCH] Fixed ~yt definitely? --- src/NadekoBot/Services/Impl/YoutubeService.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/Services/Impl/YoutubeService.cs b/src/NadekoBot/Services/Impl/YoutubeService.cs index bcc44fa2..94290894 100644 --- a/src/NadekoBot/Services/Impl/YoutubeService.cs +++ b/src/NadekoBot/Services/Impl/YoutubeService.cs @@ -45,8 +45,11 @@ namespace NadekoBot.Services.Impl public async Task> FindRelatedVideosAsync(string id, int count = 1) { - Contract.Requires(!string.IsNullOrWhiteSpace(id)); - Contract.Requires(count > 0); + if (string.IsNullOrWhiteSpace(id)) + throw new ArgumentNullException(nameof(id)); + + if (count <= 0) + throw new ArgumentOutOfRangeException(nameof(count)); var match = new Regex("(?:youtu\\.be\\/|v=)(?[\\da-zA-Z\\-_]*)").Match(id); if (match.Length > 1) @@ -62,8 +65,11 @@ namespace NadekoBot.Services.Impl public async Task> FindVideosByKeywordsAsync(string keywords, int count = 1) { - Contract.Requires(!string.IsNullOrWhiteSpace(keywords)); - Contract.Requires(count > 0); + if (string.IsNullOrWhiteSpace(keywords)) + throw new ArgumentNullException(nameof(keywords)); + + if (count <= 0) + throw new ArgumentOutOfRangeException(nameof(count)); var query = yt.Search.List("snippet"); query.MaxResults = count;