Example #1
0
 /// <summary>
 /// Creates a new ChapterViewModel
 /// </summary>
 /// <param name="manga">Manga</param>
 /// <param name="chapter">Chapter to wrap</param>
 /// <param name="task">Mangas task</param>
 public ChapterViewModel(Manga manga, Chapter chapter, MangasTask task)
 {
     chapter_ = chapter;
     chapter_.Read += OnChapterRead;
     manga_ = manga;
     task_ = task;
 }
Example #2
0
 /// <summary>
 /// Called when a chapter has been added to the manga
 /// </summary>
 /// <param name="chapter">Added chapter</param>
 protected void OnMangaNewChapter(Chapter chapter)
 {
     chapter.Read += OnChapterRead;
     chapters_.Add(factory_.Create(manga_, chapter, task_));
     NotifyOfPropertyChange(() => Name);
     NotifyOfPropertyChange(() => Chapters);
     NotifyOfPropertyChange(() => CanReadAll);
 }
Example #3
0
 /// <summary>
 /// Adds a chapter to the manga
 /// </summary>
 /// <param name="chapter"></param>
 public void Add(Chapter chapter)
 {
     chapters_.AddFirst(chapter);
     if (NewChapter != null)
         NewChapter(chapter);
 }
Example #4
0
        /// <summary>
        /// Updates the given manga
        /// </summary>
        /// <param name="manga">Manga to update</param>
        /// <returns>If the manga was updated or not</returns>
        private async Task UpdateManga(Manga manga)
        {
            try
            {
                string data = await HttpHelper.Get(manga.Link);

                if (!string.IsNullOrEmpty(data))
                {
                    var document = XDocument.Parse(data);

                    var items = document.Root.Element("channel").Elements("item");

                    foreach (var item in items)
                    {
                        string description_item = item.Element("description").Value;
                        string link_item = item.Element("link").Value;
                        string title_item = item.Element("title").Value;

                        var description = parser_.ParseDescription(description_item);
                        float? number = parser_.ParseChapterNumber(title_item);

                        // We assume the link never changes (Since we don't have an uuid or something
                        // like that. Thanks MangaFox)
                        var chapter = manga.Chapters.FirstOrDefault(c => c.Link == link_item);

                        // Create a new chapter
                        if (chapter == null)
                        {
                            chapter = new Chapter();

                            chapter.Description = description.Item1;
                            chapter.Team = description.Item2;
                            chapter.Link = link_item;
                            chapter.Number = number;
                            chapter.Title = title_item;

                            manga.Add(chapter);
                        }
                        // Update data
                        else
                        {
                            chapter.Description = description.Item1;
                            chapter.Team = description.Item2;
                            chapter.Number = number;
                            chapter.Title = title_item;
                        }
                    }
                }

                log_.Info("Update", "Successfully updated the manga \"" + manga.Name + "\"");
            }
            catch (Exception e)
            {
                log_.Error("Update", "Could not update the manga \"" + manga.Name + "\": "
                    + e.Message);
            }
        }