f52aa6123b
Replaces generic RawType with ByteDocument in downloaders and context classes, simplifying type usage. Adds builder classes for FailurePredicateOptions, FragmentOptions, SkipPredicateOptions, and UnitDownloaderOptions to improve configuration flexibility. Introduces DownloadTarget enum and SkipPredicate delegate for more granular download control. Refactors Fluent API interfaces and implementations to remove RawType generics and streamline usage. Adds Playwright and Stealth download strategies for extensibility.
45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using System.Collections.Concurrent;
|
|
using System.Text.Json;
|
|
using Beam.Abstractions;
|
|
using Beam.Models;
|
|
|
|
namespace Beam.Fluent;
|
|
|
|
internal sealed class DownloadStage<OutType>(DownloadEnumerable<OutType> download) : IDownloadStage<OutType> {
|
|
private IAsyncEnumerable<Ordered<OutType>> _download = download;
|
|
|
|
public DownloadEnumerable<OutType> AsAsyncEnumerable() {
|
|
return new DownloadEnumerable<OutType>(_download.GetAsyncEnumerator());
|
|
}
|
|
|
|
private async IAsyncEnumerable<Ordered<OutType>> _SaveToDirectory(string dir) {
|
|
Directory.CreateDirectory(dir);
|
|
await foreach (var download in _download) {
|
|
await System.IO.File.WriteAllTextAsync(
|
|
Path.Combine(dir, $"{Path.GetRandomFileName()}.{download.Order}.json"),
|
|
JsonSerializer.Serialize(dir));
|
|
yield return download;
|
|
}
|
|
}
|
|
|
|
public IDownloadStage<OutType> SaveToDirectory(string dir) {
|
|
_download = _SaveToDirectory(dir);
|
|
return this;
|
|
}
|
|
|
|
public IDownloadStage<OutType> SaveToFiles(IEnumerable<string> files) {
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public IDownloadStage<OutType> SaveToMemory(ConcurrentBag<OutType> bag) {
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public void WaitForDownload() {
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task WaitForDownloadAsync() {
|
|
throw new NotImplementedException();
|
|
}
|
|
} |