public MangaArchiveCacheObject(MangaObject MangaObject, BookmarkObject BookmarkObject)
            : base()
        {
            SetValue(GuidPropertyKey, Guid.NewGuid());
            this.MangaObject = MangaObject;
            this.BookmarkObject = BookmarkObject;
            if (!this.Empty() && !BookmarkObject.Equals(this.BookmarkObject, null))
            {
                this.SetValue(IsNewPropertyKey, false);
                this.SetValue(ResumeChapterObjectPropertyKey, this.MangaObject.ChapterObjectOfBookmarkObject(this.BookmarkObject));

                Int32 ResumeChapterObjectIndex = this.MangaObject.IndexOfChapterObject(this.ResumeChapterObject) + 1;
                this.SetValue(HasMoreToReadPropertyKey, ResumeChapterObjectIndex < this.MangaObject.Chapters.Count);

                this.SetValue(ChapterProgressMaximumPropertyKey, this.MangaObject.Chapters.Count);
                this.SetValue(ChapterProgressPropertyKey, ResumeChapterObjectIndex);
            }
            else if (!this.Empty())
            {
                this.SetValue(IsNewPropertyKey, true);
                this.SetValue(HasMoreToReadPropertyKey, true);
                this.SetValue(ChapterProgressPropertyKey, 0);
                this.SetValue(ChapterProgressMaximumPropertyKey, 1);
            }
            this.LastUpdate = DateTime.Now;
        }
 public MangaArchiveInformationObject(MangaObject MangaObject, BookmarkObject BookmarkObject)
     : base()
 {
     this.MangaObject = MangaObject;
     this.BookmarkObject = BookmarkObject;
     if(!this.Empty())
         this.SetValue(ResumeChapterObjectPropertyKey, BookmarkObject.Equals(this.BookmarkObject, null) ? null : this.MangaObject.ChapterObjectOfBookmarkObject(this.BookmarkObject));
 }
Пример #3
0
 public MangaArchiveCacheObject(MangaObject MangaObject, BookmarkObject BookmarkObject)
     : base()
 {
     SetValue(GuidPropertyKey, Guid.NewGuid());
     this.MangaObject = MangaObject;
     this.BookmarkObject = BookmarkObject;
     if (!this.Empty() && !BookmarkObject.Equals(this.BookmarkObject, null))
         this.SetValue(ResumeChapterObjectPropertyKey, this.MangaObject.ChapterObjectOfBookmarkObject(this.BookmarkObject));
     this.LastUpdate = DateTime.Now;
 }
Пример #4
0
        private void OpenChapter(MangaObject MangaObject, ChapterObject ChapterObject)
        {
            this.MangaObject = MangaObject;
            this.ChapterObject = ChapterObject;

            String base_path = Path.Combine(App.CHAPTER_ARCHIVE_DIRECTORY, MangaObject.MangaFileName());
            this.ArchiveFilePath = Path.Combine(base_path, ChapterObject.ChapterArchiveName(App.CHAPTER_ARCHIVE_EXTENSION));
            ChapterObjectPreloadDictionary.Clear();
            try
            {
                ChapterObject PrevChapter = this.MangaObject.PrevChapterObject(this.ChapterObject);
                ChapterObjectPreloadDictionary.Add(this.PrevArchiveFilePath = Path.Combine(base_path, PrevChapter.ChapterArchiveName(App.CHAPTER_ARCHIVE_EXTENSION)), PrevChapter);
            }
            catch { this.PrevArchiveFilePath = null; }
            try
            {
                ChapterObject NextChapter = this.MangaObject.NextChapterObject(this.ChapterObject);
                ChapterObjectPreloadDictionary.Add(this.NextArchiveFilePath = Path.Combine(base_path, NextChapter.ChapterArchiveName(App.CHAPTER_ARCHIVE_EXTENSION)), NextChapter);
            }
            catch { this.NextArchiveFilePath = null; }

            LoadChapterObject();
            LoadBookmarkObject();
            this.ContinueReading = false;

            ChapterGarbageCollector();
            this.PullFocus();

            // TODO: Fix bug when loading still loading manga...
            // VerifyArchiveFile.VerifyArchive(App.ZipStorage, this.ArchiveFilePath);
        }
Пример #5
0
        static void Search()
        {
            Console.Write("Search Term: ");
            String SearchTerm = Console.ReadLine();
            List<MangaObject> SearchResults = new List<MangaObject>();
            while (SearchTerm != null && SearchTerm != String.Empty)
            {
                if (SearchResults.Count > 0 && SearchTerm.StartsWith("`"))
                {
                    Int32 srIndex = Int32.Parse(SearchTerm.Substring(1));
                    MangaObject mObj = SearchResults[srIndex];
                    mObj.LoadMangaObject();
                    mObj.SortChapters();
                    zip_storage.Write(String.Format("{0}/{1}", Environment.CurrentDirectory, String.Format("{0}.ma", mObj.Name).SafeFileName()), "MangaObject", mObj.Serialize(SaveType.XML));
                    //mObj.SaveToArchive(String.Format("{0}.ma", mObj.Name).SafeFileName(), "MangaObject", SaveType.XML);
                }
                else
                {
                    Dictionary<String, List<SearchResultObject>> RawSearchResults = new Dictionary<String, List<SearchResultObject>>();
                    foreach (ISiteExtension ise in SiteExtentions.Values)
                    {
                        ISiteExtensionDescriptionAttribute isea = ise.GetType().GetCustomAttribute<ISiteExtensionDescriptionAttribute>(false);
                        SearchRequestObject sro = ise.GetSearchRequestObject(searchTerm: SearchTerm);
                        Console.Write("Searching {0}...", isea.Name);

                        HttpWebRequest request = WebRequest.Create(sro.Url) as HttpWebRequest;
                        request.Referer = sro.Referer ?? request.Host;
                        request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
                        switch (sro.Method)
                        {
                            default:
                            case myMangaSiteExtension.Enums.SearchMethod.GET:
                                request.Method = "GET";
                                break;

                            case myMangaSiteExtension.Enums.SearchMethod.POST:
                                request.Method = "POST";
                                request.ContentType = "application/x-www-form-urlencoded";
                                using (var requestWriter = new StreamWriter(request.GetRequestStream()))
                                { requestWriter.Write(sro.RequestContent); }
                                break;
                        }

                        try
                        {
                            try
                            {
                                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                                {
                                    using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
                                    {
                                        foreach (SearchResultObject searchResultObject in ise.ParseSearch(streamReader.ReadToEnd()))
                                        {
                                            String keyName = new String(searchResultObject.Name.ToLower().Where(Char.IsLetterOrDigit).ToArray());
                                            if (!RawSearchResults.ContainsKey(keyName))
                                                RawSearchResults[keyName] = new List<SearchResultObject>();
                                            RawSearchResults[keyName].Add(searchResultObject);
                                        }
                                    }
                                }
                            }
                            catch (WebException ex)
                            {
                                using (HttpWebResponse response = ex.Response as HttpWebResponse)
                                {
                                    using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
                                    {
                                        foreach (SearchResultObject searchResultObject in ise.ParseSearch(streamReader.ReadToEnd()))
                                        {
                                            String keyName = new String(searchResultObject.Name.ToLower().Where(Char.IsLetterOrDigit).ToArray());
                                            if (!RawSearchResults.ContainsKey(keyName))
                                                RawSearchResults[keyName] = new List<SearchResultObject>();
                                            RawSearchResults[keyName].Add(searchResultObject);
                                        }
                                    }
                                }
                            }
                            Console.WriteLine("Done!");
                        }
                        catch
                        {
                            Console.WriteLine("Timeout!");
                        }
                    }

                    Dictionary<String, List<DatabaseObject>> RawDatabaseSearchResults = new Dictionary<String, List<DatabaseObject>>();
                    foreach (IDatabaseExtension ide in DatabaseExtentions.Values)
                    {
                        IDatabaseExtensionDescriptionAttribute idea = ide.GetType().GetCustomAttribute<IDatabaseExtensionDescriptionAttribute>(false);
                        SearchRequestObject SearchRequestObject = ide.GetSearchRequestObject(searchTerm: SearchTerm);
                        Console.Write("Searching {0}...", idea.Name);

                        HttpWebRequest request = WebRequest.Create(SearchRequestObject.Url) as HttpWebRequest;
                        request.Referer = idea.RefererHeader ?? request.Host;
                        request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
                        try
                        {
                            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                            {
                                using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
                                {
                                    foreach (DatabaseObject searchResultObject in ide.ParseSearch(streamReader.ReadToEnd()))
                                    {
                                        String keyName = new String(searchResultObject.Name.ToLower().Where(Char.IsLetterOrDigit).ToArray());
                                        if (!RawDatabaseSearchResults.ContainsKey(keyName))
                                            RawDatabaseSearchResults[keyName] = new List<DatabaseObject>();
                                        RawDatabaseSearchResults[keyName].Add(searchResultObject);
                                    }
                                }
                            }
                            Console.WriteLine("Done!");
                        }
                        catch
                        {
                            Console.WriteLine("Timeout!");
                        }
                    }

                    SearchResults.Clear();
                    foreach (String key in RawSearchResults.Keys)
                    {
                        List<SearchResultObject> SearchResultObjects = RawSearchResults[key];
                        MangaObject mangaObject = new MangaObject();
                        mangaObject.Merge(from SearchResultObject searchResultObject in SearchResultObjects select searchResultObject.ConvertToMangaObject());
                        if (RawDatabaseSearchResults.ContainsKey(key))
                        {
                            List<DatabaseObject> DatabaseObjects = RawDatabaseSearchResults[key];
                            mangaObject.AttachDatabase(DatabaseObjectExtensions.Merge(DatabaseObjects));
                        }
                        SearchResults.Add(mangaObject);
                    }

                    Console.WriteLine(String.Format("Search Term:{0}\n\tResults Found: {1}", SearchTerm, RawSearchResults.Count));
                    int i = 0;
                    foreach (MangaObject SearchResult in SearchResults)
                    {
                        Console.WriteLine(String.Format("[{0}]Name: {1}", i++, SearchResult.Name));
                        Console.WriteLine(String.Format("\tUrl: {0}", String.Join("\n\t     ", (from LocationObject location in SearchResult.Locations select location.Url).ToArray())));
                        Console.WriteLine(String.Format("\tDatabase: {0}", String.Join("\n\t          ", (from LocationObject location in SearchResult.DatabaseLocations select location.Url).ToArray())));
                        Console.WriteLine(String.Format("\tCover Url: {0}", String.Join("\n\t           ", SearchResult.Covers)));
                        Console.WriteLine(String.Format("\tDescription: {0}", String.Join("\n\t           ", SearchResult.Description)));
                        Console.WriteLine(String.Format("\tReleased: {0}", String.Join("\n\t           ", SearchResult.Released.ToLongDateString())));
                    }
                }
                Console.WriteLine();
                Console.WriteLine("`(index) to download info.");
                Console.WriteLine("Empty Search Term Exits Application.");
                Console.Write("Search Term: ");
                SearchTerm = Console.ReadLine();
            }
        }
Пример #6
0
        static void Main(string[] args)
        {
            MangaObject test = new MangaObject();
            test.Name = "Test";
            test.MangaType = myMangaSiteExtension.Enums.MangaObjectType.Unknown;

            Stream test_stream_1 = test.Serialize(SaveType.Binary);
            MangaObject test2 = test_stream_1.Deserialize<MangaObject>(SaveType.Binary);

            zip_storage = Core.Other.Singleton.Singleton<ZipStorage>.Instance;

            //SiteExtentions.Add("MangaReader", new AFTV_Network.MangaReader());
            //SiteExtentions.Add("MangaPanda", new AFTV_Network.MangaPanda());
            //SiteExtentions.Add("MangaHere", new MangaHere.MangaHere());
            //SiteExtentions.Add("Batoto", new Batoto.Batoto());
            SiteExtentions.Add("MangaTraders", new MangaTraders.MangaTraders());
            //SiteExtentions.Add("Batoto-Spanish", new Batoto.Batoto_Spanish());
            //SiteExtentions.Add("Batoto-German", new Batoto.Batoto_German());
            //SiteExtentions.Add("Batoto-French", new Batoto.Batoto_French());
            DatabaseExtentions.Add("MangaHelpers", new MangaHelpers.MangaHelpers());
            DatabaseExtentions.Add("AnimeNewsNetwork", new AnimeNewsNetwork.AnimeNewsNetwork());
            DatabaseExtentions.Add("MangaUpdatesBakaUpdates", new MangaUpdatesBakaUpdates.MangaUpdatesBakaUpdates());
            foreach (ISiteExtension ise in SiteExtentions.Values)
            {
                ISiteExtensionDescriptionAttribute isea = ise.GetType().GetCustomAttribute<ISiteExtensionDescriptionAttribute>(false);
                Console.WriteLine("Loaded Site Extention {0}", isea.Name);
            }
            foreach (IDatabaseExtension ise in DatabaseExtentions.Values)
            {
                IDatabaseExtensionDescriptionAttribute isea = ise.GetType().GetCustomAttribute<IDatabaseExtensionDescriptionAttribute>(false);
                Console.WriteLine("Loaded Database Extention {0}", isea.Name);
            }
            LoadManga();
            //Search();
            zip_storage.Dispose();
        }
Пример #7
0
        public MangaObject ParseMangaObject(string content)
        {
            if (content.ToLower().Contains("has been licensed, it is not available in MangaHere.".ToLower()))
                return null;
            HtmlDocument MangaObjectDocument = new HtmlDocument();
            MangaObjectDocument.LoadHtml(content);

            HtmlNode TitleNode = MangaObjectDocument.DocumentNode.SelectSingleNode("//h1[contains(@class,'title')]"),
                MangaDetailsNode = MangaObjectDocument.DocumentNode.SelectSingleNode("//div[contains(@class,'manga_detail')]"),
                MangaPropertiesNode = MangaDetailsNode.SelectSingleNode(".//div[1]"),
                MangaDesciptionNode = MangaObjectDocument.GetElementbyId("show"),
                AuthorsNode = MangaPropertiesNode.SelectSingleNode(".//ul/li[5]"),
                ArtistsNode = MangaPropertiesNode.SelectSingleNode(".//ul/li[6]"),
                GenresNode = MangaPropertiesNode.SelectSingleNode(".//ul/li[4]");
            HtmlNodeCollection AuthorsNodeCollection = AuthorsNode.SelectNodes(".//a"),
                ArtistsNodeCollection = ArtistsNode.SelectNodes(".//a");
            String Desciption = MangaDesciptionNode != null ? MangaDesciptionNode.FirstChild.InnerText : String.Empty,
                MangaName = HtmlEntity.DeEntitize(System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(TitleNode.LastChild.InnerText.ToLower()));

            String[] AlternateNames = MangaPropertiesNode.SelectSingleNode(".//ul/li[3]").LastChild.InnerText.Split(new String[] { "; " }, StringSplitOptions.RemoveEmptyEntries),
                Authors = { }, Artists = { },
                Genres = MangaPropertiesNode.SelectSingleNode(".//ul/li[4]").LastChild.InnerText.Split(new String[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
            if (AuthorsNodeCollection != null)
                Authors = (from HtmlNode AuthorNode in AuthorsNodeCollection select AuthorNode.InnerText).ToArray();
            if (ArtistsNodeCollection != null)
                Artists = (from HtmlNode ArtistNode in ArtistsNodeCollection select ArtistNode.InnerText).ToArray();

            List<ChapterObject> Chapters = new List<ChapterObject>();
            HtmlNodeCollection RawChapterList = MangaDetailsNode.SelectNodes(".//div[contains(@class,'detail_list')]/ul[1]/li");
            foreach (HtmlNode ChapterNode in RawChapterList)
            {
                String volNode = ChapterNode.SelectSingleNode(".//span[1]/span").InnerText;
                String[] volChapSub = { (volNode != null && volNode.Length > 0) ? volNode.Substring(4).Trim() : "0" };
                String ChapterTitle = ChapterNode.SelectSingleNode(".//span[1]/a").InnerText.Trim();
                String ChapterNumber = ChapterTitle.Substring(ChapterTitle.LastIndexOf(' ') + 1).Trim();
                volChapSub = volChapSub.Concat(ChapterNumber.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries)).ToArray();

                ChapterObject Chapter = new ChapterObject()
                {
                    Name = ChapterTitle,
                    Volume = UInt32.Parse(volChapSub[0]),
                    Chapter = UInt32.Parse(volChapSub[1]),
                    Locations = {
                        new LocationObject() {
                                ExtensionName = SiteExtensionDescriptionAttribute.Name,
                                Url = ChapterNode.SelectSingleNode(".//span[1]/a").Attributes["href"].Value }
                        },
                    Released = ChapterNode.SelectSingleNode(".//span[2]").InnerText.ToLower().Equals("today") ? DateTime.Today : (ChapterNode.SelectSingleNode(".//span[2]").InnerText.ToLower().Equals("yesterday") ? DateTime.Today.AddDays(-1) : DateTime.Parse(ChapterNode.SelectSingleNode(".//span[2]").InnerText))
                };
                if (volChapSub.Length == 3)
                    Chapter.SubChapter = UInt32.Parse(volChapSub[2]);
                Chapters.Add(Chapter);
            }
            Chapters.Reverse();
            String Cover = MangaPropertiesNode.SelectSingleNode(".//img[1]/@src").Attributes["src"].Value;
            Cover = Cover.Substring(0, Cover.LastIndexOf('?'));

            MangaObject MangaObj = new MangaObject()
            {
                Name = MangaName,
                Description = HtmlEntity.DeEntitize(Desciption),
                AlternateNames = AlternateNames.ToList(),
                Covers = { Cover },
                Authors = Authors.ToList(),
                Artists = Artists.ToList(),
                Genres = Genres.ToList(),
                Released = Chapters.First().Released,
                Chapters = Chapters
            };
            MangaObj.AlternateNames.RemoveAll(an => an.ToLower().Equals("none"));
            MangaObj.Genres.RemoveAll(g => g.ToLower().Equals("none"));
            return MangaObj;
        }
Пример #8
0
        public MangaObject ParseMangaObject(String content)
        {
            Int32 MangaInformationContentStart = content.IndexOf("<!-- Intro Series -->"),
                MangaInformationContentEnd = content.IndexOf("<!-- **END: Intro Series -->", MangaInformationContentStart);
            String MangaInformationContent = content.Substring(MangaInformationContentStart, MangaInformationContentEnd - MangaInformationContentStart);

            Int32 MangaChaptersContentStart = content.IndexOf("<!-- Main Content -->"),
                MangaChaptersContentEnd = content.IndexOf("<!-- **END: Main Content -->", MangaChaptersContentStart);
            String MangaChaptersContent = content.Substring(MangaChaptersContentStart, MangaChaptersContentEnd - MangaChaptersContentStart);

            HtmlDocument MangaObjectDocument = new HtmlDocument();
            MangaObjectDocument.LoadHtml(MangaInformationContent);

            HtmlNode MangaObjectNode = MangaObjectDocument.DocumentNode.SelectSingleNode(".//div/div");

            String MangaName = String.Empty,
                Description = String.Empty;
            List<String> AlternateNames = new List<String>(),
                AuthorsArtists = new List<String>(),
                Genres = new List<String>();

            foreach (HtmlNode DetailNode in MangaObjectNode.SelectNodes(".//div[2]/div[contains(@class,'row')]"))
            {
                HtmlNode DetailTypeNode = DetailNode.SelectSingleNode(".//div[1]/b[1] | .//div[1]/strong[1]"),
                    DetailTextNode = (DetailTypeNode != null) ? DetailTypeNode.NextSibling : null,
                    DetailDescriptionNode = (DetailTextNode != null) ? DetailTextNode.NextSibling : null,
                    MangaNameNode = DetailNode.SelectSingleNode(".//div[1]/h1");
                HtmlNodeCollection DetailLinkNodes = DetailNode.SelectNodes(".//div[1]/a");
                String DetailType = (DetailTypeNode != null) ? DetailTypeNode.InnerText.Trim().TrimEnd(':') : "MangaName",
                    DetailValue = String.Empty;
                String[] DetailValues = { };
                if (DetailLinkNodes != null)
                {
                    DetailValues = (from HtmlNode LinkNode in DetailLinkNodes select LinkNode.InnerText).ToArray();
                }
                else if (MangaNameNode != null)
                {
                    DetailValue = HtmlEntity.DeEntitize(MangaNameNode.InnerText.Trim());
                }
                else if (DetailDescriptionNode != null)
                {
                    DetailValue = HtmlEntity.DeEntitize(DetailDescriptionNode.InnerText.Trim());
                }
                else if (DetailTextNode != null)
                {
                    DetailValue = HtmlEntity.DeEntitize(DetailTextNode.InnerText.Trim());
                }

                switch (DetailType)
                {
                    default: break;
                    case "MangaName": MangaName = DetailValue; break;
                    case "Alternate Names": AlternateNames = (from String AltName in DetailValue.Split(',') select AltName.Trim()).ToList(); break;
                    case "Author": AuthorsArtists = DetailValues.ToList(); break;
                    case "Genre": Genres = DetailValues.ToList(); break;
                    case "Description": Description = DetailValue; break;
                }
            }

            String Cover = SiteExtensionDescriptionAttribute.RootUrl + MangaObjectNode.SelectSingleNode(".//div[1]/img/@src").Attributes["src"].Value;

            List<ChapterObject> Chapters = new List<ChapterObject>();
            MangaObjectDocument.LoadHtml(MangaChaptersContent);
            HtmlNodeCollection RawChapterList = MangaObjectDocument.DocumentNode.SelectNodes(".//div[contains(@class,'row')]");
            foreach (HtmlNode RawChapterNode in RawChapterList.Skip(1))
            {
                HtmlNode ChapterNumberNode = RawChapterNode.SelectSingleNode(".//div[1]/a"),
                    ReleaseDate = RawChapterNode.SelectSingleNode(".//div[2]/time");
                String ChapterNumber = Regex.Match(ChapterNumberNode.InnerText, @"\d+(\.\d+)?").Value;
                String[] ChapterSub = ChapterNumber.Trim().Split('.');

                ChapterObject Chapter = new ChapterObject()
                {
                    Name = HtmlEntity.DeEntitize(RawChapterNode.SelectSingleNode(".//div[1]/gray").InnerText),
                    Chapter = UInt32.Parse(ChapterSub[0]),
                    Locations =
                    {
                        new LocationObject(){
                            ExtensionName = SiteExtensionDescriptionAttribute.Name,
                            Url = SiteExtensionDescriptionAttribute.RootUrl + ChapterNumberNode.Attributes["href"].Value
                        },
                    },
                    Released = ReleaseDate.InnerText.ToLower().StartsWith("today") ? DateTime.Today : ReleaseDate.InnerText.ToLower().StartsWith("yesterday") ? DateTime.Today.AddDays(-1) : DateTime.Parse(ReleaseDate.InnerText.ToLower())
                };
                if (ChapterSub.Length == 2)
                    Chapter.SubChapter = UInt32.Parse(ChapterSub[1]);
                Chapters.Add(Chapter);
            }
            Chapters.Reverse();
            MangaObject MangaObj = new MangaObject()
            {
                Name = MangaName,
                Description = Description,
                AlternateNames = AlternateNames.ToList(),
                Covers = { Cover },
                Authors = AuthorsArtists.ToList(),
                Artists = AuthorsArtists.ToList(),
                Genres = Genres.ToList(),
                Released = Chapters.First().Released,
                Chapters = Chapters
            };
            MangaObj.AlternateNames.RemoveAll(an => an.ToLower().Equals("none"));
            MangaObj.Genres.RemoveAll(g => g.ToLower().Equals("none"));
            return MangaObj;
        }
 public ReadChapterRequestObject(MangaObject MangaObject, ChapterObject ChapterObject)
 {
     this.MangaObject = MangaObject;
     this.ChapterObject = ChapterObject;
 }