Exemplo n.º 1
0
        private List <ListEntry> NormalizeKitsuMangaList()
        {
            // Create temp list
            List <ListEntry> tmplistentries = new List <ListEntry>();

            foreach (Dictionary <String, Object> entry in this.tmplist)
            {
                int entryId = int.Parse((string)entry["id"]);
                int titleId = int.Parse((string)((JObject)((JObject)(((JObject)entry["relationships"]).ToObject <Dictionary <string, object> >()["manga"])).ToObject <Dictionary <string, object> >()["data"]).ToObject <Dictionary <string, object> >()["id"]);
                Dictionary <string, object> eattributes = ((JObject)entry["attributes"]).ToObject <Dictionary <string, object> >();
                Dictionary <string, object> attributes  = JObjectToDictionary((JObject)FindMetaData(titleId, EntryType.Manga)["attributes"]);
                RecordMappingIds(titleId, EntryType.Manga);
                String      title       = (String)attributes["canonicalTitle"];
                String      tmpstatus   = (String)eattributes["status"];
                bool        reconsuming = (bool)eattributes["reconsuming"];
                EntryStatus eStatus;
                switch (tmpstatus)
                {
                case "on_hold":
                    eStatus = EntryStatus.paused;
                    break;

                case "planned":
                    eStatus = EntryStatus.planning;
                    break;

                case "current":
                    eStatus = EntryStatus.current;
                    break;

                case "completed":
                    eStatus = EntryStatus.completed;
                    break;

                case "dropped":
                    eStatus = EntryStatus.dropped;
                    break;

                default:
                    eStatus = EntryStatus.current;
                    break;
                }
                int       progress        = Convert.ToInt32((long)eattributes["progress"]);
                int       progressVolumes = Convert.ToInt32((long)eattributes["volumesOwned"]);
                ListEntry newentry        = new ListEntry(titleId, title, eStatus, progress, progressVolumes);
                newentry.totalSegment     = !(object.ReferenceEquals(null, (attributes["chapterCount"]))) ? Convert.ToInt32((long)attributes["chapterCount"]) : 0;
                newentry.totalVolumes     = !(object.ReferenceEquals(null, (attributes["volumeCount"]))) ? Convert.ToInt32((long)attributes["volumeCount"]) : 0;
                newentry.mediaFormat      = (String)attributes["mangaType"];
                newentry.repeating        = reconsuming;
                newentry.repeatCount      = Convert.ToInt32((long)eattributes["reconsumeCount"]);
                newentry.personalComments = (String)eattributes["notes"];
                newentry.rating           = !object.ReferenceEquals(null, eattributes["ratingTwenty"]) ? ConvertRatingTwentyToRawScore(Convert.ToInt32((long)eattributes["ratingTwenty"])) : 0;
                if (!object.ReferenceEquals(null, eattributes["startedAt"]) && eattributes["startedAt"].GetType() == typeof(DateTime))
                {
                    DateTime startDate = (DateTime)eattributes["startedAt"];
                    newentry.startDate = startDate.Year + "-" + (startDate.Month < 10 ? "0" + startDate.Month.ToString() : startDate.Month.ToString()) + "-" + (startDate.Day < 10 ? "0" + startDate.Day.ToString() : startDate.Day.ToString());
                }
                else
                {
                    newentry.startDate = "0000-00-00";
                }
                if (!object.ReferenceEquals(null, eattributes["finishedAt"]) && eattributes["finishedAt"].GetType() == typeof(DateTime))
                {
                    DateTime finishDate = (DateTime)eattributes["finishedAt"];
                    newentry.endDate = finishDate.Year + "-" + (finishDate.Month < 10 ? "0" + finishDate.Month.ToString() : finishDate.Month.ToString()) + "-" + (finishDate.Day < 10 ? "0" + finishDate.Day.ToString() : finishDate.Day.ToString());
                }
                else
                {
                    newentry.endDate = "0000-00-00";
                }
                // Add entry
                tmplistentries.Add(newentry);
            }
            return(tmplistentries);
        }
Exemplo n.º 2
0
        private List <ListEntry> NormalizeAniListMangaList()
        {
            // Create temp list
            List <ListEntry> tmplistentries = new List <ListEntry>();

            foreach (Dictionary <String, Object> entry in this.tmplist)
            {
                int titleId = Convert.ToInt32((long)JObjectToDictionary((JObject)entry["id"])["id"]);
                int idMal   = !(object.ReferenceEquals(null, JObjectToDictionary((JObject)entry["id"])["idMal"])) ? Convert.ToInt32((long)JObjectToDictionary((JObject)entry["id"])["idMal"]) : -1;
                if (idMal > 0 && tconverter.RetreiveSavedMALIDFromServiceID(Service.AniList, titleId, EntryType.Manga) < 0)
                {
                    tconverter.SaveIDtoDatabase(Service.AniList, idMal, titleId, EntryType.Manga);
                }
                String      title       = (String)(JObjectToDictionary((JObject)(JObjectToDictionary((JObject)entry["title"]))["title"]))["title"];
                String      tmpstatus   = (String)entry["read_status"];
                bool        reconsuming = false;
                EntryStatus eStatus;
                switch (tmpstatus)
                {
                case "PAUSED":
                    eStatus = EntryStatus.paused;
                    break;

                case "PLANNING":
                    eStatus = EntryStatus.planning;
                    break;

                case "CURRENT":
                    eStatus = EntryStatus.current;
                    break;

                case "REPEATING":
                    reconsuming = true;
                    eStatus     = EntryStatus.current;
                    break;

                case "COMPLETED":
                    eStatus = EntryStatus.completed;
                    break;

                case "DROPPED":
                    eStatus = EntryStatus.dropped;
                    break;

                default:
                    eStatus = EntryStatus.current;
                    break;
                }
                int       progress        = Convert.ToInt32((long)entry["read_chapters"]);
                int       progressVolumes = Convert.ToInt32((long)entry["read_volumes"]);
                ListEntry newentry        = new ListEntry(titleId, title, eStatus, progress, progressVolumes);
                newentry.totalSegment     = (!object.ReferenceEquals(null, (JObjectToDictionary((JObject)entry["chapters"]))["chapters"])) ? Convert.ToInt32((long)(JObjectToDictionary((JObject)entry["chapters"]))["chapters"]) : 0;
                newentry.totalVolumes     = (!object.ReferenceEquals(null, (JObjectToDictionary((JObject)entry["volumes"]))["volumes"])) ? Convert.ToInt32((long)(JObjectToDictionary((JObject)entry["volumes"]))["volumes"]) : 0;
                newentry.mediaFormat      = (String)(JObjectToDictionary((JObject)entry["type"]))["format"];
                newentry.repeating        = reconsuming;
                newentry.repeatCount      = Convert.ToInt32((long)entry["reread_count"]);
                newentry.personalComments = (String)entry["notes"];
                newentry.rating           = Convert.ToInt32((long)entry["score"]);
                if (!object.ReferenceEquals(null, JObjectToDictionary((JObject)entry["read_start"])["year"]) && !object.ReferenceEquals(null, JObjectToDictionary((JObject)entry["read_start"])["month"]) && !object.ReferenceEquals(null, JObjectToDictionary((JObject)entry["read_start"])["day"]))
                {
                    newentry.startDate = (long)JObjectToDictionary((JObject)entry["read_start"])["year"] + "-" + ((long)JObjectToDictionary((JObject)entry["read_start"])["month"] < 10 ? "0" + ((long)JObjectToDictionary((JObject)entry["read_start"])["month"]).ToString() : ((long)JObjectToDictionary((JObject)entry["read_start"])["month"]).ToString()) + "-" + ((long)JObjectToDictionary((JObject)entry["read_start"])["day"] < 10 ? "0" + ((long)JObjectToDictionary((JObject)entry["read_start"])["day"]).ToString() : ((long)JObjectToDictionary((JObject)entry["read_start"])["day"]).ToString());
                }
                else
                {
                    newentry.startDate = "0000-00-00";
                }
                if (!object.ReferenceEquals(null, JObjectToDictionary((JObject)entry["read_end"])["year"]) && !object.ReferenceEquals(null, JObjectToDictionary((JObject)entry["read_end"])["month"]) && !object.ReferenceEquals(null, JObjectToDictionary((JObject)entry["read_end"])["day"]))
                {
                    newentry.endDate = (long)JObjectToDictionary((JObject)entry["read_end"])["year"] + "-" + ((long)JObjectToDictionary((JObject)entry["read_end"])["month"] < 10 ? "0" + ((long)JObjectToDictionary((JObject)entry["read_end"])["month"]).ToString() : ((long)JObjectToDictionary((JObject)entry["read_end"])["month"]).ToString()) + "-" + ((long)JObjectToDictionary((JObject)entry["read_end"])["day"] < 10 ? "0" + ((long)JObjectToDictionary((JObject)entry["read_end"])["day"]).ToString() : ((long)JObjectToDictionary((JObject)entry["read_end"])["day"]).ToString());
                }
                else
                {
                    newentry.endDate = "0000-00-00";
                }
                // Add entry
                tmplistentries.Add(newentry);
            }
            return(tmplistentries);
        }