示例#1
0
 public ComicDownloadRequest(IComicSaver saver,
                             ComicEntity entity,
                             ComicDetail detail,
                             IReadOnlyCollection <DownloadItemRequest> requests,
                             IComicSourceProvider provider)
 {
     Detail           = detail;
     Entity           = entity;
     Saver            = saver;
     DownloadRequests = requests;
     Provider         = provider;
 }
        public static async Task <ComicDetail> GetChapterWithPageAsync(this IComicSourceProvider provider,
                                                                       string targetUrl,
                                                                       IChapterAnalysisNotifyer notifyer = null,
                                                                       CancellationToken token           = default(CancellationToken))
        {
            if (notifyer != null)
            {
                await notifyer.FetchingComicAsync(new ComicAnalysingContext { Address = targetUrl, Provider = provider });
            }
            var cap = await provider.GetChaptersAsync(targetUrl);

            if (notifyer != null)
            {
                await notifyer.FetchedComicAsync(new ComicAnalysedContext { Entity = cap, Address = targetUrl, Provider = provider });
            }
            token.ThrowIfCancellationRequested();
            var cwps = new List <ChapterWithPage>();

            for (int a = 0; a < cap.Chapters.Length; a++)
            {
                token.ThrowIfCancellationRequested();
                var c = cap.Chapters[a];
                if (notifyer != null)
                {
                    await notifyer.FetchingChapterAsync(new ChapterAnalysingContext { Chapter = c, Index = a, Entity = cap, Address = targetUrl, Provider = provider });
                }
                var pages = await provider.GetPagesAsync(c.TargetUrl);

                var cwp = new ChapterWithPage(c, pages);
                cwps.Add(cwp);
                if (notifyer != null)
                {
                    await notifyer.FetchedChapterAsync(new ChapterAnalysedContext { ChapterWithPage = cwp, Chapter = c, Index = a, Entity = cap, Address = targetUrl, Provider = provider });
                }
            }
            return(new ComicDetail
            {
                Entity = cap,
                Chapters = cwps.ToArray()
            });
        }
示例#3
0
 public StreamResourceFactory(IComicSourceProvider sourceProvider)
 {
     this.sourceProvider = sourceProvider ?? throw new ArgumentNullException(nameof(sourceProvider));
 }
示例#4
0
 public ComicSourceProviderHost(IComicSourceProvider comicSourceProvider, IServiceScope scope)
 {
     ComicSourceProvider = comicSourceProvider;
     Scope = scope;
 }
示例#5
0
 public PlatformResourceCreator(IComicSourceProvider provider)
 {
     this.provider = provider ?? throw new ArgumentNullException(nameof(provider));
 }