forked from EllieBotDevs/elliebot
Yt searches now INTERNALLY return multiple results but there is no way right now to paginate plain text results moved some stuff around
61 lines
No EOL
1.9 KiB
C#
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()
|
|
};
|
|
} |