Fixed ~yt definitely?
This commit is contained in:
parent
3e4ce6ad23
commit
30fde5fa83
@ -45,8 +45,11 @@ namespace NadekoBot.Services.Impl
|
|||||||
|
|
||||||
public async Task<IEnumerable<string>> FindRelatedVideosAsync(string id, int count = 1)
|
public async Task<IEnumerable<string>> FindRelatedVideosAsync(string id, int count = 1)
|
||||||
{
|
{
|
||||||
Contract.Requires<ArgumentNullException>(!string.IsNullOrWhiteSpace(id));
|
if (string.IsNullOrWhiteSpace(id))
|
||||||
Contract.Requires<ArgumentOutOfRangeException>(count > 0);
|
throw new ArgumentNullException(nameof(id));
|
||||||
|
|
||||||
|
if (count <= 0)
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(count));
|
||||||
|
|
||||||
var match = new Regex("(?:youtu\\.be\\/|v=)(?<id>[\\da-zA-Z\\-_]*)").Match(id);
|
var match = new Regex("(?:youtu\\.be\\/|v=)(?<id>[\\da-zA-Z\\-_]*)").Match(id);
|
||||||
if (match.Length > 1)
|
if (match.Length > 1)
|
||||||
@ -62,8 +65,11 @@ namespace NadekoBot.Services.Impl
|
|||||||
|
|
||||||
public async Task<IEnumerable<string>> FindVideosByKeywordsAsync(string keywords, int count = 1)
|
public async Task<IEnumerable<string>> FindVideosByKeywordsAsync(string keywords, int count = 1)
|
||||||
{
|
{
|
||||||
Contract.Requires<ArgumentNullException>(!string.IsNullOrWhiteSpace(keywords));
|
if (string.IsNullOrWhiteSpace(keywords))
|
||||||
Contract.Requires<ArgumentOutOfRangeException>(count > 0);
|
throw new ArgumentNullException(nameof(keywords));
|
||||||
|
|
||||||
|
if (count <= 0)
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(count));
|
||||||
|
|
||||||
var query = yt.Search.List("snippet");
|
var query = yt.Search.List("snippet");
|
||||||
query.MaxResults = count;
|
query.MaxResults = count;
|
||||||
|
Loading…
Reference in New Issue
Block a user