public CalendarCollection(string sRecMessage) { /* * // 297 CALENDAR * 6622|1251417600|0 * 6551|1251417600|0 * 6652|1252108800|0 * 6635|1252540800|0 * 6698|1252627200|0 * 6489|1253145600|0 * 6653|1253750400|0 * 6684|1253836800|0 * 6781|1253836800|0 * 6763|1253923200|0 */ // DateFlags // 0 = normal start and end date (2010-01-31) // 1 = start date is year-month (2010-01) // 2 = start date is a year (2010) // 4 = normal start date, year-month end date // 8 = normal start date, year end date // 10 = start date is a year (2010) // 16 = normal start and end date (2010-01-31) // remove the header info string[] sDetails = sRecMessage.Substring(0).Split('\n'); if (sDetails.Length <= 2) { return; } for (int i = 1; i < sDetails.Length - 1; i++) // first item will be the status command, and last will be empty { //BaseConfig.MyAnimeLog.Write("s: {0}", sDetails[i]); Calendar cal = new Calendar(); string[] flds = sDetails[i].Substring(0).Split('|'); cal.AnimeID = int.Parse(flds[0]); cal.ReleaseDateRaw = flds[1]; cal.DateFlags = int.Parse(flds[2]); cal.ReleaseDate = AniDB.GetAniDBDateAsDate(flds[1], cal.DateFlags); calendars.Add(cal); //BaseConfig.MyAnimeLog.Write("grp: {0}", grp); } }
// constructor // sRecMessage is the message received from ANIDB file info command // example response like '220 FILE .....' public Raw_AniDB_Anime(string sRecMessage) { PopulateDefaults(); // remove the header info string[] sDetails = sRecMessage.Substring(10).Split('|'); //230 ANIME 0|0 // 0. 6107 ** anime id // 1. 2009 ** year // 2. TV Series ** type // 3. 979 ** related anime id's // 4. 32 ** related anime types // 5. Magic,Shounen,Manga,Military,Action ** genres // 6. 6,6,6,6,4 ** genreRAW weight // 7. Hagane no Renkinjutsushi (2009) ** romaji name // 8. Kanji Name // 9. Full Metal Alchemist: Brotherhood ** english name // 10. * other name // 11. FMA2'hagaren2 ** short name list (the apostrophe is the list separator) // 12. Fullmetal Alchemist: Brotherhood'Fullmetal Alchemist 2'Full Metal Alchemist 2'???????? ???????: ????????'St?lalkemisten'????????? ??????? ?????? : ??????'2 ????????? ??????? ??????'??????? ????? 2009'Metalinis Alchemikas 2'?????? 2009 ** synonyms // 13. 0 ** episodes // 14. 5 ** normal episode count // 15. 6 ** special episode count // 16. 1238889600 ** air date // 17. 0 ** end date // 18. http://www.hagaren.jp/ ** url // 19. 15097.jpg ** pic name // 20. 175,5,273,171,4 ** category id list // 21. 0 ** rating // 22. 0 ** vote count // 23. 846 ** temp rating (divide by 100) // 24. 416 ** temp vote count // 25. 0 ** average review rating // 26. 0 ** review count // 27. ** Award List // 28. 0 ** Restricted 18+ // 29. 0 Anime Planet ID // 30. 0 ANN ID // 31. 0 AllCinema ID // 32. 0 AnimeNfo ID // 33. 1238889600 ** last modified // 34. 705,2409,2410,2411,2412,2413,2414,2415 ** character id list // 35. 705,2409,2410,2411,2412,2413,2414,2415 ** review id list AnimeID = int.Parse(sDetails[0]); AnimeTypeRAW = AniDBAPILib.ProcessAniDBString(sDetails[2]); RelatedAnimeIdsRAW = AniDBAPILib.ProcessAniDBString(sDetails[3]); //BaseConfig.MyAnimeLog.Write("relatedAnimeIDs: {0}", sDetails[3]); //BaseConfig.MyAnimeLog.Write("relatedAnimeIDs: {0}", AniDBLib.ProcessAniDBString(sDetails[3])); RelatedAnimeTypesRAW = AniDBAPILib.ProcessAniDBString(sDetails[4]); //genreweight = sDetails[6]; //RomajiName = AniDBAPILib.ProcessAniDBString(sDetails[7]); //BaseConfig.MyAnimeLog.Write("English name old: **{0}**", sDetails[8]); //KanjiName = AniDBAPILib.ProcessAniDBString(sDetails[8]); //EnglishName = AniDBAPILib.ProcessAniDBString(sDetails[9]); //BaseConfig.MyAnimeLog.Write("English name new: **{0}**", englishName); //OtherName = AniDBAPILib.ProcessAniDBString(sDetails[10]); //ShortNames = AniDBAPILib.ProcessAniDBString(sDetails[11].Replace("'", "|")); //Synonyms = AniDBAPILib.ProcessAniDBString(sDetails[12].Replace("'", "|")); EpisodeCount = AniDBAPILib.ProcessAniDBInt(sDetails[13]); EpisodeCountNormal = AniDBAPILib.ProcessAniDBInt(sDetails[14]); EpisodeCountSpecial = AniDBAPILib.ProcessAniDBInt(sDetails[15]); int airDateSeconds = int.Parse(AniDBAPILib.ProcessAniDBString(sDetails[16])); int endDateSeconds = int.Parse(AniDBAPILib.ProcessAniDBString(sDetails[17])); AirDate = AniDB.GetAniDBDateAsDate(airDateSeconds); EndDate = AniDB.GetAniDBDateAsDate(endDateSeconds); URL = AniDBAPILib.ProcessAniDBString(sDetails[18]); Picname = AniDBAPILib.ProcessAniDBString(sDetails[19]); //categoryidlist = sDetails[20]; Rating = AniDBAPILib.ProcessAniDBInt(sDetails[21]); VoteCount = AniDBAPILib.ProcessAniDBInt(sDetails[22]); TempRating = AniDBAPILib.ProcessAniDBInt(sDetails[23]); TempVoteCount = AniDBAPILib.ProcessAniDBInt(sDetails[24]); AvgReviewRating = AniDBAPILib.ProcessAniDBInt(sDetails[25]); ReviewCount = AniDBAPILib.ProcessAniDBInt(sDetails[26]); AwardList = AniDBAPILib.ProcessAniDBString(sDetails[27]); Restricted = AniDBAPILib.ProcessAniDBInt(sDetails[28]); AnimePlanetID = AniDBAPILib.ProcessAniDBInt(sDetails[29]); ANNID = AniDBAPILib.ProcessAniDBInt(sDetails[30]); AllCinemaID = AniDBAPILib.ProcessAniDBInt(sDetails[31]); AnimeNfoID = AniDBAPILib.ProcessAniDBString(sDetails[32]); DateRecordUpdated = AniDBAPILib.ProcessAniDBString(sDetails[33]); CharacterIDListRAW = AniDBAPILib.ProcessAniDBString(sDetails[34]); ReviewIDListRAW = AniDBAPILib.ProcessAniDBString(sDetails[35]); //New version number VersionNumber = LastVersion; //Genres should by right in utf-16 GenreRAW = sDetails[5]; BeginYear = AirDate.HasValue ? AirDate.Value.Year : 0; EndYear = EndDate.HasValue ? EndDate.Value.Year : 0; foreach (int rid in this.ReviewIDList) { //BaseConfig.MyAnimeLog.Write("ReviewID: {0}", rid.ToString()); } /* * char[] chars = sDetails[5].ToCharArray(); * * foreach (char c in chars) * { * if ((int)c > 31 && (int)c < 127) * genreRAW += c.ToString(); * } */ }
public static Raw_AniDB_Anime ProcessAnimeDetails(XmlDocument docAnime, int animeID) { // most of the genral anime data will be over written by the UDP command Raw_AniDB_Anime anime = new Raw_AniDB_Anime { AnimeID = animeID }; // check if there is any data if (docAnime?["anime"]?.Attributes["id"]?.Value == null) { logger.Warn("AniDB ProcessAnimeDetails - Received no or invalid info in XML"); return(null); } anime.Description = TryGetProperty(docAnime, "anime", "description")?.Replace('`', '\''); anime.AnimeTypeRAW = TryGetProperty(docAnime, "anime", "type"); string episodecount = TryGetProperty(docAnime, "anime", "episodecount"); int.TryParse(episodecount, out int epCount); anime.EpisodeCount = epCount; anime.EpisodeCountNormal = epCount; int convertedAirDate = AniDB.GetAniDBDateAsSeconds(TryGetProperty(docAnime, "anime", "startdate"), true); int convertedEndDate = AniDB.GetAniDBDateAsSeconds(TryGetProperty(docAnime, "anime", "enddate"), false); //anime.AirDate = TryGetProperty(docAnime, "anime", "startdate"); //anime.EndDate = TryGetProperty(docAnime, "anime", "enddate"); anime.AirDate = AniDB.GetAniDBDateAsDate(convertedAirDate); anime.EndDate = AniDB.GetAniDBDateAsDate(convertedEndDate); anime.BeginYear = anime.AirDate?.Year ?? 0; anime.EndYear = anime.EndDate?.Year ?? 0; //string enddate = TryGetProperty(docAnime, "anime", "enddate"); string restricted = docAnime["anime"].Attributes["restricted"]?.Value; if (bool.TryParse(restricted, out bool res)) { anime.Restricted = res ? 1 : 0; } else { anime.Restricted = 0; } anime.URL = TryGetProperty(docAnime, "anime", "url"); anime.Picname = TryGetProperty(docAnime, "anime", "picture"); anime.DateTimeUpdated = DateTime.Now; anime.DateTimeDescUpdated = anime.DateTimeUpdated; anime.ImageEnabled = 1; #region Related Anime XmlNodeList raItems = docAnime["anime"]["relatedanime"]?.GetElementsByTagName("anime"); if (raItems != null) { anime.RelatedAnimeIdsRAW = string.Empty; anime.RelatedAnimeTypesRAW = string.Empty; foreach (XmlNode node in raItems) { if (node?.Attributes?["id"]?.Value == null) { continue; } if (!int.TryParse(node.Attributes["id"].Value, out int id)) { continue; } int relType = ConvertReltTypeTextToEnum(TryGetAttribute(node, "type")); if (anime.RelatedAnimeIdsRAW.Length > 0) { anime.RelatedAnimeIdsRAW += "'"; } if (anime.RelatedAnimeTypesRAW.Length > 0) { anime.RelatedAnimeTypesRAW += "'"; } anime.RelatedAnimeIdsRAW += id.ToString(); anime.RelatedAnimeTypesRAW += relType.ToString(); } } #endregion #region Titles XmlNodeList titleItems = docAnime["anime"]["titles"]?.GetElementsByTagName("title"); if (titleItems != null) { foreach (XmlNode node in titleItems) { string titleType = node?.Attributes?["type"]?.Value?.Trim().ToLower(); if (string.IsNullOrEmpty(titleType)) { continue; } string languageType = node.Attributes["xml:lang"]?.Value?.Trim().ToLower(); if (string.IsNullOrEmpty(languageType)) { continue; } string titleValue = node.InnerText.Trim(); if (string.IsNullOrEmpty(titleValue)) { continue; } if (titleType.Trim().ToUpper().Equals("MAIN")) { anime.MainTitle = titleValue.Replace('`', '\''); } } } #endregion #region Ratings // init ratings anime.VoteCount = 0; anime.TempVoteCount = 0; anime.Rating = 0; anime.TempRating = 0; anime.ReviewCount = 0; anime.AvgReviewRating = 0; NumberStyles style = NumberStyles.Number; CultureInfo culture = CultureInfo.CreateSpecificCulture("en-GB"); XmlNodeList ratingItems = docAnime["anime"]["ratings"]?.ChildNodes; if (ratingItems == null) { return(anime); } foreach (XmlNode node in ratingItems) { string name = node?.Name?.Trim().ToLower(); if (string.IsNullOrEmpty(name)) { continue; } if (!int.TryParse(TryGetAttribute(node, "count"), out int iCount)) { continue; } if (!decimal.TryParse(node.InnerText.Trim(), style, culture, out decimal iRating)) { continue; } iRating = (int)Math.Round(iRating * 100); if (name.Equals("permanent")) { anime.VoteCount = iCount; anime.Rating = (int)iRating; } else if (name.Equals("temporary")) { anime.TempVoteCount = iCount; anime.TempRating = (int)iRating; } else if (name.Equals("review")) { anime.ReviewCount = iCount; anime.AvgReviewRating = (int)iRating; } } #endregion return(anime); }
public static Raw_AniDB_Anime ProcessAnimeDetails(XmlDocument docAnime, int animeID) { // most of the genral anime data will be over written by the UDP command Raw_AniDB_Anime anime = new Raw_AniDB_Anime { AnimeID = animeID }; // check if there is any data try { string id = docAnime["anime"].Attributes["id"].Value; } catch { //BaseConfig.MyAnimeLog.Write("Invalid xml document: {0}", animeID.ToString()); return(null); } anime.Description = TryGetProperty(docAnime, "anime", "description"); anime.AnimeTypeRAW = TryGetProperty(docAnime, "anime", "type"); string episodecount = TryGetProperty(docAnime, "anime", "episodecount"); int.TryParse(episodecount, out int epCount); anime.EpisodeCount = epCount; anime.EpisodeCountNormal = epCount; int convertedAirDate = AniDB.GetAniDBDateAsSeconds(TryGetProperty(docAnime, "anime", "startdate"), true); int convertedEndDate = AniDB.GetAniDBDateAsSeconds(TryGetProperty(docAnime, "anime", "enddate"), false); //anime.AirDate = TryGetProperty(docAnime, "anime", "startdate"); //anime.EndDate = TryGetProperty(docAnime, "anime", "enddate"); anime.AirDate = AniDB.GetAniDBDateAsDate(convertedAirDate); anime.EndDate = AniDB.GetAniDBDateAsDate(convertedEndDate); anime.BeginYear = anime.AirDate.HasValue ? anime.AirDate.Value.Year : 0; anime.EndYear = anime.EndDate.HasValue ? anime.EndDate.Value.Year : 0; //string enddate = TryGetProperty(docAnime, "anime", "enddate"); string restricted = docAnime["anime"].Attributes["restricted"].Value; bool.TryParse(restricted, out bool res); anime.Restricted = res ? 1 : 0; anime.URL = TryGetProperty(docAnime, "anime", "url"); anime.Picname = TryGetProperty(docAnime, "anime", "picture"); anime.DateTimeUpdated = DateTime.Now; anime.DateTimeDescUpdated = anime.DateTimeUpdated; anime.ImageEnabled = 1; #region Related Anime if (docAnime["anime"]["relatedanime"] != null) { XmlNodeList raItems = docAnime["anime"]["relatedanime"].GetElementsByTagName("anime"); if (raItems != null) { anime.RelatedAnimeIdsRAW = ""; anime.RelatedAnimeTypesRAW = ""; foreach (XmlNode node in raItems) { try { int id = int.Parse(node.Attributes["id"].Value); int relType = ConvertReltTypeTextToEnum(TryGetAttribute(node, "type")); if (anime.RelatedAnimeIdsRAW.Length > 0) { anime.RelatedAnimeIdsRAW += "'"; } if (anime.RelatedAnimeTypesRAW.Length > 0) { anime.RelatedAnimeTypesRAW += "'"; } anime.RelatedAnimeIdsRAW += id.ToString(); anime.RelatedAnimeTypesRAW += relType.ToString(); } catch { //BaseConfig.MyAnimeLog.Write("Error in GetEpisodes: {0}", ex); } } } } #endregion #region Titles if (docAnime["anime"]["titles"] != null) { XmlNodeList titleItems = docAnime["anime"]["titles"].GetElementsByTagName("title"); if (titleItems != null) { foreach (XmlNode node in titleItems) { try { string titleType = node.Attributes["type"].Value.Trim().ToLower(); string languageType = node.Attributes["xml:lang"].Value.Trim().ToLower(); string titleValue = node.InnerText.Trim(); if (titleType.Trim().ToUpper() == "MAIN") { anime.MainTitle = titleValue; } } catch { //BaseConfig.MyAnimeLog.Write("Error in GetEpisodes: {0}", ex); } } } } #endregion #region Ratings // init ratings anime.VoteCount = 0; anime.TempVoteCount = 0; anime.Rating = 0; anime.TempRating = 0; anime.ReviewCount = 0; anime.AvgReviewRating = 0; NumberStyles style = NumberStyles.Number; CultureInfo culture = CultureInfo.CreateSpecificCulture("en-GB"); if (docAnime["anime"]["ratings"] != null) { XmlNodeList ratingItems = docAnime["anime"]["ratings"].ChildNodes; if (ratingItems != null) { foreach (XmlNode node in ratingItems) { try { if (node.Name.Trim().ToLower() == "permanent") { int.TryParse(TryGetAttribute(node, "count"), out int iCount); anime.VoteCount = iCount; decimal.TryParse(node.InnerText.Trim(), style, culture, out decimal iRating); anime.Rating = (int)(iRating * 100); } if (node.Name.Trim().ToLower() == "temporary") { int.TryParse(TryGetAttribute(node, "count"), out int iCount); anime.TempVoteCount = iCount; decimal.TryParse(node.InnerText.Trim(), style, culture, out decimal iRating); anime.TempRating = (int)(iRating * 100); } if (node.Name.Trim().ToLower() == "review") { int.TryParse(TryGetAttribute(node, "count"), out int iCount); anime.ReviewCount = iCount; decimal.TryParse(node.InnerText.Trim(), style, culture, out decimal iRating); anime.AvgReviewRating = (int)(iRating * 100); } } catch { //BaseConfig.MyAnimeLog.Write("Error in GetEpisodes: {0}", ex); } } } } #endregion //anime.VersionNumber = Raw_AniDB_Anime.LastVersion; //BaseConfig.MyAnimeLog.Write("Anime: {0}", anime.ToString()); return(anime); //anime.Save(true, createSeriesRecord); //AniDB_Anime.UpdateDescription(anime.AnimeID, anime.Description); }