2024-09-21 14:42:25 +12:00
using EllieBot.Modules.Searches.GoogleScrape ;
using EllieBot.Modules.Searches.Youtube ;
namespace EllieBot.Modules.Searches ;
2024-09-21 14:57:09 +12:00
public sealed class DefaultSearchServiceFactory : ISearchServiceFactory , IEService
2024-09-21 14:42:25 +12:00
{
private readonly SearchesConfigService _scs ;
private readonly SearxSearchService _sss ;
private readonly GoogleSearchService _gss ;
private readonly YtdlpYoutubeSearchService _ytdlp ;
private readonly YtdlYoutubeSearchService _ytdl ;
private readonly YoutubeDataApiSearchService _ytdata ;
private readonly InvidiousYtSearchService _iYtSs ;
private readonly GoogleScrapeService _gscs ;
public DefaultSearchServiceFactory (
SearchesConfigService scs ,
GoogleSearchService gss ,
GoogleScrapeService gscs ,
SearxSearchService sss ,
YtdlpYoutubeSearchService ytdlp ,
YtdlYoutubeSearchService ytdl ,
YoutubeDataApiSearchService ytdata ,
InvidiousYtSearchService iYtSs )
{
_scs = scs ;
_sss = sss ;
_gss = gss ;
_gscs = gscs ;
_iYtSs = iYtSs ;
_ytdlp = ytdlp ;
_ytdl = ytdl ;
_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 . Ytdlp = > _ytdlp ,
YoutubeSearcher . Ytdl = > _ytdl ,
YoutubeSearcher . Invidious = > _iYtSs ,
_ = > _ytdl
} ;
}