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 virtual enHelperActivityType Process() { ShokoService.LastAniDBMessage = DateTime.Now; ShokoService.LastAniDBHTTPMessage = DateTime.Now; XmlDocument docAnime = AniDBHTTPHelper.GetMyListXMLFromAPI(username, password, ref xmlResult); //XmlDocument docAnime = LoadAnimeMyListFromFile(); //APIUtils.WriteToLog("AniDBHTTPCommand_GetFullAnime: " + xmlResult); if (xmlResult.Trim().Length > 0) { WriteAnimeMyListToFile(xmlResult); } if (CheckForBan(xmlResult)) { return(enHelperActivityType.NoSuchAnime); } if (docAnime != null) { myListItems = AniDBHTTPHelper.ProcessMyList(docAnime); return(enHelperActivityType.GotMyListHTTP); } else { return(enHelperActivityType.NoSuchAnime); } }
public static void PopulateResourceLinks() { int i = 0; var animes = RepoFactory.AniDB_Anime.GetAll().ToList(); foreach (var anime in animes) { if (i % 10 == 0) { ServerState.Instance.CurrentSetupStatus = string.Format( Commons.Properties.Resources.Database_Validating, "Populating Resource Links from Cache", $" {i}/{animes.Count}"); } i++; try { var xmlDocument = APIUtils.LoadAnimeHTTPFromFile(anime.AnimeID); if (xmlDocument == null) { continue; } var resourceLinks = AniDBHTTPHelper.ProcessResources(xmlDocument, anime.AnimeID); anime.CreateResources(resourceLinks); } catch (Exception e) { logger.Error( $"There was an error Populating Resource Links for AniDB_Anime {anime.AnimeID}, Update the Series' AniDB Info for a full stack: {e.Message}"); } } using (var session = DatabaseFactory.SessionFactory.OpenStatelessSession()) { i = 0; var batches = animes.Batch(50).ToList(); foreach (var animeBatch in batches) { i++; ServerState.Instance.CurrentSetupStatus = string.Format(Commons.Properties.Resources.Database_Validating, "Saving AniDB_Anime batch ", $"{i}/{batches.Count}"); try { using (var transaction = session.BeginTransaction()) { foreach (var anime in animeBatch) { RepoFactory.AniDB_Anime.SaveWithOpenTransaction(session.Wrap(), anime); } transaction.Commit(); } } catch (Exception e) { logger.Error($"There was an error saving anime while Populating Resource Links: {e}"); } } } }
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"); }
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; }
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; }
public virtual AniDBUDPResponseCode Process() { XmlDocument docAnime = AniDBHTTPHelper.GetVotesXMLFromAPI(username, password); //APIUtils.WriteToLog("AniDBHTTPCommand_GetFullAnime: " + xmlResult); if (docAnime != null) { myVotes = AniDBHTTPHelper.ProcessVotes(docAnime); return(AniDBUDPResponseCode.GotVotesHTTP); } return(AniDBUDPResponseCode.NoSuchAnime); }
public static void FixAniDB_EpisodesWithMissingTitles() { logger.Info("Checking for Episodes with Missing Titles"); var episodes = RepoFactory.AniDB_Episode.GetAll() .Where(a => !RepoFactory.AniDB_Episode_Title.GetByEpisodeID(a.EpisodeID).Any() && RepoFactory.AnimeSeries.GetByAnimeID(a.AnimeID) != null).ToList(); var animeIDs = episodes.Select(a => a.AnimeID).Distinct().OrderBy(a => a).ToList(); int count = 0; logger.Info($"There are {episodes.Count} episodes in {animeIDs.Count} anime with missing titles. Attempting to fill them from HTTP cache"); foreach (int animeID in animeIDs) { count++; try { var anime = RepoFactory.AniDB_Anime.GetByAnimeID(animeID); if (anime == null) { logger.Info($"Anime {animeID} is missing it's AniDB_Anime record. That's a problem. Try importing a file for the anime."); continue; } ServerState.Instance.CurrentSetupStatus = string.Format( Commons.Properties.Resources.Database_Validating, $"Generating Episode Info for {anime.MainTitle}", $" {count}/{animeIDs.Count}"); XmlDocument docAnime = APIUtils.LoadAnimeHTTPFromFile(animeID); if (docAnime == null) { continue; } logger.Info($"{anime.MainTitle} has a proper HTTP cache. Attempting to regenerate info from it."); var rawEpisodes = AniDBHTTPHelper.ProcessEpisodes(docAnime, animeID); anime.CreateEpisodes(rawEpisodes); logger.Info($"Recreating Episodes for {anime.MainTitle}"); SVR_AnimeSeries series = RepoFactory.AnimeSeries.GetByAnimeID(anime.AnimeID); if (series == null) { continue; } series.CreateAnimeEpisodes(); } catch (Exception e) { logger.Error($"Error Populating Episode Titles for Anime ({animeID}): {e}"); } } logger.Info("Finished Filling Episode Titles from Cache."); }
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; }
public virtual enHelperActivityType Process() { XmlDocument docAnime = AniDBHTTPHelper.GetVotesXMLFromAPI(username, password, ref xmlResult); if (CheckForBan(xmlResult)) { return(enHelperActivityType.NoSuchAnime); } //APIUtils.WriteToLog("AniDBHTTPCommand_GetFullAnime: " + xmlResult); if (docAnime != null) { myVotes = AniDBHTTPHelper.ProcessVotes(docAnime); return(enHelperActivityType.GotVotesHTTP); } return(enHelperActivityType.NoSuchAnime); }
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); } } }
public ActionResult UpdateMissingAniDBXML() { try { var allAnime = RepoFactory.AniDB_Anime.GetAll().Select(a => a.AnimeID).OrderBy(a => a).ToList(); logger.Info($"Starting the check for {allAnime.Count} anime XML files"); int updatedAnime = 0; for (var i = 0; i < allAnime.Count; i++) { var animeID = allAnime[i]; if (i % 10 == 1) { logger.Info($"Checking anime {i + 1}/{allAnime.Count} for XML file"); } var xml = APIUtils.LoadAnimeHTTPFromFile(animeID); if (xml == null) { CommandRequest_GetAnimeHTTP cmd = new CommandRequest_GetAnimeHTTP(animeID, true, false); cmd.Save(); updatedAnime++; continue; } var rawAnime = AniDBHTTPHelper.ProcessAnimeDetails(xml, animeID); if (rawAnime == null) { CommandRequest_GetAnimeHTTP cmd = new CommandRequest_GetAnimeHTTP(animeID, true, false); cmd.Save(); updatedAnime++; } } logger.Info($"Updating {updatedAnime} anime"); } catch (Exception e) { logger.Error($"Error checking and queuing AniDB XML Updates: {e}"); return(APIStatus.InternalError(e.Message)); } return(APIStatus.OK()); }
public virtual enHelperActivityType Process() { string xmlResult = AniDBHTTPHelper.GetMyListXMLFromAPI(username, password); XmlDocument docAnime = null; if (0 < xmlResult.Trim().Length) { WriteAnimeMyListToFile(xmlResult); docAnime = new XmlDocument(); docAnime.LoadXml(xmlResult); } if (docAnime != null) { myListItems = AniDBHTTPHelper.ProcessMyList(docAnime); if (myListItems != null) { return(enHelperActivityType.GotMyListHTTP); } } return(enHelperActivityType.NoSuchAnime); }
public ActionResult UpdateMissingAniDBXML() { try { var allAnime = RepoFactory.AniDB_Anime.GetAll().Select(a => a.AnimeID).OrderBy(a => a).ToList(); Logger.LogInformation($"Starting the check for {allAnime.Count} anime XML files"); int updatedAnime = 0; for (var i = 0; i < allAnime.Count; i++) { var animeID = allAnime[i]; if (i % 10 == 1) { Logger.LogInformation($"Checking anime {i + 1}/{allAnime.Count} for XML file"); } var xml = APIUtils.LoadAnimeHTTPFromFile(animeID); if (xml == null) { Series.QueueAniDBRefresh(animeID, true, false, false); updatedAnime++; continue; } var rawAnime = AniDBHTTPHelper.ProcessAnimeDetails(xml, animeID); if (rawAnime == null) { Series.QueueAniDBRefresh(animeID, true, false, false); updatedAnime++; } } Logger.LogInformation($"Updating {updatedAnime} anime"); } catch (Exception e) { Logger.LogError(e, $"Error checking and queuing AniDB XML Updates: {e}"); return(InternalError(e.Message)); } return(Ok()); }
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; }
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 }
public static void FixAniDB_EpisodesWithMissingTitles() { var specials = RepoFactory.AniDB_Episode.GetAll().Where(a => string.IsNullOrEmpty(a.GetEnglishTitle())) .Select(a => a.AnimeID).Distinct().OrderBy(a => a).ToList(); int count = 0; foreach (int animeID in specials) { count++; try { var anime = RepoFactory.AniDB_Anime.GetByAnimeID(animeID); if (anime == null) { continue; } ServerState.Instance.CurrentSetupStatus = string.Format( Commons.Properties.Resources.Database_Validating, $"Generating Episode Info for {anime.MainTitle}", $" {count}/{specials.Count}"); XmlDocument docAnime = APIUtils.LoadAnimeHTTPFromFile(animeID); if (docAnime == null) { continue; } var episodes = AniDBHTTPHelper.ProcessEpisodes(docAnime, animeID); anime.CreateEpisodes(episodes); // we don't need to save the AniDB_Anime, since nothing has changed in it } catch (Exception e) { logger.Error($"Error Populating Episode Titles for Anime ({animeID}): {e}"); } } }
public virtual enHelperActivityType Process() { string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string filePath = Path.Combine(appPath, "Anime_HTTP"); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string fileName = string.Format("AnimeDoc_{0}.xml", animeID); string fileNameWithPath = Path.Combine(filePath, fileName); if (!CacheOnly) { JMMService.LastAniDBMessage = DateTime.Now; JMMService.LastAniDBHTTPMessage = DateTime.Now; } XmlDocument docAnime = null; if (CacheOnly) { xmlResult = AzureWebAPI.Get_AnimeXML(animeID); if (!string.IsNullOrEmpty(xmlResult)) { docAnime = new XmlDocument(); docAnime.LoadXml(xmlResult); } } else { if (!ForceFromAniDB) { //Disable usage of Azure API for this type of data /*xmlResult = AzureWebAPI.Get_AnimeXML(animeID); * if (string.IsNullOrEmpty(xmlResult)) * { * docAnime = AniDBHTTPHelper.GetAnimeXMLFromAPI(animeID, ref xmlResult); * } * else * { * docAnime = new XmlDocument(); * docAnime.LoadXml(xmlResult); * }*/ docAnime = AniDBHTTPHelper.GetAnimeXMLFromAPI(animeID, ref xmlResult); } else { docAnime = AniDBHTTPHelper.GetAnimeXMLFromAPI(animeID, ref xmlResult); //XmlDocument docAnime = LoadAnimeHTTPFromFile(animeID); } } if (xmlResult.Trim().Length > 0) { WriteAnimeHTTPToFile(animeID, xmlResult); } if (CheckForBan(xmlResult)) { return(enHelperActivityType.NoSuchAnime); } if (docAnime != null) { anime = AniDBHTTPHelper.ProcessAnimeDetails(docAnime, animeID); episodes = AniDBHTTPHelper.ProcessEpisodes(docAnime, animeID); titles = AniDBHTTPHelper.ProcessTitles(docAnime, animeID); tags = AniDBHTTPHelper.ProcessTags(docAnime, animeID); characters = AniDBHTTPHelper.ProcessCharacters(docAnime, animeID); relations = AniDBHTTPHelper.ProcessRelations(docAnime, animeID); similarAnime = AniDBHTTPHelper.ProcessSimilarAnime(docAnime, animeID); recommendations = AniDBHTTPHelper.ProcessRecommendations(docAnime, animeID); return(enHelperActivityType.GotAnimeInfoHTTP); } else { return(enHelperActivityType.NoSuchAnime); } }
public virtual enHelperActivityType Process() { if (!CacheOnly) { ShokoService.LastAniDBMessage = DateTime.Now; ShokoService.LastAniDBHTTPMessage = DateTime.Now; } XmlDocument docAnime = null; if (CacheOnly) { xmlResult = AzureWebAPI.Get_AnimeXML(animeID); if (!string.IsNullOrEmpty(xmlResult)) { docAnime = new XmlDocument(); docAnime.LoadXml(xmlResult); } } else { if (!ForceFromAniDB) { //Disable usage of Azure API for this type of data /*xmlResult = AzureWebAPI.Get_AnimeXML(animeID); * if (string.IsNullOrEmpty(xmlResult)) * { * docAnime = AniDBHTTPHelper.GetAnimeXMLFromAPI(animeID, ref xmlResult); * } * else * { * docAnime = new XmlDocument(); * docAnime.LoadXml(xmlResult); * }*/ //logger.Info("Trying to load Anime HTTP info from cache file..."); docAnime = LoadAnimeHTTPFromFile(animeID); if (docAnime == null) { //logger.Info("No Anime HTTP info found in cache file, loading from HTTP API"); docAnime = AniDBHTTPHelper.GetAnimeXMLFromAPI(animeID, ref xmlResult); } } else { docAnime = AniDBHTTPHelper.GetAnimeXMLFromAPI(animeID, ref xmlResult); } } if (CheckForBan(xmlResult)) { return(enHelperActivityType.NoSuchAnime); } if (xmlResult.Trim().Length > 0) { WriteAnimeHTTPToFile(animeID, xmlResult); } if (docAnime != null) { anime = AniDBHTTPHelper.ProcessAnimeDetails(docAnime, animeID); episodes = AniDBHTTPHelper.ProcessEpisodes(docAnime, animeID); titles = AniDBHTTPHelper.ProcessTitles(docAnime, animeID); tags = AniDBHTTPHelper.ProcessTags(docAnime, animeID); characters = AniDBHTTPHelper.ProcessCharacters(docAnime, animeID); relations = AniDBHTTPHelper.ProcessRelations(docAnime, animeID); similarAnime = AniDBHTTPHelper.ProcessSimilarAnime(docAnime, animeID); recommendations = AniDBHTTPHelper.ProcessRecommendations(docAnime, animeID); return(enHelperActivityType.GotAnimeInfoHTTP); } else { return(enHelperActivityType.NoSuchAnime); } }
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"); }
public static anime SearchAnimesByTitle(string searchTitle) { if (string.IsNullOrEmpty(ServerSettings.MAL_Username) || string.IsNullOrEmpty(ServerSettings.MAL_Password)) { logger.Warn("Won't search MAL, MAL credentials not provided"); return(GetEmptyAnimes()); } searchTitle = HttpUtility.UrlPathEncode(searchTitle); string searchResultXML = ""; try { searchResultXML = SendMALAuthenticatedRequest("https://myanimelist.net/api/anime/search.xml?q=" + searchTitle); } catch (Exception ex) { logger.Error(ex, ex.ToString()); return(GetEmptyAnimes()); } if (searchResultXML.Trim().Length == 0) { return(GetEmptyAnimes()); } searchResultXML = HttpUtility.HtmlDecode(searchResultXML); searchResultXML = HttpUtilityV2.HtmlDecode(searchResultXML); searchResultXML = searchResultXML.Replace("&", "&"); XmlDocument docSearchResult = new XmlDocument(); docSearchResult.LoadXml(searchResultXML); anime animes = GetEmptyAnimes(); List <animeEntry> entries = new List <animeEntry>(); if (docSearchResult != null && docSearchResult["anime"] != null) { XmlNodeList searchItems = docSearchResult["anime"].GetElementsByTagName("entry"); foreach (XmlNode node in searchItems) { try { animeEntry entry = new animeEntry(); // default values entry.end_date = string.Empty; entry.english = string.Empty; entry.episodes = 0; entry.id = 0; entry.image = string.Empty; entry.score = 0; entry.start_date = string.Empty; entry.status = string.Empty; entry.synonyms = string.Empty; entry.synopsis = string.Empty; entry.title = string.Empty; entry.type = string.Empty; entry.end_date = AniDBHTTPHelper.TryGetProperty(node, "end_date"); entry.english = AniDBHTTPHelper.TryGetProperty(node, "english"); entry.image = AniDBHTTPHelper.TryGetProperty(node, "image"); int eps = 0; int id = 0; decimal score = 0; int.TryParse(AniDBHTTPHelper.TryGetProperty(node, "episodes"), out eps); int.TryParse(AniDBHTTPHelper.TryGetProperty(node, "id"), out id); decimal.TryParse(AniDBHTTPHelper.TryGetProperty(node, "score"), out score); entry.episodes = eps; entry.id = id; entry.score = score; entry.start_date = AniDBHTTPHelper.TryGetProperty(node, "start_date"); entry.status = AniDBHTTPHelper.TryGetProperty(node, "status"); entry.synonyms = AniDBHTTPHelper.TryGetProperty(node, "synonyms"); entry.synopsis = AniDBHTTPHelper.TryGetProperty(node, "synopsis"); entry.title = AniDBHTTPHelper.TryGetProperty(node, "title"); entry.type = AniDBHTTPHelper.TryGetProperty(node, "type"); entries.Add(entry); } catch (Exception ex) { logger.Error(ex, ex.ToString()); } } } animes.entry = entries.ToArray(); return(animes); }
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); }