Esempio n. 1
0
        public void ProcessFromHTTPResult(XmlNode node, int anid)
        {
            this.AnimeID        = anid;
            this.TagID          = 0;
            this.Spoiler        = 0;
            this.LocalSpoiler   = 0;
            this.GlobalSpoiler  = 0;
            this.TagName        = string.Empty;
            this.TagDescription = string.Empty;
            this.TagCount       = 0;
            this.Approval       = 0;
            this.Weight         = 0;

            this.TagID = int.Parse(AniDBHTTPHelper.TryGetAttribute(node, "id"));

            int.TryParse(AniDBHTTPHelper.TryGetAttribute(node, "weight"), out int tapp);
            this.Weight = tapp;

            this.TagName        = AniDBHTTPHelper.TryGetProperty(node, "name")?.Replace('`', '\'');
            this.TagDescription = AniDBHTTPHelper.TryGetProperty(node, "description")?.Replace('`', '\'');

            bool.TryParse(AniDBHTTPHelper.TryGetAttribute(node, "localspoiler"), out bool lsp);
            this.Spoiler |= lsp ? 1 : 0;

            bool.TryParse(AniDBHTTPHelper.TryGetAttribute(node, "globalspoiler"), out bool gsp);
            this.Spoiler |= gsp ? 1 : 0;
        }
        public void ProcessFromHTTPResult(XmlNode node, int anid)
        {
            InitFields();

            this.AnimeID = anid;

            int.TryParse(AniDBHTTPHelper.TryGetAttribute(node, "id"), out int id);
            this.RelatedAnimeID = id;

            this.RelationType = AniDBHTTPHelper.TryGetAttribute(node, "type");
        }
Esempio n. 3
0
        public void ProcessFromHTTPResult(XmlNode node, int anid)
        {
            InitFields();

            this.AnimeID = anid;

            this.RecommendationTypeText = AniDBHTTPHelper.TryGetAttribute(node, "type");
            this.RecommendationText     = node.InnerText.Trim().Replace('`', '\'');

            int.TryParse(AniDBHTTPHelper.TryGetAttribute(node, "uid"), out int uid);
            this.UserID = uid;
        }
Esempio n. 4
0
        public void ProcessFromHTTPResult(XmlNode node, int anid)
        {
            this.AnimeID = anid;

            bool result = int.TryParse(AniDBHTTPHelper.TryGetAttribute(node, "type"), out int typeInt);

            if (!result)
            {
                return;
            }
            Type = (AniDB_ResourceLinkType)typeInt;
        }
Esempio n. 5
0
        public void ProcessFromHTTPResult(XmlNode node, int anid)
        {
            InitFields();

            this.AnimeID = anid;

            int.TryParse(AniDBHTTPHelper.TryGetAttribute(node, "id"), out int id);
            this.SimilarAnimeID = id;

            int.TryParse(AniDBHTTPHelper.TryGetAttribute(node, "approval"), out int appr);
            this.Approval = appr;

            int.TryParse(AniDBHTTPHelper.TryGetAttribute(node, "total"), out int tot);
            this.Total = tot;
        }
Esempio n. 6
0
        public void ProcessFromHTTPResult(XmlNode node, int anid)
        {
            InitFields();

            this.AnimeID  = anid;
            this.CharID   = int.Parse(AniDBHTTPHelper.TryGetAttribute(node, "id"));
            this.CharType = AniDBHTTPHelper.TryGetAttribute(node, "type");

            this.CharName        = AniDBHTTPHelper.TryGetProperty(node, "name")?.Replace('`', '\'');
            this.CharDescription = AniDBHTTPHelper.TryGetProperty(node, "description")?.Replace('`', '\'');
            this.EpisodeListRaw  = AniDBHTTPHelper.TryGetProperty(node, "episodes") ?? string.Empty;
            this.PicName         = AniDBHTTPHelper.TryGetProperty(node, "picture");

            CreatorListRaw = string.Empty;
            foreach (XmlNode nodeChild in node.ChildNodes)
            {
                if (nodeChild?.Name == "seiyuu")
                {
                    Raw_AniDB_Seiyuu seiyuu = new Raw_AniDB_Seiyuu();

                    if (nodeChild.Attributes?["id"] != null)
                    {
                        string creatorid = nodeChild.Attributes["id"].Value;
                        seiyuu.SeiyuuID = int.Parse(creatorid);

                        if (CreatorListRaw.Length > 0)
                        {
                            CreatorListRaw += ",";
                        }
                        CreatorListRaw += creatorid.Trim();
                    }

                    if (nodeChild.Attributes?["picture"] != null)
                    {
                        seiyuu.PicName = nodeChild.Attributes["picture"].Value;
                    }

                    seiyuu.SeiyuuName = nodeChild.InnerText.Replace('`', '\'');
                    Seiyuus.Add(seiyuu);
                }
            }
        }
Esempio n. 7
0
        public void ProcessFromHTTPResult(XmlNode node, int anid)
        {
            this.AnimeID   = anid;
            this.TitleType = string.Empty;
            this.Language  = string.Empty;
            this.Title     = string.Empty;

            this.TitleType = AniDBHTTPHelper.TryGetAttribute(node, "type");
            this.Language  = AniDBHTTPHelper.TryGetAttribute(node, "xml:lang");
            this.Title     = node.InnerText.Trim().Replace('`', '\'');

            // Title Types
            // -------------
            // main
            // official
            // syn / SYNONYM / SYNONYMs
            // short

            // Common Languages
            // en = english
            // x-jat = romaji
            // ja = kanji
        }
Esempio n. 8
0
        public void ProcessFromHTTPResult(XmlNode node, int anid)
        {
            this.AnimeID             = anid;
            this.CategoryID          = 0;
            this.ParentID            = 0;
            this.IsHentai            = 0;
            this.CategoryName        = string.Empty;
            this.CategoryDescription = string.Empty;
            this.Weighting           = 0;

            this.CategoryID = int.Parse(AniDBHTTPHelper.TryGetAttribute(node, "id"));
            this.ParentID   = int.Parse(AniDBHTTPHelper.TryGetAttribute(node, "parentid"));

            bool.TryParse(AniDBHTTPHelper.TryGetAttribute(node, "hentai"), out bool hentai);
            this.IsHentai = hentai ? 1 : 0;


            this.CategoryName        = AniDBHTTPHelper.TryGetProperty(node, "name");
            this.CategoryDescription = AniDBHTTPHelper.TryGetProperty(node, "description");

            int.TryParse(AniDBHTTPHelper.TryGetAttribute(node, "weight"), out int weight);
            this.Weighting = weight;
        }
Esempio n. 9
0
        public bool ProcessEpisodeSource(XmlNode node, int anid)
        {
            if (string.IsNullOrEmpty(node?.Attributes?["id"]?.Value))
            {
                return(false);
            }
            if (!int.TryParse(node?.Attributes?["id"]?.Value, out int id))
            {
                return(false);
            }
            EpisodeID = id;
            // default values
            LengthSeconds   = 0;
            Rating          = 0;
            Votes           = 0;
            EpisodeNumber   = 0;
            EpisodeType     = 1;
            AirDate         = 0;
            DateTimeUpdated = DateTime.Now;

            AnimeID = anid;

            string epno = AniDBHTTPHelper.TryGetProperty(node, "epno");

            EpisodeType     = GetEpisodeType(epno);
            EpisodeNumber   = GetEpisodeNumber(epno);
            IsDoubleEpisode = GetIsDoubleEpisode(epno);

            string length = AniDBHTTPHelper.TryGetProperty(node, "length");

            int.TryParse(length, out int lMinutes);
            int secs = lMinutes * 60;

            LengthSeconds = secs;

            NumberStyles style   = NumberStyles.Number;
            CultureInfo  culture = CultureInfo.CreateSpecificCulture("en-GB");

            if (decimal.TryParse(AniDBHTTPHelper.TryGetProperty(node, "rating"), style, culture, out decimal rating))
            {
                Rating = rating;
            }
            if (int.TryParse(AniDBHTTPHelper.TryGetAttribute(node, "rating", "votes"), out int votes))
            {
                Votes = votes;
            }

            // Titles
            foreach (XmlNode nodeChild in node.ChildNodes)
            {
                // Make sure that it's a title and has data
                if (!(nodeChild?.Name.Equals("title") ?? false) ||
                    string.IsNullOrEmpty(nodeChild.InnerText))
                {
                    continue;
                }

                // get language
                string language = nodeChild.Attributes?["xml:lang"]?.Value?.Trim().ToUpperInvariant();
                if (string.IsNullOrEmpty(language))
                {
                    continue;
                }
                string title = nodeChild.InnerText.Trim().Replace('`', '\'');

                using (var upd = Repo.Instance.AniDB_Episode_Title.BeginAddOrUpdate(() => Repo.Instance.AniDB_Episode_Title.GetByEpisodeIDAndLanguage(id, language).FirstOrDefault()))
                {
                    upd.Entity.AniDB_EpisodeID = id;
                    upd.Entity.Language        = language;
                    upd.Entity.Title           = title;
                    upd.Commit();
                }
            }

            string adate = AniDBHTTPHelper.TryGetProperty(node, "airdate");

            AirDate = Commons.Utils.AniDB.GetAniDBDateAsSeconds(adate, true);

            Description = AniDBHTTPHelper.TryGetProperty(node, "summary")?.Replace('`', '\'');
            IsValid     = true;
            return(true);
        }
Esempio n. 10
0
        public void ProcessHTTPSource(XmlNode node)
        {
            if (node == null)
            {
                logger.Warn("MyList item had a corrupted XML");
                return;
            }
            if (string.IsNullOrEmpty(node.Attributes?["id"]?.Value))
            {
                logger.Warn("MyList item has no ID" + "\n" + node);
                return;
            }
            ListID    = int.Parse(node.Attributes["id"].Value);
            AnimeID   = int.Parse(node.Attributes["aid"].Value);
            EpisodeID = int.Parse(node.Attributes["eid"].Value);
            FileID    = int.Parse(node.Attributes["fid"].Value);

            ViewDateHTTP = AniDBHTTPHelper.TryGetAttribute(node, "viewdate");

            // calculate the watched date
            if (!string.IsNullOrEmpty(ViewDateHTTP) && ViewDateHTTP.Length > 17)
            {
                try
                {
                    // eg "2011-02-23T20:49:18+0000"

                    /*int year = int.Parse(ViewDateHTTP.Trim().Substring(0, 4));
                     * int month = int.Parse(ViewDateHTTP.Trim().Substring(5, 2));
                     * int day = int.Parse(ViewDateHTTP.Trim().Substring(8, 2));
                     *
                     * int hour = int.Parse(ViewDateHTTP.Trim().Substring(11, 2));
                     * int minute = int.Parse(ViewDateHTTP.Trim().Substring(14, 2));
                     * int second = int.Parse(ViewDateHTTP.Trim().Substring(17, 2));
                     *
                     * DateTime utcDate = new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc);
                     */
                    if (!DateTime.TryParse(ViewDateHTTP, out DateTime utcDate))
                    {
                        logger.Error("Error processing View Date HTTP: " + ViewDateHTTP);
                    }
                    utcDate = utcDate.AddSeconds(ViewDateUDP);

                    WatchedDate = utcDate.ToLocalTime();
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "Error processing View Date HTTP: " + ex.ToString());
                }
            }

            string tempstate = AniDBHTTPHelper.TryGetProperty(node, "state");
            bool   state     = int.TryParse(tempstate, out int istate);

            if (state)
            {
                State = istate;
            }

            string fstate    = AniDBHTTPHelper.TryGetProperty(node, "filestate");
            bool   filestate = int.TryParse(fstate, out int ifilestate);

            if (filestate)
            {
                FileState = ifilestate;
            }

            if (!state && !filestate)
            {
                logger.Warn($"AniDB Sync_MyList - MyListItem with fid {FileID} has no 'State' or 'FileState'");
            }

            Source = AniDBHTTPHelper.TryGetProperty(node, "storage");
        }