Files
nadekobot/src/NadekoBot/Modules/Searches/Search/Youtube/YoutubeDataApiSearchService.cs
Kwoth 3c108e531e dev: Added initial version of the grpc api. Added relevant dummy settings to creds (they have no effect rn)
dev: Yt searches now INTERNALLY return multiple results but there is no way right now to paginate plain text results
dev: moved some stuff around
2024-09-26 07:26:18 +00:00

23 lines
601 B
C#

namespace NadekoBot.Modules.Searches.Youtube;
public sealed class YoutubeDataApiSearchService : IYoutubeSearchService, INService
{
private readonly IGoogleApiService _gapi;
public YoutubeDataApiSearchService(IGoogleApiService gapi)
{
_gapi = gapi;
}
public async Task<VideoInfo[]?> SearchAsync(string query)
{
ArgumentNullException.ThrowIfNull(query);
var results = await _gapi.GetVideoLinksByKeywordAsync(query);
if(results.Count == 0)
return null;
return results.Map(r => new VideoInfo(r));
}
}