This repository has been archived on 2024-12-22. You can view files and clone it, but cannot push or open issues or pull requests.
elliebot/src/EllieBot/Modules/Searches/Search/DefaultSearchServiceFactory.cs
Toastie c0cd161c90
Added initial version of the grpc api. Added relevant dummy settings to creds (they have no effect rn)
Yt searches now INTERNALLY return multiple results but there is no way right now to paginate plain text results
moved some stuff around
2024-10-03 17:24:13 +13:00

61 lines
No EOL
1.9 KiB
C#

using EllieBot.Modules.Searches.GoogleScrape;
using EllieBot.Modules.Searches.Youtube;
namespace EllieBot.Modules.Searches;
public sealed class DefaultSearchServiceFactory : ISearchServiceFactory, IEService
{
private readonly SearchesConfigService _scs;
private readonly SearxSearchService _sss;
private readonly YtDlpSearchService _ytdlp;
private readonly GoogleSearchService _gss;
private readonly YoutubeDataApiSearchService _ytdata;
private readonly InvidiousYtSearchService _iYtSs;
private readonly GoogleScrapeService _gscs;
public DefaultSearchServiceFactory(
SearchesConfigService scs,
GoogleSearchService gss,
GoogleScrapeService gscs,
SearxSearchService sss,
YtDlpSearchService ytdlp,
YoutubeDataApiSearchService ytdata,
InvidiousYtSearchService iYtSs)
{
_scs = scs;
_sss = sss;
_ytdlp = ytdlp;
_gss = gss;
_gscs = gscs;
_iYtSs = iYtSs;
_ytdata = ytdata;
}
public ISearchService GetSearchService(string? hint = null)
=> _scs.Data.WebSearchEngine switch
{
WebSearchEngine.Google => _gss,
WebSearchEngine.Google_Scrape => _gscs,
WebSearchEngine.Searx => _sss,
_ => _gss
};
public ISearchService GetImageSearchService(string? hint = null)
=> _scs.Data.ImgSearchEngine switch
{
ImgSearchEngine.Google => _gss,
ImgSearchEngine.Searx => _sss,
_ => _gss
};
public IYoutubeSearchService GetYoutubeSearchService(string? hint = null)
=> _scs.Data.YtProvider switch
{
YoutubeSearcher.YtDataApiv3 => _ytdata,
YoutubeSearcher.Invidious => _iYtSs,
YoutubeSearcher.Ytdlp => _ytdlp,
_ => throw new ArgumentOutOfRangeException()
};
}