Example #1
0
 internal static void ParseChapterPages(Chapter chapter, JToken token)
 {
     JToken pages = token["pages"];
     if (pages != null)
     {
         chapter.Pages = ParsePages(pages.Children());
     }
 }
Example #2
0
        public void GetChapterPages(Chapter chapter, int providerKey)
        {
            try
            {
                HttpClient client = new HttpClient();
                var response = client.GetStringAsync(string.Format(Urls.GetMangaChapterFromProvider, chapter.MangaKey, chapter.Key, providerKey)).Result;

                // Transform JSON into manga
                JsonHelper.ParseChapterPages(chapter, JObject.Parse(response));
            }
            catch (HttpRequestException)
            {
            }
        }
Example #3
0
        private static Chapter ParseChapter(string mangaKey, JToken token)
        {
            Chapter chapter = new Chapter();

            chapter.Key = token["_id"].Value<string>();
            chapter.MangaKey = mangaKey;
            chapter.ProviderKey = JsonHelper.ParseString(token["provider"]);
            chapter.PreviousChapterId = JsonHelper.ParseString(token["previous"]);
            chapter.NextChapterId = JsonHelper.ParseString(token["next"]);
            chapter.Number = JsonHelper.ParseInt(token["number"]);
            chapter.Title = JsonHelper.ParseString(token["title"]);
            chapter.Pages = ParsePages(token["pages"].Children());
            chapter.UploadedDate = ParseDateTime(JsonHelper.ParseInt(token["uploadedDate"]));

            return chapter;
        }
Example #4
0
        public void GetChapterPages(Chapter chapter)
        {
            try
            {
                // Check if we already have the pages in memory
                if (chapter.Pages != null && chapter.Pages.Count() > 0)
                {
                    return;
                }

                HttpClient client = new HttpClient();
                var response = client.GetStringAsync(string.Format(Urls.GetMangaChapter, chapter.MangaKey, chapter.Key)).Result;

                // Transform JSON into chapter
                JsonHelper.ParseChapterPages(chapter, JObject.Parse(response));
            }
            catch (HttpRequestException)
            {
            }
        }
Example #5
0
        public async void DownloadMangaChapter(Chapter chapter)
        {
            if (chapter.Pages == null)
            {
                this.GetChapterPages(chapter);
                if (chapter.Pages == null)
                {
                    return;
                }
            }

            StorageFolder folder = FileSystemUtilities.GetFolder(ApplicationData.Current.LocalFolder, Constants.DownloadsFolderPath);

            if (folder != null)
            {
                // TODO: CREATE A NAME IN A WAY THAT WE CAN GET INFORMATION FROM IT!!! (SOMETHING LIKE MANGANAME_CHAPTERNUMBER)
                var file = await folder.CreateFileAsync(chapter.Key, CreationCollisionOption.ReplaceExisting);
                using (var archiveStream = await file.OpenStreamForWriteAsync())
                {
                    ZipArchive archive = new ZipArchive(archiveStream);

                    HttpClient client = new HttpClient();
                    for (int i = 0; i < chapter.Pages.Count; i++)
                    {
                        var data = await client.GetByteArrayAsync(chapter.Pages[i]);

                        var entry = archive.CreateEntry(Path.Combine("i + 1", Path.GetExtension(chapter.Pages[i])));
                        using (var stream = entry.Open())
                        {
                            stream.Write(data, 0, data.Length);
                        }
                    }
                }

                chapter.IsDownloaded = true;
            }
        }
Example #6
0
 public void GetChapterPages(Chapter chapter, int providerKey)
 {
     throw new NotImplementedException();
 }
Example #7
0
 public void GetChapterPages(Chapter chapter)
 {
     throw new NotImplementedException();
 }
Example #8
0
 public void DownloadMangaChapters(Chapter start, Chapter end)
 {
     throw new NotImplementedException();
 }
Example #9
0
 public void DownloadMangaChapter(Chapter chapter)
 {
     throw new NotImplementedException();
 }