2021-10-29 22:35:34 +01:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
using SpotifyAPI.Web;
|
|
|
|
using StackExchange.Redis;
|
|
|
|
|
|
|
|
namespace Selector.Cache
|
2021-11-29 21:04:15 +00:00
|
|
|
{
|
|
|
|
public class CachingAudioFeatureInjectorFactory: IAudioFeatureInjectorFactory {
|
2021-10-29 22:35:34 +01:00
|
|
|
|
|
|
|
private readonly ILoggerFactory LoggerFactory;
|
|
|
|
private readonly IDatabaseAsync Db;
|
|
|
|
|
|
|
|
public CachingAudioFeatureInjectorFactory(
|
|
|
|
ILoggerFactory loggerFactory,
|
|
|
|
IDatabaseAsync db
|
|
|
|
) {
|
|
|
|
LoggerFactory = loggerFactory;
|
|
|
|
Db = db;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<IConsumer> Get(ISpotifyConfigFactory spotifyFactory, IPlayerWatcher watcher = null)
|
|
|
|
{
|
|
|
|
var config = await spotifyFactory.GetConfig();
|
|
|
|
var client = new SpotifyClient(config);
|
|
|
|
|
|
|
|
return new CachingAudioFeatureInjector(
|
|
|
|
watcher,
|
|
|
|
Db,
|
|
|
|
client.Tracks,
|
|
|
|
LoggerFactory.CreateLogger<CachingAudioFeatureInjector>()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|