コード例 #1
0
        /// <summary>
        /// Downloads a certain chapter
        /// </summary>
        /// <param name="Chapter">Chapter to download</param>
        public async Task DownloadChapterAsync(MangaChapter Chapter)
        {
            // Loads all pages images and page count
            Chapter.Load( );

            HTTP.DownloadProgressChanged += HTTP_DownloadProgressChanged;

            CurrentDownloadingChapter = Chapter;

            // Creates a ChapterFileProcessor
            using (var pageProcessor = GetFileProcessor(Chapter))
            {
                // Loops through all pages
                for (var i = 0; i < Chapter.Pages; i++)
                {
                    var page = Chapter.PageLinks[i];

                    // Saves the file bytes
                    await pageProcessor.SaveFileAsync(
                        // 00X.ext file formats
                        i.ToString( ).PadLeft ( 3, '0' ) + Path.GetExtension(page),
                        // Downloads the bytes from the image
                        await HTTP.GetDataAsync(page)
                        );
                }
            }

            CurrentDownloadingChapter = null;

            HTTP.DownloadProgressChanged -= HTTP_DownloadProgressChanged;
        }
コード例 #2
0
            /// <summary>
            /// Initializes a chapter processor
            /// </summary>
            /// <param name="Chapter"></param>
            public ChapterFileProcessor(MangaChapter Chapter)
            {
                root = new IO(ConfigsManager.SavePath)
                       .PathForChapter(Chapter);
                this.Chapter = Chapter;

                if (Compressed = ConfigsManager.CompressChapters)
                {
                    ZipFile = new ZipFile(root + ".cbz");
                }
            }
コード例 #3
0
 /// <summary>
 /// Saves all bytes to the file according to the user's settings
 /// (compression, etc.)
 /// </summary>
 /// <param name="Chapter">Chapter that is being downloaded</param>
 public static ChapterFileProcessor GetFileProcessor(MangaChapter Chapter)
 {
     return(new ChapterFileProcessor(Chapter));
 }
コード例 #4
0
 /// <summary>
 /// Gets all page images links for a given chapter
 /// </summary>
 /// <param name="Chapter">The chapter</param>
 /// <returns></returns>
 public abstract Task <String[]> GetPageLinksAsync(MangaChapter Chapter);