Ejemplo n.º 1
0
        public static void GetAnime(int animeID, bool createSeriesRecord)
        {
            try
            {
                string uri = string.Format(AniDBHTTPHelper.AnimeURL, animeID);
                //BaseConfig.MyAnimeLog.Write("GetAnime: {0}", uri);
                string xml = APIUtils.DownloadWebPage(uri);

                //BaseConfig.MyAnimeLog.Write("AniDBHTTPHelper.GetAnime: {0}", xml);

                if (xml.Trim().Length == 0)
                {
                    return;
                }

                XmlDocument docAnime = new XmlDocument();
                docAnime.LoadXml(xml);

                ProcessAnimeDetails(docAnime, animeID);
                ProcessEpisodes(docAnime, animeID);
            }
            catch (Exception ex)
            {
                //BaseConfig.MyAnimeLog.Write("Error in AniDBHTTPHelper.GetAnime: {0}", ex);
                return;
            }
        }
Ejemplo n.º 2
0
        public static XmlDocument GetMyListXMLFromAPI(string username, string password, ref string rawXML)
        {
            try
            {
                //string fileName = @"C:\Projects\SVN\mylist.xml";
                //StreamReader re = File.OpenText(fileName);
                //rawXML = re.ReadToEnd();
                //re.Close();


                string uri = string.Format(AniDBHTTPHelper.MyListURL, username, password);
                rawXML = APIUtils.DownloadWebPage(uri);

                if (rawXML.Trim().Length == 0)
                {
                    return(null);
                }

                XmlDocument docAnime = new XmlDocument();
                docAnime.LoadXml(rawXML);

                return(docAnime);
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error in AniDBHTTPHelper.GetMyListXMLFromAPI: {0}", ex);
                return(null);
            }
        }
Ejemplo n.º 3
0
        public static string GetMyListXMLFromAPI(string username, string password)
        {
            try
            {
                if (ShokoService.AnidbProcessor.IsHttpBanned)
                {
                    logger.Info("GetMyListXMLFromAPI: banned, not getting");
                    return(null);
                }
                ShokoService.LastAniDBMessage     = DateTime.Now;
                ShokoService.LastAniDBHTTPMessage = DateTime.Now;

                string uri    = string.Format(MyListURL, username, password);
                string rawXML = APIUtils.DownloadWebPage(uri);

                if (0 == rawXML.Trim().Length || CheckForBan(rawXML))
                {
                    rawXML = null;
                }

                return(rawXML);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error in AniDBHTTPHelper.GetMyListXMLFromAPI: {0}");
                return(null);
            }
        }
Ejemplo n.º 4
0
        public static XmlDocument GetVotesXMLFromAPI(string username, string password)
        {
            try
            {
                if (ShokoService.AnidbProcessor.IsHttpBanned)
                {
                    logger.Info("GetVotesXMLFromAPI: banned, not getting");
                    return(null);
                }
                ShokoService.LastAniDBMessage     = DateTime.Now;
                ShokoService.LastAniDBHTTPMessage = DateTime.Now;

                string      uri      = string.Format(VotesURL, username, password);
                string      rawXML   = APIUtils.DownloadWebPage(uri);
                XmlDocument docAnime = null;
                if (0 < rawXML.Trim().Length&& !CheckForBan(rawXML))
                {
                    docAnime = new XmlDocument();
                    docAnime.LoadXml(rawXML);
                }
                return(docAnime);
            }
            catch
            {
                //BaseConfig.MyAnimeLog.Write("Error in AniDBHTTPHelper.GetAnimeXMLFromAPI: {0}", ex);
                return(null);
            }
        }
Ejemplo n.º 5
0
        public static XmlDocument GetAnimeXMLFromAPI(int animeID)
        {
            try
            {
                if (ShokoService.AnidbProcessor.IsHttpBanned)
                {
                    logger.Info("GetAnimeXMLFromAPI: banned, not getting");
                    return(null);
                }
                ShokoService.LastAniDBMessage     = DateTime.Now;
                ShokoService.LastAniDBHTTPMessage = DateTime.Now;

                var      anime      = Repo.Instance.AniDB_AnimeUpdate.GetByAnimeID(animeID);
                DateTime?prevUpdate = anime?.UpdatedAt;

                string uri = string.Format(AnimeURL, animeID);
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(ServerSettings.Instance.Culture);
                DateTime start = DateTime.Now;
                string   msg   = string.Format(Resources.AniDB_GettingAnimeXML, animeID) + "; prevUpdate: " + prevUpdate;
                ShokoService.LogToSystem(Constants.DBLogType.APIAniDBHTTP, msg);

                string rawXML = APIUtils.DownloadWebPage(uri);

                // Putting this here for no chance of error. It is ALWAYS created or updated when AniDB is called!
                var update = Repo.Instance.AniDB_AnimeUpdate.GetByAnimeID(animeID);
                using (var upd = Repo.Instance.AniDB_AnimeUpdate.BeginAddOrUpdate(() => Repo.Instance.AniDB_AnimeUpdate.GetByAnimeID(animeID), () => new AniDB_AnimeUpdate {
                    AnimeID = animeID
                }))
                {
                    upd.Entity.UpdatedAt = DateTime.Now;
                    upd.Commit();
                }

                TimeSpan ts      = DateTime.Now - start;
                string   content = rawXML;
                if (content.Length > 100)
                {
                    content = content.Substring(0, 100);
                }
                msg = string.Format(Resources.AniDB_GotAnimeXML, animeID, ts.TotalMilliseconds,
                                    content);
                ShokoService.LogToSystem(Constants.DBLogType.APIAniDBHTTP, msg);

                XmlDocument docAnime = null;
                if (0 < rawXML.Trim().Length&& !CheckForBan(rawXML))
                {
                    APIUtils.WriteAnimeHTTPToFile(animeID, rawXML);

                    docAnime = new XmlDocument();
                    docAnime.LoadXml(rawXML);
                }

                return(docAnime);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error in AniDBHTTPHelper.GetAnimeXMLFromAPI: {0}");
                return(null);
            }
        }
Ejemplo n.º 6
0
        public static XmlDocument GetAnimeXMLFromAPI(int animeID, ref string rawXML)
        {
            try
            {
                string uri = string.Format(AnimeURL, animeID);
                //APIUtils.WriteToLog("GetAnimeXMLFromAPI: " + uri);

                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(ServerSettings.Culture);

                DateTime start = DateTime.Now;
                string   msg   = string.Format(Resources.AniDB_GettingAnimeXML, animeID);
                ShokoService.LogToSystem(Constants.DBLogType.APIAniDBHTTP, msg);

                rawXML = APIUtils.DownloadWebPage(uri);

                // Putting this here for no chance of error. It is ALWAYS created or updated when AniDB is called!
                var update = RepoFactory.AniDB_AnimeUpdate.GetByAnimeID(animeID);
                if (update == null)
                {
                    update = new AniDB_AnimeUpdate {
                        AnimeID = animeID, UpdatedAt = DateTime.Now
                    }
                }
                ;
                else
                {
                    update.UpdatedAt = DateTime.Now;
                }
                RepoFactory.AniDB_AnimeUpdate.Save(update);

                TimeSpan ts      = DateTime.Now - start;
                string   content = rawXML;
                if (content.Length > 100)
                {
                    content = content.Substring(0, 100);
                }
                msg = string.Format(Resources.AniDB_GotAnimeXML, animeID, ts.TotalMilliseconds,
                                    content);
                ShokoService.LogToSystem(Constants.DBLogType.APIAniDBHTTP, msg);

                //APIUtils.WriteToLog("GetAnimeXMLFromAPI result: " + rawXML);

                if (rawXML.Trim().Length == 0)
                {
                    return(null);
                }

                XmlDocument docAnime = new XmlDocument();
                docAnime.LoadXml(rawXML);

                return(docAnime);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error in AniDBHTTPHelper.GetAnimeXMLFromAPI: {0}");
                return(null);
            }
        }
Ejemplo n.º 7
0
        public static XmlDocument GetAnimeXMLFromAPI(int animeID, ref string rawXML)
        {
            try
            {
                string uri = string.Format(AniDBHTTPHelper.AnimeURL, animeID);
                //APIUtils.WriteToLog("GetAnimeXMLFromAPI: " + uri);

                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(ServerSettings.Culture);

                DateTime start = DateTime.Now;
                string   msg   = string.Format(JMMServer.Properties.Resources.AniDB_GettingAnimeXML, animeID);
                JMMService.LogToSystem(Constants.DBLogType.APIAniDBHTTP, msg);

                rawXML = APIUtils.DownloadWebPage(uri);

                TimeSpan ts      = DateTime.Now - start;
                string   content = rawXML;
                if (content.Length > 100)
                {
                    content = content.Substring(0, 100);
                }
                msg = string.Format(JMMServer.Properties.Resources.AniDB_GotAnimeXML, animeID, ts.TotalMilliseconds,
                                    content);
                JMMService.LogToSystem(Constants.DBLogType.APIAniDBHTTP, msg);

                //APIUtils.WriteToLog("GetAnimeXMLFromAPI result: " + rawXML);

                if (rawXML.Trim().Length == 0)
                {
                    return(null);
                }

                XmlDocument docAnime = new XmlDocument();
                docAnime.LoadXml(rawXML);

                return(docAnime);
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error in AniDBHTTPHelper.GetAnimeXMLFromAPI: {0}", ex);
                return(null);
            }
        }
Ejemplo n.º 8
0
        public static XmlDocument GetAnimeXMLFromAPI(int animeID, ref string rawXML)
        {
            try
            {
                string uri = string.Format(AniDBHTTPHelper.AnimeURL, animeID);
                //APIUtils.WriteToLog("GetAnimeXMLFromAPI: " + uri);

                DateTime start = DateTime.Now;
                string   msg   = string.Format("Getting Anime XML Data From ANIDB: {0}", animeID);
                JMMService.LogToDatabase(Constants.DBLogType.APIAniDBHTTP, msg);

                rawXML = APIUtils.DownloadWebPage(uri);

                TimeSpan ts      = DateTime.Now - start;
                string   content = rawXML;
                if (content.Length > 100)
                {
                    content = content.Substring(0, 100);
                }
                msg = string.Format("Got Anime XML Data From ANIDB: {0} - {1} - {2}", animeID, ts.TotalMilliseconds, content);
                JMMService.LogToDatabase(Constants.DBLogType.APIAniDBHTTP, msg);

                //APIUtils.WriteToLog("GetAnimeXMLFromAPI result: " + rawXML);

                if (rawXML.Trim().Length == 0)
                {
                    return(null);
                }

                XmlDocument docAnime = new XmlDocument();
                docAnime.LoadXml(rawXML);

                return(docAnime);
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error in AniDBHTTPHelper.GetAnimeXMLFromAPI: {0}", ex);
                return(null);
            }
        }
Ejemplo n.º 9
0
        public static XmlDocument GetVotesXMLFromAPI(string username, string password, ref string rawXML)
        {
            try
            {
                string uri = string.Format(AniDBHTTPHelper.VotesURL, username, password);
                rawXML = APIUtils.DownloadWebPage(uri);

                if (rawXML.Trim().Length == 0)
                {
                    return(null);
                }

                XmlDocument docAnime = new XmlDocument();
                docAnime.LoadXml(rawXML);

                return(docAnime);
            }
            catch (Exception ex)
            {
                //BaseConfig.MyAnimeLog.Write("Error in AniDBHTTPHelper.GetAnimeXMLFromAPI: {0}", ex);
                return(null);
            }
        }