Beispiel #1
0
        public Chapter[] GetUpdates()
        {
            List <Chapter> result   = new List <Chapter>();
            string         jsonText = MangaDex.GetMangaJSON(MangaDex.GetMangaUrl(GetID()));
            JObject        jobj     = JObject.Parse(jsonText);

            foreach (JProperty p in jobj["chapter"])
            {
                JToken value = p.Value;
                if (value.Type == JTokenType.Object)
                {
                    JObject o       = (JObject)value;
                    string  chapNum = (String)o["chapter"];
                    if (((string)o["lang_code"]).Equals(userlang))
                    {
                        // Console.WriteLine(chapNum);
                        string chapID = ((JProperty)value.Parent).Name;
                        if (!Directory.Exists(Path.Combine(mangaRoot.FullName, chapID)))
                        {
                            DirectoryInfo chapDir    = FileHelper.CreateFolder(mangaRoot, chapID);
                            Chapter       newchapter = new Chapter(chapDir, chapID, chapNum);
                            chapters.Add(newchapter);
                            result.Add(newchapter);
                        }
                    }
                }
            }
            return(result.ToArray());
        }
Beispiel #2
0
        /// <summary>
        /// Creates manga.txt, then calls Load()
        /// </summary>
        /// <param name="mangaUrl"></param>
        private void Create(string mangaUrl)
        {
            string jsonText = MangaDex.GetMangaJSON(mangaUrl);

            JObject jobj  = JObject.Parse(jsonText);
            string  title = (string)jobj["manga"]["title"];

            string lang_code = "gb";

            FileHelper.CreateFolder(FileHelper.APP_ROOT, MangaDex.GetMangaID(mangaUrl));
            File.WriteAllLines(Path.Combine(mangaRoot.FullName, "manga.txt"), new string[] {
                "manga",
                MangaDex.GetMangaID(mangaUrl),
                title,
                lang_code,    // TODO: Custom user languages
                "^any-group", // TODO: Custom user groups
                title,        // TODO: Custom user title
                "1", "1",     // Chapter 1, page 1
                "1"           // TODO: Get latest chapter for language and group
            });

            foreach (JProperty p in jobj["chapter"])
            {
                JToken value = p.Value;
                if (value.Type == JTokenType.Object)
                {
                    JObject o       = (JObject)value;
                    string  chapNum = (String)o["chapter"];
                    if (((string)o["lang_code"]).Equals(lang_code))
                    {
                        // Console.WriteLine(chapNum);
                        string        chapID  = ((JProperty)value.Parent).Name;
                        DirectoryInfo chapDir = FileHelper.CreateFolder(mangaRoot, chapID);
                        chapters.Add(new Chapter(chapDir, chapID, chapNum));
                    }
                }
            }

            Load();
        }