Refactor downloaders to use ByteDocument and add options builders

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.
This commit is contained in:
qwsdcvghyu89
2025-11-15 22:51:46 +11:00
parent 647b2b0f37
commit f52aa6123b
34 changed files with 648 additions and 439 deletions
+10 -10
View File
@@ -6,15 +6,15 @@ using Beam.Stealth;
namespace Beam.Fluent;
public interface IContextStage<RawType, OutType> {
IContextStage<RawType, OutType> Configure(Action<DownloadContextBuilder<RawType>> configure);
IContextStage<RawType, OutType> WithParallelism(int degree);
IContextStage<RawType, OutType> WithTimeout(TimeSpan timeout);
IContextStage<RawType, OutType> WithRetryReporter(IProgress<IRetryReport> reporter);
IContextStage<RawType, OutType> UseFragments();
IContextStage<RawType, OutType> UsePlaywright(PlaywrightAsyncManipulator manipulator);
IContextStage<RawType, OutType> UseStealth(StealthAsyncManipulator manipulator, StealthConfig config);
IContextStage<RawType, OutType> ConfigureUnitDownloaderOptions(
Action<UnitDownloaderOptionsBuilder<RawType, OutType>> configure);
public interface IContextStage<OutType> {
IContextStage<OutType> Configure(Action<DownloadContextBuilder> configure);
IContextStage<OutType> WithParallelism(int degree);
IContextStage<OutType> WithTimeout(TimeSpan timeout);
IContextStage<OutType> WithRetryReporter(IProgress<IRetryReport> reporter);
IContextStage<OutType> UseFragments();
IContextStage<OutType> UsePlaywright(PlaywrightAsyncManipulator manipulator);
IContextStage<OutType> UseStealth(StealthAsyncManipulator manipulator, StealthConfig config);
IContextStage<OutType> ConfigureUnitDownloaderOptions(
Action<UnitDownloaderOptionsBuilder<OutType>> configure);
DownloadEnumerable<OutType> Build();
}
+4 -4
View File
@@ -2,10 +2,10 @@
namespace Beam.Fluent;
public interface IDownloadStage<RawType, OutType> {
IDownloadStage<RawType, OutType> SaveToDirectory(string dir);
IDownloadStage<RawType, OutType> SaveToFiles(IEnumerable<string> files);
IDownloadStage<RawType, OutType> SaveToMemory(ConcurrentBag<OutType> bag);
public interface IDownloadStage<OutType> {
IDownloadStage<OutType> SaveToDirectory(string dir);
IDownloadStage<OutType> SaveToFiles(IEnumerable<string> files);
IDownloadStage<OutType> SaveToMemory(ConcurrentBag<OutType> bag);
void WaitForDownload();
Task WaitForDownloadAsync();
DownloadEnumerable<OutType> AsAsyncEnumerable();
+2 -2
View File
@@ -3,6 +3,6 @@ using Beam.Models;
namespace Beam.Fluent;
public interface ITransformStage<RawType, OutType> {
IContextStage<RawType, OutType> WithTransformer(AsyncTransformer<RawType, OutType> factory);
public interface ITransformStage<OutType> {
IContextStage<OutType> WithTransformer(AsyncTransformer<ByteDocument, OutType> factory);
}