mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-12-27 12:35:35 +08:00
adc91cc4f3
* feat(core): connect to danmaku server with buvid3 * make buvid3 nullable & add json serializer setting * fix test * fix regex & make regex static * remove anonHttpClient * remove MainHttpClient * split FetchAsTextAsync * GetAnonymousCookieAsync * use template string in TestCookieAsync * fix test * background get anonymous cookie * make jsonSerializerSettings static * fix uid parse logic * fix buvid match * remove GetAnonCookie * restore merge typo * fix comment * rename ICookieTester
55 lines
2.5 KiB
C#
55 lines
2.5 KiB
C#
using BililiveRecorder.Core;
|
|
using BililiveRecorder.Core.Api;
|
|
using BililiveRecorder.Core.Api.Danmaku;
|
|
using BililiveRecorder.Core.Api.Http;
|
|
using BililiveRecorder.Core.Config.V3;
|
|
using BililiveRecorder.Core.Danmaku;
|
|
using BililiveRecorder.Core.Recording;
|
|
using BililiveRecorder.Core.Scripting;
|
|
using BililiveRecorder.Flv;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Polly.Registry;
|
|
|
|
namespace BililiveRecorder.DependencyInjection
|
|
{
|
|
public static class DependencyInjectionExtensions
|
|
{
|
|
public static IServiceCollection AddRecorderConfig(this IServiceCollection services, ConfigV3 config) => services
|
|
.AddSingleton(config)
|
|
.AddSingleton(sp => sp.GetRequiredService<ConfigV3>().Global)
|
|
;
|
|
|
|
public static IServiceCollection AddRecorder(this IServiceCollection services) => services
|
|
.AddSingleton<IMemoryStreamProvider, RecyclableMemoryStreamProvider>()
|
|
.AddRecorderPollyPolicy()
|
|
.AddRecorderApiClients()
|
|
.AddRecorderRecording()
|
|
.AddSingleton<IRecorder, Recorder>()
|
|
.AddSingleton<IRoomFactory, RoomFactory>()
|
|
.AddScoped<IBasicDanmakuWriter, BasicDanmakuWriter>()
|
|
.AddSingleton<UserScriptRunner>()
|
|
;
|
|
|
|
private static IServiceCollection AddRecorderPollyPolicy(this IServiceCollection services) => services
|
|
.AddSingleton<PollyPolicy>()
|
|
.AddSingleton<IReadOnlyPolicyRegistry<string>>(sp => sp.GetRequiredService<PollyPolicy>())
|
|
;
|
|
|
|
public static IServiceCollection AddRecorderApiClients(this IServiceCollection services) => services
|
|
.AddSingleton<HttpApiClient>()
|
|
.AddSingleton<ICookieTester>(sp => sp.GetRequiredService<HttpApiClient>())
|
|
.AddSingleton<PolicyWrappedApiClient<HttpApiClient>>()
|
|
.AddSingleton<IApiClient>(sp => sp.GetRequiredService<PolicyWrappedApiClient<HttpApiClient>>())
|
|
.AddSingleton<IDanmakuServerApiClient>(sp => sp.GetRequiredService<PolicyWrappedApiClient<HttpApiClient>>())
|
|
.AddScoped<IDanmakuClient, DanmakuClient>()
|
|
;
|
|
|
|
public static IServiceCollection AddRecorderRecording(this IServiceCollection services) => services
|
|
.AddScoped<IRecordTaskFactory, RecordTaskFactory>()
|
|
.AddScoped<IFlvProcessingContextWriterFactory, FlvProcessingContextWriterWithFileWriterFactory>()
|
|
.AddScoped<IFlvTagReaderFactory, FlvTagReaderFactory>()
|
|
.AddScoped<ITagGroupReaderFactory, TagGroupReaderFactory>()
|
|
;
|
|
}
|
|
}
|